babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034
  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. }
  5247. }
  5248. declare module "babylonjs/Meshes/dataBuffer" {
  5249. /**
  5250. * Class used to store gfx data (like WebGLBuffer)
  5251. */
  5252. export class DataBuffer {
  5253. /**
  5254. * Gets or sets the number of objects referencing this buffer
  5255. */
  5256. references: number;
  5257. /** Gets or sets the size of the underlying buffer */
  5258. capacity: number;
  5259. /**
  5260. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5261. */
  5262. is32Bits: boolean;
  5263. /**
  5264. * Gets the underlying buffer
  5265. */
  5266. readonly underlyingResource: any;
  5267. }
  5268. }
  5269. declare module "babylonjs/Misc/performanceMonitor" {
  5270. /**
  5271. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5272. */
  5273. export class PerformanceMonitor {
  5274. private _enabled;
  5275. private _rollingFrameTime;
  5276. private _lastFrameTimeMs;
  5277. /**
  5278. * constructor
  5279. * @param frameSampleSize The number of samples required to saturate the sliding window
  5280. */
  5281. constructor(frameSampleSize?: number);
  5282. /**
  5283. * Samples current frame
  5284. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5285. */
  5286. sampleFrame(timeMs?: number): void;
  5287. /**
  5288. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5289. */
  5290. readonly averageFrameTime: number;
  5291. /**
  5292. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5293. */
  5294. readonly averageFrameTimeVariance: number;
  5295. /**
  5296. * Returns the frame time of the most recent frame
  5297. */
  5298. readonly instantaneousFrameTime: number;
  5299. /**
  5300. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5301. */
  5302. readonly averageFPS: number;
  5303. /**
  5304. * Returns the average framerate in frames per second using the most recent frame time
  5305. */
  5306. readonly instantaneousFPS: number;
  5307. /**
  5308. * Returns true if enough samples have been taken to completely fill the sliding window
  5309. */
  5310. readonly isSaturated: boolean;
  5311. /**
  5312. * Enables contributions to the sliding window sample set
  5313. */
  5314. enable(): void;
  5315. /**
  5316. * Disables contributions to the sliding window sample set
  5317. * Samples will not be interpolated over the disabled period
  5318. */
  5319. disable(): void;
  5320. /**
  5321. * Returns true if sampling is enabled
  5322. */
  5323. readonly isEnabled: boolean;
  5324. /**
  5325. * Resets performance monitor
  5326. */
  5327. reset(): void;
  5328. }
  5329. /**
  5330. * RollingAverage
  5331. *
  5332. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5333. */
  5334. export class RollingAverage {
  5335. /**
  5336. * Current average
  5337. */
  5338. average: number;
  5339. /**
  5340. * Current variance
  5341. */
  5342. variance: number;
  5343. protected _samples: Array<number>;
  5344. protected _sampleCount: number;
  5345. protected _pos: number;
  5346. protected _m2: number;
  5347. /**
  5348. * constructor
  5349. * @param length The number of samples required to saturate the sliding window
  5350. */
  5351. constructor(length: number);
  5352. /**
  5353. * Adds a sample to the sample set
  5354. * @param v The sample value
  5355. */
  5356. add(v: number): void;
  5357. /**
  5358. * Returns previously added values or null if outside of history or outside the sliding window domain
  5359. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5360. * @return Value previously recorded with add() or null if outside of range
  5361. */
  5362. history(i: number): number;
  5363. /**
  5364. * Returns true if enough samples have been taken to completely fill the sliding window
  5365. * @return true if sample-set saturated
  5366. */
  5367. isSaturated(): boolean;
  5368. /**
  5369. * Resets the rolling average (equivalent to 0 samples taken so far)
  5370. */
  5371. reset(): void;
  5372. /**
  5373. * Wraps a value around the sample range boundaries
  5374. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5375. * @return Wrapped position in sample range
  5376. */
  5377. protected _wrapPosition(i: number): number;
  5378. }
  5379. }
  5380. declare module "babylonjs/Misc/stringDictionary" {
  5381. import { Nullable } from "babylonjs/types";
  5382. /**
  5383. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5384. * The underlying implementation relies on an associative array to ensure the best performances.
  5385. * The value can be anything including 'null' but except 'undefined'
  5386. */
  5387. export class StringDictionary<T> {
  5388. /**
  5389. * This will clear this dictionary and copy the content from the 'source' one.
  5390. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5391. * @param source the dictionary to take the content from and copy to this dictionary
  5392. */
  5393. copyFrom(source: StringDictionary<T>): void;
  5394. /**
  5395. * Get a value based from its key
  5396. * @param key the given key to get the matching value from
  5397. * @return the value if found, otherwise undefined is returned
  5398. */
  5399. get(key: string): T | undefined;
  5400. /**
  5401. * Get a value from its key or add it if it doesn't exist.
  5402. * This method will ensure you that a given key/data will be present in the dictionary.
  5403. * @param key the given key to get the matching value from
  5404. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5405. * The factory will only be invoked if there's no data for the given key.
  5406. * @return the value corresponding to the key.
  5407. */
  5408. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5409. /**
  5410. * Get a value from its key if present in the dictionary otherwise add it
  5411. * @param key the key to get the value from
  5412. * @param val if there's no such key/value pair in the dictionary add it with this value
  5413. * @return the value corresponding to the key
  5414. */
  5415. getOrAdd(key: string, val: T): T;
  5416. /**
  5417. * Check if there's a given key in the dictionary
  5418. * @param key the key to check for
  5419. * @return true if the key is present, false otherwise
  5420. */
  5421. contains(key: string): boolean;
  5422. /**
  5423. * Add a new key and its corresponding value
  5424. * @param key the key to add
  5425. * @param value the value corresponding to the key
  5426. * @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
  5427. */
  5428. add(key: string, value: T): boolean;
  5429. /**
  5430. * Update a specific value associated to a key
  5431. * @param key defines the key to use
  5432. * @param value defines the value to store
  5433. * @returns true if the value was updated (or false if the key was not found)
  5434. */
  5435. set(key: string, value: T): boolean;
  5436. /**
  5437. * Get the element of the given key and remove it from the dictionary
  5438. * @param key defines the key to search
  5439. * @returns the value associated with the key or null if not found
  5440. */
  5441. getAndRemove(key: string): Nullable<T>;
  5442. /**
  5443. * Remove a key/value from the dictionary.
  5444. * @param key the key to remove
  5445. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5446. */
  5447. remove(key: string): boolean;
  5448. /**
  5449. * Clear the whole content of the dictionary
  5450. */
  5451. clear(): void;
  5452. /**
  5453. * Gets the current count
  5454. */
  5455. readonly count: number;
  5456. /**
  5457. * Execute a callback on each key/val of the dictionary.
  5458. * Note that you can remove any element in this dictionary in the callback implementation
  5459. * @param callback the callback to execute on a given key/value pair
  5460. */
  5461. forEach(callback: (key: string, val: T) => void): void;
  5462. /**
  5463. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5464. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5465. * Note that you can remove any element in this dictionary in the callback implementation
  5466. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5467. * @returns the first item
  5468. */
  5469. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5470. private _count;
  5471. private _data;
  5472. }
  5473. }
  5474. declare module "babylonjs/Misc/promise" {
  5475. /**
  5476. * Helper class that provides a small promise polyfill
  5477. */
  5478. export class PromisePolyfill {
  5479. /**
  5480. * Static function used to check if the polyfill is required
  5481. * If this is the case then the function will inject the polyfill to window.Promise
  5482. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5483. */
  5484. static Apply(force?: boolean): void;
  5485. }
  5486. }
  5487. declare module "babylonjs/Meshes/buffer" {
  5488. import { Nullable, DataArray } from "babylonjs/types";
  5489. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5490. /**
  5491. * Class used to store data that will be store in GPU memory
  5492. */
  5493. export class Buffer {
  5494. private _engine;
  5495. private _buffer;
  5496. /** @hidden */
  5497. _data: Nullable<DataArray>;
  5498. private _updatable;
  5499. private _instanced;
  5500. /**
  5501. * Gets the byte stride.
  5502. */
  5503. readonly byteStride: number;
  5504. /**
  5505. * Constructor
  5506. * @param engine the engine
  5507. * @param data the data to use for this buffer
  5508. * @param updatable whether the data is updatable
  5509. * @param stride the stride (optional)
  5510. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5511. * @param instanced whether the buffer is instanced (optional)
  5512. * @param useBytes set to true if the stride in in bytes (optional)
  5513. */
  5514. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5515. /**
  5516. * Create a new VertexBuffer based on the current buffer
  5517. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5518. * @param offset defines offset in the buffer (0 by default)
  5519. * @param size defines the size in floats of attributes (position is 3 for instance)
  5520. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5521. * @param instanced defines if the vertex buffer contains indexed data
  5522. * @param useBytes defines if the offset and stride are in bytes
  5523. * @returns the new vertex buffer
  5524. */
  5525. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5526. /**
  5527. * Gets a boolean indicating if the Buffer is updatable?
  5528. * @returns true if the buffer is updatable
  5529. */
  5530. isUpdatable(): boolean;
  5531. /**
  5532. * Gets current buffer's data
  5533. * @returns a DataArray or null
  5534. */
  5535. getData(): Nullable<DataArray>;
  5536. /**
  5537. * Gets underlying native buffer
  5538. * @returns underlying native buffer
  5539. */
  5540. getBuffer(): Nullable<DataBuffer>;
  5541. /**
  5542. * Gets the stride in float32 units (i.e. byte stride / 4).
  5543. * May not be an integer if the byte stride is not divisible by 4.
  5544. * DEPRECATED. Use byteStride instead.
  5545. * @returns the stride in float32 units
  5546. */
  5547. getStrideSize(): number;
  5548. /**
  5549. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5550. * @param data defines the data to store
  5551. */
  5552. create(data?: Nullable<DataArray>): void;
  5553. /** @hidden */
  5554. _rebuild(): void;
  5555. /**
  5556. * Update current buffer data
  5557. * @param data defines the data to store
  5558. */
  5559. update(data: DataArray): void;
  5560. /**
  5561. * Updates the data directly.
  5562. * @param data the new data
  5563. * @param offset the new offset
  5564. * @param vertexCount the vertex count (optional)
  5565. * @param useBytes set to true if the offset is in bytes
  5566. */
  5567. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5568. /**
  5569. * Release all resources
  5570. */
  5571. dispose(): void;
  5572. }
  5573. /**
  5574. * Specialized buffer used to store vertex data
  5575. */
  5576. export class VertexBuffer {
  5577. /** @hidden */
  5578. _buffer: Buffer;
  5579. private _kind;
  5580. private _size;
  5581. private _ownsBuffer;
  5582. private _instanced;
  5583. private _instanceDivisor;
  5584. /**
  5585. * The byte type.
  5586. */
  5587. static readonly BYTE: number;
  5588. /**
  5589. * The unsigned byte type.
  5590. */
  5591. static readonly UNSIGNED_BYTE: number;
  5592. /**
  5593. * The short type.
  5594. */
  5595. static readonly SHORT: number;
  5596. /**
  5597. * The unsigned short type.
  5598. */
  5599. static readonly UNSIGNED_SHORT: number;
  5600. /**
  5601. * The integer type.
  5602. */
  5603. static readonly INT: number;
  5604. /**
  5605. * The unsigned integer type.
  5606. */
  5607. static readonly UNSIGNED_INT: number;
  5608. /**
  5609. * The float type.
  5610. */
  5611. static readonly FLOAT: number;
  5612. /**
  5613. * Gets or sets the instance divisor when in instanced mode
  5614. */
  5615. instanceDivisor: number;
  5616. /**
  5617. * Gets the byte stride.
  5618. */
  5619. readonly byteStride: number;
  5620. /**
  5621. * Gets the byte offset.
  5622. */
  5623. readonly byteOffset: number;
  5624. /**
  5625. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5626. */
  5627. readonly normalized: boolean;
  5628. /**
  5629. * Gets the data type of each component in the array.
  5630. */
  5631. readonly type: number;
  5632. /**
  5633. * Constructor
  5634. * @param engine the engine
  5635. * @param data the data to use for this vertex buffer
  5636. * @param kind the vertex buffer kind
  5637. * @param updatable whether the data is updatable
  5638. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5639. * @param stride the stride (optional)
  5640. * @param instanced whether the buffer is instanced (optional)
  5641. * @param offset the offset of the data (optional)
  5642. * @param size the number of components (optional)
  5643. * @param type the type of the component (optional)
  5644. * @param normalized whether the data contains normalized data (optional)
  5645. * @param useBytes set to true if stride and offset are in bytes (optional)
  5646. */
  5647. 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);
  5648. /** @hidden */
  5649. _rebuild(): void;
  5650. /**
  5651. * Returns the kind of the VertexBuffer (string)
  5652. * @returns a string
  5653. */
  5654. getKind(): string;
  5655. /**
  5656. * Gets a boolean indicating if the VertexBuffer is updatable?
  5657. * @returns true if the buffer is updatable
  5658. */
  5659. isUpdatable(): boolean;
  5660. /**
  5661. * Gets current buffer's data
  5662. * @returns a DataArray or null
  5663. */
  5664. getData(): Nullable<DataArray>;
  5665. /**
  5666. * Gets underlying native buffer
  5667. * @returns underlying native buffer
  5668. */
  5669. getBuffer(): Nullable<DataBuffer>;
  5670. /**
  5671. * Gets the stride in float32 units (i.e. byte stride / 4).
  5672. * May not be an integer if the byte stride is not divisible by 4.
  5673. * DEPRECATED. Use byteStride instead.
  5674. * @returns the stride in float32 units
  5675. */
  5676. getStrideSize(): number;
  5677. /**
  5678. * Returns the offset as a multiple of the type byte length.
  5679. * DEPRECATED. Use byteOffset instead.
  5680. * @returns the offset in bytes
  5681. */
  5682. getOffset(): number;
  5683. /**
  5684. * Returns the number of components per vertex attribute (integer)
  5685. * @returns the size in float
  5686. */
  5687. getSize(): number;
  5688. /**
  5689. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5690. * @returns true if this buffer is instanced
  5691. */
  5692. getIsInstanced(): boolean;
  5693. /**
  5694. * Returns the instancing divisor, zero for non-instanced (integer).
  5695. * @returns a number
  5696. */
  5697. getInstanceDivisor(): number;
  5698. /**
  5699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5700. * @param data defines the data to store
  5701. */
  5702. create(data?: DataArray): void;
  5703. /**
  5704. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5705. * This function will create a new buffer if the current one is not updatable
  5706. * @param data defines the data to store
  5707. */
  5708. update(data: DataArray): void;
  5709. /**
  5710. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5711. * Returns the directly updated WebGLBuffer.
  5712. * @param data the new data
  5713. * @param offset the new offset
  5714. * @param useBytes set to true if the offset is in bytes
  5715. */
  5716. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5717. /**
  5718. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5719. */
  5720. dispose(): void;
  5721. /**
  5722. * Enumerates each value of this vertex buffer as numbers.
  5723. * @param count the number of values to enumerate
  5724. * @param callback the callback function called for each value
  5725. */
  5726. forEach(count: number, callback: (value: number, index: number) => void): void;
  5727. /**
  5728. * Positions
  5729. */
  5730. static readonly PositionKind: string;
  5731. /**
  5732. * Normals
  5733. */
  5734. static readonly NormalKind: string;
  5735. /**
  5736. * Tangents
  5737. */
  5738. static readonly TangentKind: string;
  5739. /**
  5740. * Texture coordinates
  5741. */
  5742. static readonly UVKind: string;
  5743. /**
  5744. * Texture coordinates 2
  5745. */
  5746. static readonly UV2Kind: string;
  5747. /**
  5748. * Texture coordinates 3
  5749. */
  5750. static readonly UV3Kind: string;
  5751. /**
  5752. * Texture coordinates 4
  5753. */
  5754. static readonly UV4Kind: string;
  5755. /**
  5756. * Texture coordinates 5
  5757. */
  5758. static readonly UV5Kind: string;
  5759. /**
  5760. * Texture coordinates 6
  5761. */
  5762. static readonly UV6Kind: string;
  5763. /**
  5764. * Colors
  5765. */
  5766. static readonly ColorKind: string;
  5767. /**
  5768. * Matrix indices (for bones)
  5769. */
  5770. static readonly MatricesIndicesKind: string;
  5771. /**
  5772. * Matrix weights (for bones)
  5773. */
  5774. static readonly MatricesWeightsKind: string;
  5775. /**
  5776. * Additional matrix indices (for bones)
  5777. */
  5778. static readonly MatricesIndicesExtraKind: string;
  5779. /**
  5780. * Additional matrix weights (for bones)
  5781. */
  5782. static readonly MatricesWeightsExtraKind: string;
  5783. /**
  5784. * Deduces the stride given a kind.
  5785. * @param kind The kind string to deduce
  5786. * @returns The deduced stride
  5787. */
  5788. static DeduceStride(kind: string): number;
  5789. /**
  5790. * Gets the byte length of the given type.
  5791. * @param type the type
  5792. * @returns the number of bytes
  5793. */
  5794. static GetTypeByteLength(type: number): number;
  5795. /**
  5796. * Enumerates each value of the given parameters as numbers.
  5797. * @param data the data to enumerate
  5798. * @param byteOffset the byte offset of the data
  5799. * @param byteStride the byte stride of the data
  5800. * @param componentCount the number of components per element
  5801. * @param componentType the type of the component
  5802. * @param count the total number of components
  5803. * @param normalized whether the data is normalized
  5804. * @param callback the callback function called for each value
  5805. */
  5806. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5807. private static _GetFloatValue;
  5808. }
  5809. }
  5810. declare module "babylonjs/Maths/sphericalPolynomial" {
  5811. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5812. /**
  5813. * Class representing spherical harmonics coefficients to the 3rd degree
  5814. */
  5815. export class SphericalHarmonics {
  5816. /**
  5817. * Defines whether or not the harmonics have been prescaled for rendering.
  5818. */
  5819. preScaled: boolean;
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. l22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scaleInPlace(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5892. * required operations at run time.
  5893. *
  5894. * This is simply done by scaling back the SH with Ylm constants parameter.
  5895. * The trigonometric part being applied by the shader at run time.
  5896. */
  5897. preScaleForRendering(): void;
  5898. /**
  5899. * Constructs a spherical harmonics from an array.
  5900. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5901. * @returns the spherical harmonics
  5902. */
  5903. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5904. /**
  5905. * Gets the spherical harmonics from polynomial
  5906. * @param polynomial the spherical polynomial
  5907. * @returns the spherical harmonics
  5908. */
  5909. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5910. }
  5911. /**
  5912. * Class representing spherical polynomial coefficients to the 3rd degree
  5913. */
  5914. export class SphericalPolynomial {
  5915. private _harmonics;
  5916. /**
  5917. * The spherical harmonics used to create the polynomials.
  5918. */
  5919. readonly preScaledHarmonics: SphericalHarmonics;
  5920. /**
  5921. * The x coefficients of the spherical polynomial
  5922. */
  5923. x: Vector3;
  5924. /**
  5925. * The y coefficients of the spherical polynomial
  5926. */
  5927. y: Vector3;
  5928. /**
  5929. * The z coefficients of the spherical polynomial
  5930. */
  5931. z: Vector3;
  5932. /**
  5933. * The xx coefficients of the spherical polynomial
  5934. */
  5935. xx: Vector3;
  5936. /**
  5937. * The yy coefficients of the spherical polynomial
  5938. */
  5939. yy: Vector3;
  5940. /**
  5941. * The zz coefficients of the spherical polynomial
  5942. */
  5943. zz: Vector3;
  5944. /**
  5945. * The xy coefficients of the spherical polynomial
  5946. */
  5947. xy: Vector3;
  5948. /**
  5949. * The yz coefficients of the spherical polynomial
  5950. */
  5951. yz: Vector3;
  5952. /**
  5953. * The zx coefficients of the spherical polynomial
  5954. */
  5955. zx: Vector3;
  5956. /**
  5957. * Adds an ambient color to the spherical polynomial
  5958. * @param color the color to add
  5959. */
  5960. addAmbient(color: Color3): void;
  5961. /**
  5962. * Scales the spherical polynomial by the given amount
  5963. * @param scale the amount to scale
  5964. */
  5965. scaleInPlace(scale: number): void;
  5966. /**
  5967. * Gets the spherical polynomial from harmonics
  5968. * @param harmonics the spherical harmonics
  5969. * @returns the spherical polynomial
  5970. */
  5971. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5972. /**
  5973. * Constructs a spherical polynomial from an array.
  5974. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5975. * @returns the spherical polynomial
  5976. */
  5977. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5978. }
  5979. }
  5980. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5981. import { Nullable } from "babylonjs/types";
  5982. /**
  5983. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5984. */
  5985. export interface CubeMapInfo {
  5986. /**
  5987. * The pixel array for the front face.
  5988. * This is stored in format, left to right, up to down format.
  5989. */
  5990. front: Nullable<ArrayBufferView>;
  5991. /**
  5992. * The pixel array for the back face.
  5993. * This is stored in format, left to right, up to down format.
  5994. */
  5995. back: Nullable<ArrayBufferView>;
  5996. /**
  5997. * The pixel array for the left face.
  5998. * This is stored in format, left to right, up to down format.
  5999. */
  6000. left: Nullable<ArrayBufferView>;
  6001. /**
  6002. * The pixel array for the right face.
  6003. * This is stored in format, left to right, up to down format.
  6004. */
  6005. right: Nullable<ArrayBufferView>;
  6006. /**
  6007. * The pixel array for the up face.
  6008. * This is stored in format, left to right, up to down format.
  6009. */
  6010. up: Nullable<ArrayBufferView>;
  6011. /**
  6012. * The pixel array for the down face.
  6013. * This is stored in format, left to right, up to down format.
  6014. */
  6015. down: Nullable<ArrayBufferView>;
  6016. /**
  6017. * The size of the cubemap stored.
  6018. *
  6019. * Each faces will be size * size pixels.
  6020. */
  6021. size: number;
  6022. /**
  6023. * The format of the texture.
  6024. *
  6025. * RGBA, RGB.
  6026. */
  6027. format: number;
  6028. /**
  6029. * The type of the texture data.
  6030. *
  6031. * UNSIGNED_INT, FLOAT.
  6032. */
  6033. type: number;
  6034. /**
  6035. * Specifies whether the texture is in gamma space.
  6036. */
  6037. gammaSpace: boolean;
  6038. }
  6039. /**
  6040. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6041. */
  6042. export class PanoramaToCubeMapTools {
  6043. private static FACE_FRONT;
  6044. private static FACE_BACK;
  6045. private static FACE_RIGHT;
  6046. private static FACE_LEFT;
  6047. private static FACE_DOWN;
  6048. private static FACE_UP;
  6049. /**
  6050. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6051. *
  6052. * @param float32Array The source data.
  6053. * @param inputWidth The width of the input panorama.
  6054. * @param inputHeight The height of the input panorama.
  6055. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6056. * @return The cubemap data
  6057. */
  6058. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6059. private static CreateCubemapTexture;
  6060. private static CalcProjectionSpherical;
  6061. }
  6062. }
  6063. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6064. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6066. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6067. /**
  6068. * Helper class dealing with the extraction of spherical polynomial dataArray
  6069. * from a cube map.
  6070. */
  6071. export class CubeMapToSphericalPolynomialTools {
  6072. private static FileFaces;
  6073. /**
  6074. * Converts a texture to the according Spherical Polynomial data.
  6075. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6076. *
  6077. * @param texture The texture to extract the information from.
  6078. * @return The Spherical Polynomial data.
  6079. */
  6080. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6081. /**
  6082. * Converts a cubemap to the according Spherical Polynomial data.
  6083. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6084. *
  6085. * @param cubeInfo The Cube map to extract the information from.
  6086. * @return The Spherical Polynomial data.
  6087. */
  6088. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6089. }
  6090. }
  6091. declare module "babylonjs/Engines/engineStore" {
  6092. import { Nullable } from "babylonjs/types";
  6093. import { Engine } from "babylonjs/Engines/engine";
  6094. import { Scene } from "babylonjs/scene";
  6095. /**
  6096. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6097. * during the life time of the application.
  6098. */
  6099. export class EngineStore {
  6100. /** Gets the list of created engines */
  6101. static Instances: import("babylonjs/Engines/engine").Engine[];
  6102. /**
  6103. * Gets the latest created engine
  6104. */
  6105. static readonly LastCreatedEngine: Nullable<Engine>;
  6106. /**
  6107. * Gets the latest created scene
  6108. */
  6109. static readonly LastCreatedScene: Nullable<Scene>;
  6110. }
  6111. }
  6112. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6113. /**
  6114. * Define options used to create a render target texture
  6115. */
  6116. export class RenderTargetCreationOptions {
  6117. /**
  6118. * Specifies is mipmaps must be generated
  6119. */
  6120. generateMipMaps?: boolean;
  6121. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6122. generateDepthBuffer?: boolean;
  6123. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6124. generateStencilBuffer?: boolean;
  6125. /** Defines texture type (int by default) */
  6126. type?: number;
  6127. /** Defines sampling mode (trilinear by default) */
  6128. samplingMode?: number;
  6129. /** Defines format (RGBA by default) */
  6130. format?: number;
  6131. }
  6132. }
  6133. declare module "babylonjs/States/alphaCullingState" {
  6134. /**
  6135. * @hidden
  6136. **/
  6137. export class _AlphaState {
  6138. private _isAlphaBlendDirty;
  6139. private _isBlendFunctionParametersDirty;
  6140. private _isBlendEquationParametersDirty;
  6141. private _isBlendConstantsDirty;
  6142. private _alphaBlend;
  6143. private _blendFunctionParameters;
  6144. private _blendEquationParameters;
  6145. private _blendConstants;
  6146. /**
  6147. * Initializes the state.
  6148. */
  6149. constructor();
  6150. readonly isDirty: boolean;
  6151. alphaBlend: boolean;
  6152. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6153. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6154. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6155. reset(): void;
  6156. apply(gl: WebGLRenderingContext): void;
  6157. }
  6158. }
  6159. declare module "babylonjs/States/depthCullingState" {
  6160. import { Nullable } from "babylonjs/types";
  6161. /**
  6162. * @hidden
  6163. **/
  6164. export class _DepthCullingState {
  6165. private _isDepthTestDirty;
  6166. private _isDepthMaskDirty;
  6167. private _isDepthFuncDirty;
  6168. private _isCullFaceDirty;
  6169. private _isCullDirty;
  6170. private _isZOffsetDirty;
  6171. private _isFrontFaceDirty;
  6172. private _depthTest;
  6173. private _depthMask;
  6174. private _depthFunc;
  6175. private _cull;
  6176. private _cullFace;
  6177. private _zOffset;
  6178. private _frontFace;
  6179. /**
  6180. * Initializes the state.
  6181. */
  6182. constructor();
  6183. readonly isDirty: boolean;
  6184. zOffset: number;
  6185. cullFace: Nullable<number>;
  6186. cull: Nullable<boolean>;
  6187. depthFunc: Nullable<number>;
  6188. depthMask: boolean;
  6189. depthTest: boolean;
  6190. frontFace: Nullable<number>;
  6191. reset(): void;
  6192. apply(gl: WebGLRenderingContext): void;
  6193. }
  6194. }
  6195. declare module "babylonjs/States/stencilState" {
  6196. /**
  6197. * @hidden
  6198. **/
  6199. export class _StencilState {
  6200. /** 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 */
  6201. static readonly ALWAYS: number;
  6202. /** Passed to stencilOperation to specify that stencil value must be kept */
  6203. static readonly KEEP: number;
  6204. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6205. static readonly REPLACE: number;
  6206. private _isStencilTestDirty;
  6207. private _isStencilMaskDirty;
  6208. private _isStencilFuncDirty;
  6209. private _isStencilOpDirty;
  6210. private _stencilTest;
  6211. private _stencilMask;
  6212. private _stencilFunc;
  6213. private _stencilFuncRef;
  6214. private _stencilFuncMask;
  6215. private _stencilOpStencilFail;
  6216. private _stencilOpDepthFail;
  6217. private _stencilOpStencilDepthPass;
  6218. readonly isDirty: boolean;
  6219. stencilFunc: number;
  6220. stencilFuncRef: number;
  6221. stencilFuncMask: number;
  6222. stencilOpStencilFail: number;
  6223. stencilOpDepthFail: number;
  6224. stencilOpStencilDepthPass: number;
  6225. stencilMask: number;
  6226. stencilTest: boolean;
  6227. constructor();
  6228. reset(): void;
  6229. apply(gl: WebGLRenderingContext): void;
  6230. }
  6231. }
  6232. declare module "babylonjs/States/index" {
  6233. export * from "babylonjs/States/alphaCullingState";
  6234. export * from "babylonjs/States/depthCullingState";
  6235. export * from "babylonjs/States/stencilState";
  6236. }
  6237. declare module "babylonjs/Instrumentation/timeToken" {
  6238. import { Nullable } from "babylonjs/types";
  6239. /**
  6240. * @hidden
  6241. **/
  6242. export class _TimeToken {
  6243. _startTimeQuery: Nullable<WebGLQuery>;
  6244. _endTimeQuery: Nullable<WebGLQuery>;
  6245. _timeElapsedQuery: Nullable<WebGLQuery>;
  6246. _timeElapsedQueryEnded: boolean;
  6247. }
  6248. }
  6249. declare module "babylonjs/Materials/Textures/internalTexture" {
  6250. import { Observable } from "babylonjs/Misc/observable";
  6251. import { Nullable, int } from "babylonjs/types";
  6252. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6253. import { Engine } from "babylonjs/Engines/engine";
  6254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6255. /**
  6256. * Class used to store data associated with WebGL texture data for the engine
  6257. * This class should not be used directly
  6258. */
  6259. export class InternalTexture {
  6260. /** hidden */
  6261. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6262. /**
  6263. * The source of the texture data is unknown
  6264. */
  6265. static DATASOURCE_UNKNOWN: number;
  6266. /**
  6267. * Texture data comes from an URL
  6268. */
  6269. static DATASOURCE_URL: number;
  6270. /**
  6271. * Texture data is only used for temporary storage
  6272. */
  6273. static DATASOURCE_TEMP: number;
  6274. /**
  6275. * Texture data comes from raw data (ArrayBuffer)
  6276. */
  6277. static DATASOURCE_RAW: number;
  6278. /**
  6279. * Texture content is dynamic (video or dynamic texture)
  6280. */
  6281. static DATASOURCE_DYNAMIC: number;
  6282. /**
  6283. * Texture content is generated by rendering to it
  6284. */
  6285. static DATASOURCE_RENDERTARGET: number;
  6286. /**
  6287. * Texture content is part of a multi render target process
  6288. */
  6289. static DATASOURCE_MULTIRENDERTARGET: number;
  6290. /**
  6291. * Texture data comes from a cube data file
  6292. */
  6293. static DATASOURCE_CUBE: number;
  6294. /**
  6295. * Texture data comes from a raw cube data
  6296. */
  6297. static DATASOURCE_CUBERAW: number;
  6298. /**
  6299. * Texture data come from a prefiltered cube data file
  6300. */
  6301. static DATASOURCE_CUBEPREFILTERED: number;
  6302. /**
  6303. * Texture content is raw 3D data
  6304. */
  6305. static DATASOURCE_RAW3D: number;
  6306. /**
  6307. * Texture content is a depth texture
  6308. */
  6309. static DATASOURCE_DEPTHTEXTURE: number;
  6310. /**
  6311. * Texture data comes from a raw cube data encoded with RGBD
  6312. */
  6313. static DATASOURCE_CUBERAW_RGBD: number;
  6314. /**
  6315. * Defines if the texture is ready
  6316. */
  6317. isReady: boolean;
  6318. /**
  6319. * Defines if the texture is a cube texture
  6320. */
  6321. isCube: boolean;
  6322. /**
  6323. * Defines if the texture contains 3D data
  6324. */
  6325. is3D: boolean;
  6326. /**
  6327. * Defines if the texture contains multiview data
  6328. */
  6329. isMultiview: boolean;
  6330. /**
  6331. * Gets the URL used to load this texture
  6332. */
  6333. url: string;
  6334. /**
  6335. * Gets the sampling mode of the texture
  6336. */
  6337. samplingMode: number;
  6338. /**
  6339. * Gets a boolean indicating if the texture needs mipmaps generation
  6340. */
  6341. generateMipMaps: boolean;
  6342. /**
  6343. * Gets the number of samples used by the texture (WebGL2+ only)
  6344. */
  6345. samples: number;
  6346. /**
  6347. * Gets the type of the texture (int, float...)
  6348. */
  6349. type: number;
  6350. /**
  6351. * Gets the format of the texture (RGB, RGBA...)
  6352. */
  6353. format: number;
  6354. /**
  6355. * Observable called when the texture is loaded
  6356. */
  6357. onLoadedObservable: Observable<InternalTexture>;
  6358. /**
  6359. * Gets the width of the texture
  6360. */
  6361. width: number;
  6362. /**
  6363. * Gets the height of the texture
  6364. */
  6365. height: number;
  6366. /**
  6367. * Gets the depth of the texture
  6368. */
  6369. depth: number;
  6370. /**
  6371. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6372. */
  6373. baseWidth: number;
  6374. /**
  6375. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6376. */
  6377. baseHeight: number;
  6378. /**
  6379. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6380. */
  6381. baseDepth: number;
  6382. /**
  6383. * Gets a boolean indicating if the texture is inverted on Y axis
  6384. */
  6385. invertY: boolean;
  6386. /** @hidden */
  6387. _invertVScale: boolean;
  6388. /** @hidden */
  6389. _associatedChannel: number;
  6390. /** @hidden */
  6391. _dataSource: number;
  6392. /** @hidden */
  6393. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6394. /** @hidden */
  6395. _bufferView: Nullable<ArrayBufferView>;
  6396. /** @hidden */
  6397. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6398. /** @hidden */
  6399. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6400. /** @hidden */
  6401. _size: number;
  6402. /** @hidden */
  6403. _extension: string;
  6404. /** @hidden */
  6405. _files: Nullable<string[]>;
  6406. /** @hidden */
  6407. _workingCanvas: Nullable<HTMLCanvasElement>;
  6408. /** @hidden */
  6409. _workingContext: Nullable<CanvasRenderingContext2D>;
  6410. /** @hidden */
  6411. _framebuffer: Nullable<WebGLFramebuffer>;
  6412. /** @hidden */
  6413. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6414. /** @hidden */
  6415. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6416. /** @hidden */
  6417. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6418. /** @hidden */
  6419. _attachments: Nullable<number[]>;
  6420. /** @hidden */
  6421. _cachedCoordinatesMode: Nullable<number>;
  6422. /** @hidden */
  6423. _cachedWrapU: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedWrapV: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapR: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6430. /** @hidden */
  6431. _isDisabled: boolean;
  6432. /** @hidden */
  6433. _compression: Nullable<string>;
  6434. /** @hidden */
  6435. _generateStencilBuffer: boolean;
  6436. /** @hidden */
  6437. _generateDepthBuffer: boolean;
  6438. /** @hidden */
  6439. _comparisonFunction: number;
  6440. /** @hidden */
  6441. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6442. /** @hidden */
  6443. _lodGenerationScale: number;
  6444. /** @hidden */
  6445. _lodGenerationOffset: number;
  6446. /** @hidden */
  6447. _colorTextureArray: Nullable<WebGLTexture>;
  6448. /** @hidden */
  6449. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6450. /** @hidden */
  6451. _lodTextureHigh: Nullable<BaseTexture>;
  6452. /** @hidden */
  6453. _lodTextureMid: Nullable<BaseTexture>;
  6454. /** @hidden */
  6455. _lodTextureLow: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _isRGBD: boolean;
  6458. /** @hidden */
  6459. _webGLTexture: Nullable<WebGLTexture>;
  6460. /** @hidden */
  6461. _references: number;
  6462. private _engine;
  6463. /**
  6464. * Gets the Engine the texture belongs to.
  6465. * @returns The babylon engine
  6466. */
  6467. getEngine(): Engine;
  6468. /**
  6469. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6470. */
  6471. readonly dataSource: number;
  6472. /**
  6473. * Creates a new InternalTexture
  6474. * @param engine defines the engine to use
  6475. * @param dataSource defines the type of data that will be used
  6476. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6477. */
  6478. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6479. /**
  6480. * Increments the number of references (ie. the number of Texture that point to it)
  6481. */
  6482. incrementReferences(): void;
  6483. /**
  6484. * Change the size of the texture (not the size of the content)
  6485. * @param width defines the new width
  6486. * @param height defines the new height
  6487. * @param depth defines the new depth (1 by default)
  6488. */
  6489. updateSize(width: int, height: int, depth?: int): void;
  6490. /** @hidden */
  6491. _rebuild(): void;
  6492. /** @hidden */
  6493. _swapAndDie(target: InternalTexture): void;
  6494. /**
  6495. * Dispose the current allocated resources
  6496. */
  6497. dispose(): void;
  6498. }
  6499. }
  6500. declare module "babylonjs/Animations/easing" {
  6501. /**
  6502. * This represents the main contract an easing function should follow.
  6503. * Easing functions are used throughout the animation system.
  6504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6505. */
  6506. export interface IEasingFunction {
  6507. /**
  6508. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6509. * of the easing function.
  6510. * The link below provides some of the most common examples of easing functions.
  6511. * @see https://easings.net/
  6512. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6513. * @returns the corresponding value on the curve defined by the easing function
  6514. */
  6515. ease(gradient: number): number;
  6516. }
  6517. /**
  6518. * Base class used for every default easing function.
  6519. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6520. */
  6521. export class EasingFunction implements IEasingFunction {
  6522. /**
  6523. * Interpolation follows the mathematical formula associated with the easing function.
  6524. */
  6525. static readonly EASINGMODE_EASEIN: number;
  6526. /**
  6527. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6528. */
  6529. static readonly EASINGMODE_EASEOUT: number;
  6530. /**
  6531. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6532. */
  6533. static readonly EASINGMODE_EASEINOUT: number;
  6534. private _easingMode;
  6535. /**
  6536. * Sets the easing mode of the current function.
  6537. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6538. */
  6539. setEasingMode(easingMode: number): void;
  6540. /**
  6541. * Gets the current easing mode.
  6542. * @returns the easing mode
  6543. */
  6544. getEasingMode(): number;
  6545. /**
  6546. * @hidden
  6547. */
  6548. easeInCore(gradient: number): number;
  6549. /**
  6550. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6551. * of the easing function.
  6552. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6553. * @returns the corresponding value on the curve defined by the easing function
  6554. */
  6555. ease(gradient: number): number;
  6556. }
  6557. /**
  6558. * Easing function with a circle shape (see link below).
  6559. * @see https://easings.net/#easeInCirc
  6560. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6561. */
  6562. export class CircleEase extends EasingFunction implements IEasingFunction {
  6563. /** @hidden */
  6564. easeInCore(gradient: number): number;
  6565. }
  6566. /**
  6567. * Easing function with a ease back shape (see link below).
  6568. * @see https://easings.net/#easeInBack
  6569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6570. */
  6571. export class BackEase extends EasingFunction implements IEasingFunction {
  6572. /** Defines the amplitude of the function */
  6573. amplitude: number;
  6574. /**
  6575. * Instantiates a back ease easing
  6576. * @see https://easings.net/#easeInBack
  6577. * @param amplitude Defines the amplitude of the function
  6578. */
  6579. constructor(
  6580. /** Defines the amplitude of the function */
  6581. amplitude?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with a bouncing shape (see link below).
  6587. * @see https://easings.net/#easeInBounce
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class BounceEase extends EasingFunction implements IEasingFunction {
  6591. /** Defines the number of bounces */
  6592. bounces: number;
  6593. /** Defines the amplitude of the bounce */
  6594. bounciness: number;
  6595. /**
  6596. * Instantiates a bounce easing
  6597. * @see https://easings.net/#easeInBounce
  6598. * @param bounces Defines the number of bounces
  6599. * @param bounciness Defines the amplitude of the bounce
  6600. */
  6601. constructor(
  6602. /** Defines the number of bounces */
  6603. bounces?: number,
  6604. /** Defines the amplitude of the bounce */
  6605. bounciness?: number);
  6606. /** @hidden */
  6607. easeInCore(gradient: number): number;
  6608. }
  6609. /**
  6610. * Easing function with a power of 3 shape (see link below).
  6611. * @see https://easings.net/#easeInCubic
  6612. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6613. */
  6614. export class CubicEase extends EasingFunction implements IEasingFunction {
  6615. /** @hidden */
  6616. easeInCore(gradient: number): number;
  6617. }
  6618. /**
  6619. * Easing function with an elastic shape (see link below).
  6620. * @see https://easings.net/#easeInElastic
  6621. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6622. */
  6623. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6624. /** Defines the number of oscillations*/
  6625. oscillations: number;
  6626. /** Defines the amplitude of the oscillations*/
  6627. springiness: number;
  6628. /**
  6629. * Instantiates an elastic easing function
  6630. * @see https://easings.net/#easeInElastic
  6631. * @param oscillations Defines the number of oscillations
  6632. * @param springiness Defines the amplitude of the oscillations
  6633. */
  6634. constructor(
  6635. /** Defines the number of oscillations*/
  6636. oscillations?: number,
  6637. /** Defines the amplitude of the oscillations*/
  6638. springiness?: number);
  6639. /** @hidden */
  6640. easeInCore(gradient: number): number;
  6641. }
  6642. /**
  6643. * Easing function with an exponential shape (see link below).
  6644. * @see https://easings.net/#easeInExpo
  6645. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6646. */
  6647. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6648. /** Defines the exponent of the function */
  6649. exponent: number;
  6650. /**
  6651. * Instantiates an exponential easing function
  6652. * @see https://easings.net/#easeInExpo
  6653. * @param exponent Defines the exponent of the function
  6654. */
  6655. constructor(
  6656. /** Defines the exponent of the function */
  6657. exponent?: number);
  6658. /** @hidden */
  6659. easeInCore(gradient: number): number;
  6660. }
  6661. /**
  6662. * Easing function with a power shape (see link below).
  6663. * @see https://easings.net/#easeInQuad
  6664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6665. */
  6666. export class PowerEase extends EasingFunction implements IEasingFunction {
  6667. /** Defines the power of the function */
  6668. power: number;
  6669. /**
  6670. * Instantiates an power base easing function
  6671. * @see https://easings.net/#easeInQuad
  6672. * @param power Defines the power of the function
  6673. */
  6674. constructor(
  6675. /** Defines the power of the function */
  6676. power?: number);
  6677. /** @hidden */
  6678. easeInCore(gradient: number): number;
  6679. }
  6680. /**
  6681. * Easing function with a power of 2 shape (see link below).
  6682. * @see https://easings.net/#easeInQuad
  6683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6684. */
  6685. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6686. /** @hidden */
  6687. easeInCore(gradient: number): number;
  6688. }
  6689. /**
  6690. * Easing function with a power of 4 shape (see link below).
  6691. * @see https://easings.net/#easeInQuart
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6695. /** @hidden */
  6696. easeInCore(gradient: number): number;
  6697. }
  6698. /**
  6699. * Easing function with a power of 5 shape (see link below).
  6700. * @see https://easings.net/#easeInQuint
  6701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6702. */
  6703. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6704. /** @hidden */
  6705. easeInCore(gradient: number): number;
  6706. }
  6707. /**
  6708. * Easing function with a sin shape (see link below).
  6709. * @see https://easings.net/#easeInSine
  6710. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6711. */
  6712. export class SineEase extends EasingFunction implements IEasingFunction {
  6713. /** @hidden */
  6714. easeInCore(gradient: number): number;
  6715. }
  6716. /**
  6717. * Easing function with a bezier shape (see link below).
  6718. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6720. */
  6721. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6722. /** Defines the x component of the start tangent in the bezier curve */
  6723. x1: number;
  6724. /** Defines the y component of the start tangent in the bezier curve */
  6725. y1: number;
  6726. /** Defines the x component of the end tangent in the bezier curve */
  6727. x2: number;
  6728. /** Defines the y component of the end tangent in the bezier curve */
  6729. y2: number;
  6730. /**
  6731. * Instantiates a bezier function
  6732. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6733. * @param x1 Defines the x component of the start tangent in the bezier curve
  6734. * @param y1 Defines the y component of the start tangent in the bezier curve
  6735. * @param x2 Defines the x component of the end tangent in the bezier curve
  6736. * @param y2 Defines the y component of the end tangent in the bezier curve
  6737. */
  6738. constructor(
  6739. /** Defines the x component of the start tangent in the bezier curve */
  6740. x1?: number,
  6741. /** Defines the y component of the start tangent in the bezier curve */
  6742. y1?: number,
  6743. /** Defines the x component of the end tangent in the bezier curve */
  6744. x2?: number,
  6745. /** Defines the y component of the end tangent in the bezier curve */
  6746. y2?: number);
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. }
  6751. declare module "babylonjs/Animations/animationKey" {
  6752. /**
  6753. * Defines an interface which represents an animation key frame
  6754. */
  6755. export interface IAnimationKey {
  6756. /**
  6757. * Frame of the key frame
  6758. */
  6759. frame: number;
  6760. /**
  6761. * Value at the specifies key frame
  6762. */
  6763. value: any;
  6764. /**
  6765. * The input tangent for the cubic hermite spline
  6766. */
  6767. inTangent?: any;
  6768. /**
  6769. * The output tangent for the cubic hermite spline
  6770. */
  6771. outTangent?: any;
  6772. /**
  6773. * The animation interpolation type
  6774. */
  6775. interpolation?: AnimationKeyInterpolation;
  6776. }
  6777. /**
  6778. * Enum for the animation key frame interpolation type
  6779. */
  6780. export enum AnimationKeyInterpolation {
  6781. /**
  6782. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6783. */
  6784. STEP = 1
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationRange" {
  6788. /**
  6789. * Represents the range of an animation
  6790. */
  6791. export class AnimationRange {
  6792. /**The name of the animation range**/
  6793. name: string;
  6794. /**The starting frame of the animation */
  6795. from: number;
  6796. /**The ending frame of the animation*/
  6797. to: number;
  6798. /**
  6799. * Initializes the range of an animation
  6800. * @param name The name of the animation range
  6801. * @param from The starting frame of the animation
  6802. * @param to The ending frame of the animation
  6803. */
  6804. constructor(
  6805. /**The name of the animation range**/
  6806. name: string,
  6807. /**The starting frame of the animation */
  6808. from: number,
  6809. /**The ending frame of the animation*/
  6810. to: number);
  6811. /**
  6812. * Makes a copy of the animation range
  6813. * @returns A copy of the animation range
  6814. */
  6815. clone(): AnimationRange;
  6816. }
  6817. }
  6818. declare module "babylonjs/Animations/animationEvent" {
  6819. /**
  6820. * Composed of a frame, and an action function
  6821. */
  6822. export class AnimationEvent {
  6823. /** The frame for which the event is triggered **/
  6824. frame: number;
  6825. /** The event to perform when triggered **/
  6826. action: (currentFrame: number) => void;
  6827. /** Specifies if the event should be triggered only once**/
  6828. onlyOnce?: boolean | undefined;
  6829. /**
  6830. * Specifies if the animation event is done
  6831. */
  6832. isDone: boolean;
  6833. /**
  6834. * Initializes the animation event
  6835. * @param frame The frame for which the event is triggered
  6836. * @param action The event to perform when triggered
  6837. * @param onlyOnce Specifies if the event should be triggered only once
  6838. */
  6839. constructor(
  6840. /** The frame for which the event is triggered **/
  6841. frame: number,
  6842. /** The event to perform when triggered **/
  6843. action: (currentFrame: number) => void,
  6844. /** Specifies if the event should be triggered only once**/
  6845. onlyOnce?: boolean | undefined);
  6846. /** @hidden */
  6847. _clone(): AnimationEvent;
  6848. }
  6849. }
  6850. declare module "babylonjs/Behaviors/behavior" {
  6851. import { Nullable } from "babylonjs/types";
  6852. /**
  6853. * Interface used to define a behavior
  6854. */
  6855. export interface Behavior<T> {
  6856. /** gets or sets behavior's name */
  6857. name: string;
  6858. /**
  6859. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6860. */
  6861. init(): void;
  6862. /**
  6863. * Called when the behavior is attached to a target
  6864. * @param target defines the target where the behavior is attached to
  6865. */
  6866. attach(target: T): void;
  6867. /**
  6868. * Called when the behavior is detached from its target
  6869. */
  6870. detach(): void;
  6871. }
  6872. /**
  6873. * Interface implemented by classes supporting behaviors
  6874. */
  6875. export interface IBehaviorAware<T> {
  6876. /**
  6877. * Attach a behavior
  6878. * @param behavior defines the behavior to attach
  6879. * @returns the current host
  6880. */
  6881. addBehavior(behavior: Behavior<T>): T;
  6882. /**
  6883. * Remove a behavior from the current object
  6884. * @param behavior defines the behavior to detach
  6885. * @returns the current host
  6886. */
  6887. removeBehavior(behavior: Behavior<T>): T;
  6888. /**
  6889. * Gets a behavior using its name to search
  6890. * @param name defines the name to search
  6891. * @returns the behavior or null if not found
  6892. */
  6893. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6894. }
  6895. }
  6896. declare module "babylonjs/Collisions/intersectionInfo" {
  6897. import { Nullable } from "babylonjs/types";
  6898. /**
  6899. * @hidden
  6900. */
  6901. export class IntersectionInfo {
  6902. bu: Nullable<number>;
  6903. bv: Nullable<number>;
  6904. distance: number;
  6905. faceId: number;
  6906. subMeshId: number;
  6907. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6908. }
  6909. }
  6910. declare module "babylonjs/Culling/boundingSphere" {
  6911. import { DeepImmutable } from "babylonjs/types";
  6912. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6913. /**
  6914. * Class used to store bounding sphere information
  6915. */
  6916. export class BoundingSphere {
  6917. /**
  6918. * Gets the center of the bounding sphere in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Radius of the bounding sphere in local space
  6923. */
  6924. radius: number;
  6925. /**
  6926. * Gets the center of the bounding sphere in world space
  6927. */
  6928. readonly centerWorld: Vector3;
  6929. /**
  6930. * Radius of the bounding sphere in world space
  6931. */
  6932. radiusWorld: number;
  6933. /**
  6934. * Gets the minimum vector in local space
  6935. */
  6936. readonly minimum: Vector3;
  6937. /**
  6938. * Gets the maximum vector in local space
  6939. */
  6940. readonly maximum: Vector3;
  6941. private _worldMatrix;
  6942. private static readonly TmpVector3;
  6943. /**
  6944. * Creates a new bounding sphere
  6945. * @param min defines the minimum vector (in local space)
  6946. * @param max defines the maximum vector (in local space)
  6947. * @param worldMatrix defines the new world matrix
  6948. */
  6949. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6950. /**
  6951. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6952. * @param min defines the new minimum vector (in local space)
  6953. * @param max defines the new maximum vector (in local space)
  6954. * @param worldMatrix defines the new world matrix
  6955. */
  6956. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6957. /**
  6958. * Scale the current bounding sphere by applying a scale factor
  6959. * @param factor defines the scale factor to apply
  6960. * @returns the current bounding box
  6961. */
  6962. scale(factor: number): BoundingSphere;
  6963. /**
  6964. * Gets the world matrix of the bounding box
  6965. * @returns a matrix
  6966. */
  6967. getWorldMatrix(): DeepImmutable<Matrix>;
  6968. /** @hidden */
  6969. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Tests if the bounding sphere is intersecting the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an intersection
  6974. */
  6975. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if the bounding sphere center is in between the frustum planes.
  6978. * Used for optimistic fast inclusion.
  6979. * @param frustumPlanes defines the frustum planes to test
  6980. * @returns true if the sphere center is in between the frustum planes
  6981. */
  6982. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6983. /**
  6984. * Tests if a point is inside the bounding sphere
  6985. * @param point defines the point to test
  6986. * @returns true if the point is inside the bounding sphere
  6987. */
  6988. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6989. /**
  6990. * Checks if two sphere intersct
  6991. * @param sphere0 sphere 0
  6992. * @param sphere1 sphere 1
  6993. * @returns true if the speres intersect
  6994. */
  6995. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6996. }
  6997. }
  6998. declare module "babylonjs/Culling/boundingBox" {
  6999. import { DeepImmutable } from "babylonjs/types";
  7000. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7001. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7002. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7003. /**
  7004. * Class used to store bounding box information
  7005. */
  7006. export class BoundingBox implements ICullable {
  7007. /**
  7008. * Gets the 8 vectors representing the bounding box in local space
  7009. */
  7010. readonly vectors: Vector3[];
  7011. /**
  7012. * Gets the center of the bounding box in local space
  7013. */
  7014. readonly center: Vector3;
  7015. /**
  7016. * Gets the center of the bounding box in world space
  7017. */
  7018. readonly centerWorld: Vector3;
  7019. /**
  7020. * Gets the extend size in local space
  7021. */
  7022. readonly extendSize: Vector3;
  7023. /**
  7024. * Gets the extend size in world space
  7025. */
  7026. readonly extendSizeWorld: Vector3;
  7027. /**
  7028. * Gets the OBB (object bounding box) directions
  7029. */
  7030. readonly directions: Vector3[];
  7031. /**
  7032. * Gets the 8 vectors representing the bounding box in world space
  7033. */
  7034. readonly vectorsWorld: Vector3[];
  7035. /**
  7036. * Gets the minimum vector in world space
  7037. */
  7038. readonly minimumWorld: Vector3;
  7039. /**
  7040. * Gets the maximum vector in world space
  7041. */
  7042. readonly maximumWorld: Vector3;
  7043. /**
  7044. * Gets the minimum vector in local space
  7045. */
  7046. readonly minimum: Vector3;
  7047. /**
  7048. * Gets the maximum vector in local space
  7049. */
  7050. readonly maximum: Vector3;
  7051. private _worldMatrix;
  7052. private static readonly TmpVector3;
  7053. /**
  7054. * @hidden
  7055. */
  7056. _tag: number;
  7057. /**
  7058. * Creates a new bounding box
  7059. * @param min defines the minimum vector (in local space)
  7060. * @param max defines the maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7064. /**
  7065. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7066. * @param min defines the new minimum vector (in local space)
  7067. * @param max defines the new maximum vector (in local space)
  7068. * @param worldMatrix defines the new world matrix
  7069. */
  7070. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7071. /**
  7072. * Scale the current bounding box by applying a scale factor
  7073. * @param factor defines the scale factor to apply
  7074. * @returns the current bounding box
  7075. */
  7076. scale(factor: number): BoundingBox;
  7077. /**
  7078. * Gets the world matrix of the bounding box
  7079. * @returns a matrix
  7080. */
  7081. getWorldMatrix(): DeepImmutable<Matrix>;
  7082. /** @hidden */
  7083. _update(world: DeepImmutable<Matrix>): void;
  7084. /**
  7085. * Tests if the bounding box is intersecting the frustum planes
  7086. * @param frustumPlanes defines the frustum planes to test
  7087. * @returns true if there is an intersection
  7088. */
  7089. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7090. /**
  7091. * Tests if the bounding box is entirely inside the frustum planes
  7092. * @param frustumPlanes defines the frustum planes to test
  7093. * @returns true if there is an inclusion
  7094. */
  7095. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7096. /**
  7097. * Tests if a point is inside the bounding box
  7098. * @param point defines the point to test
  7099. * @returns true if the point is inside the bounding box
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Tests if the bounding box intersects with a bounding sphere
  7104. * @param sphere defines the sphere to test
  7105. * @returns true if there is an intersection
  7106. */
  7107. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7108. /**
  7109. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7110. * @param min defines the min vector to use
  7111. * @param max defines the max vector to use
  7112. * @returns true if there is an intersection
  7113. */
  7114. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7115. /**
  7116. * Tests if two bounding boxes are intersections
  7117. * @param box0 defines the first box to test
  7118. * @param box1 defines the second box to test
  7119. * @returns true if there is an intersection
  7120. */
  7121. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7122. /**
  7123. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7124. * @param minPoint defines the minimum vector of the bounding box
  7125. * @param maxPoint defines the maximum vector of the bounding box
  7126. * @param sphereCenter defines the sphere center
  7127. * @param sphereRadius defines the sphere radius
  7128. * @returns true if there is an intersection
  7129. */
  7130. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7131. /**
  7132. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7133. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7134. * @param frustumPlanes defines the frustum planes to test
  7135. * @return true if there is an inclusion
  7136. */
  7137. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7138. /**
  7139. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7140. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @return true if there is an intersection
  7143. */
  7144. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7145. }
  7146. }
  7147. declare module "babylonjs/Collisions/collider" {
  7148. import { Nullable, IndicesArray } from "babylonjs/types";
  7149. import { Vector3, Plane } from "babylonjs/Maths/math";
  7150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7151. /** @hidden */
  7152. export class Collider {
  7153. /** Define if a collision was found */
  7154. collisionFound: boolean;
  7155. /**
  7156. * Define last intersection point in local space
  7157. */
  7158. intersectionPoint: Vector3;
  7159. /**
  7160. * Define last collided mesh
  7161. */
  7162. collidedMesh: Nullable<AbstractMesh>;
  7163. private _collisionPoint;
  7164. private _planeIntersectionPoint;
  7165. private _tempVector;
  7166. private _tempVector2;
  7167. private _tempVector3;
  7168. private _tempVector4;
  7169. private _edge;
  7170. private _baseToVertex;
  7171. private _destinationPoint;
  7172. private _slidePlaneNormal;
  7173. private _displacementVector;
  7174. /** @hidden */
  7175. _radius: Vector3;
  7176. /** @hidden */
  7177. _retry: number;
  7178. private _velocity;
  7179. private _basePoint;
  7180. private _epsilon;
  7181. /** @hidden */
  7182. _velocityWorldLength: number;
  7183. /** @hidden */
  7184. _basePointWorld: Vector3;
  7185. private _velocityWorld;
  7186. private _normalizedVelocity;
  7187. /** @hidden */
  7188. _initialVelocity: Vector3;
  7189. /** @hidden */
  7190. _initialPosition: Vector3;
  7191. private _nearestDistance;
  7192. private _collisionMask;
  7193. collisionMask: number;
  7194. /**
  7195. * Gets the plane normal used to compute the sliding response (in local space)
  7196. */
  7197. readonly slidePlaneNormal: Vector3;
  7198. /** @hidden */
  7199. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7200. /** @hidden */
  7201. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7202. /** @hidden */
  7203. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7204. /** @hidden */
  7205. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7206. /** @hidden */
  7207. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7208. /** @hidden */
  7209. _getResponse(pos: Vector3, vel: Vector3): void;
  7210. }
  7211. }
  7212. declare module "babylonjs/Culling/boundingInfo" {
  7213. import { DeepImmutable } from "babylonjs/types";
  7214. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7215. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7216. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7217. import { Collider } from "babylonjs/Collisions/collider";
  7218. /**
  7219. * Interface for cullable objects
  7220. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7221. */
  7222. export interface ICullable {
  7223. /**
  7224. * Checks if the object or part of the object is in the frustum
  7225. * @param frustumPlanes Camera near/planes
  7226. * @returns true if the object is in frustum otherwise false
  7227. */
  7228. isInFrustum(frustumPlanes: Plane[]): boolean;
  7229. /**
  7230. * Checks if a cullable object (mesh...) is in the camera frustum
  7231. * Unlike isInFrustum this cheks the full bounding box
  7232. * @param frustumPlanes Camera near/planes
  7233. * @returns true if the object is in frustum otherwise false
  7234. */
  7235. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7236. }
  7237. /**
  7238. * Info for a bounding data of a mesh
  7239. */
  7240. export class BoundingInfo implements ICullable {
  7241. /**
  7242. * Bounding box for the mesh
  7243. */
  7244. readonly boundingBox: BoundingBox;
  7245. /**
  7246. * Bounding sphere for the mesh
  7247. */
  7248. readonly boundingSphere: BoundingSphere;
  7249. private _isLocked;
  7250. private static readonly TmpVector3;
  7251. /**
  7252. * Constructs bounding info
  7253. * @param minimum min vector of the bounding box/sphere
  7254. * @param maximum max vector of the bounding box/sphere
  7255. * @param worldMatrix defines the new world matrix
  7256. */
  7257. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7258. /**
  7259. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7260. * @param min defines the new minimum vector (in local space)
  7261. * @param max defines the new maximum vector (in local space)
  7262. * @param worldMatrix defines the new world matrix
  7263. */
  7264. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7265. /**
  7266. * min vector of the bounding box/sphere
  7267. */
  7268. readonly minimum: Vector3;
  7269. /**
  7270. * max vector of the bounding box/sphere
  7271. */
  7272. readonly maximum: Vector3;
  7273. /**
  7274. * If the info is locked and won't be updated to avoid perf overhead
  7275. */
  7276. isLocked: boolean;
  7277. /**
  7278. * Updates the bounding sphere and box
  7279. * @param world world matrix to be used to update
  7280. */
  7281. update(world: DeepImmutable<Matrix>): void;
  7282. /**
  7283. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7284. * @param center New center of the bounding info
  7285. * @param extend New extend of the bounding info
  7286. * @returns the current bounding info
  7287. */
  7288. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7289. /**
  7290. * Scale the current bounding info by applying a scale factor
  7291. * @param factor defines the scale factor to apply
  7292. * @returns the current bounding info
  7293. */
  7294. scale(factor: number): BoundingInfo;
  7295. /**
  7296. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7297. * @param frustumPlanes defines the frustum to test
  7298. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7299. * @returns true if the bounding info is in the frustum planes
  7300. */
  7301. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7302. /**
  7303. * Gets the world distance between the min and max points of the bounding box
  7304. */
  7305. readonly diagonalLength: number;
  7306. /**
  7307. * Checks if a cullable object (mesh...) is in the camera frustum
  7308. * Unlike isInFrustum this cheks the full bounding box
  7309. * @param frustumPlanes Camera near/planes
  7310. * @returns true if the object is in frustum otherwise false
  7311. */
  7312. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7313. /** @hidden */
  7314. _checkCollision(collider: Collider): boolean;
  7315. /**
  7316. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7317. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7318. * @param point the point to check intersection with
  7319. * @returns if the point intersects
  7320. */
  7321. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7322. /**
  7323. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7324. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7325. * @param boundingInfo the bounding info to check intersection with
  7326. * @param precise if the intersection should be done using OBB
  7327. * @returns if the bounding info intersects
  7328. */
  7329. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7330. }
  7331. }
  7332. declare module "babylonjs/Misc/smartArray" {
  7333. /**
  7334. * Defines an array and its length.
  7335. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7336. */
  7337. export interface ISmartArrayLike<T> {
  7338. /**
  7339. * The data of the array.
  7340. */
  7341. data: Array<T>;
  7342. /**
  7343. * The active length of the array.
  7344. */
  7345. length: number;
  7346. }
  7347. /**
  7348. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7349. */
  7350. export class SmartArray<T> implements ISmartArrayLike<T> {
  7351. /**
  7352. * The full set of data from the array.
  7353. */
  7354. data: Array<T>;
  7355. /**
  7356. * The active length of the array.
  7357. */
  7358. length: number;
  7359. protected _id: number;
  7360. /**
  7361. * Instantiates a Smart Array.
  7362. * @param capacity defines the default capacity of the array.
  7363. */
  7364. constructor(capacity: number);
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * @param value defines the object to push in the array.
  7368. */
  7369. push(value: T): void;
  7370. /**
  7371. * Iterates over the active data and apply the lambda to them.
  7372. * @param func defines the action to apply on each value.
  7373. */
  7374. forEach(func: (content: T) => void): void;
  7375. /**
  7376. * Sorts the full sets of data.
  7377. * @param compareFn defines the comparison function to apply.
  7378. */
  7379. sort(compareFn: (a: T, b: T) => number): void;
  7380. /**
  7381. * Resets the active data to an empty array.
  7382. */
  7383. reset(): void;
  7384. /**
  7385. * Releases all the data from the array as well as the array.
  7386. */
  7387. dispose(): void;
  7388. /**
  7389. * Concats the active data with a given array.
  7390. * @param array defines the data to concatenate with.
  7391. */
  7392. concat(array: any): void;
  7393. /**
  7394. * Returns the position of a value in the active data.
  7395. * @param value defines the value to find the index for
  7396. * @returns the index if found in the active data otherwise -1
  7397. */
  7398. indexOf(value: T): number;
  7399. /**
  7400. * Returns whether an element is part of the active data.
  7401. * @param value defines the value to look for
  7402. * @returns true if found in the active data otherwise false
  7403. */
  7404. contains(value: T): boolean;
  7405. private static _GlobalId;
  7406. }
  7407. /**
  7408. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7409. * The data in this array can only be present once
  7410. */
  7411. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7412. private _duplicateId;
  7413. /**
  7414. * Pushes a value at the end of the active data.
  7415. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7416. * @param value defines the object to push in the array.
  7417. */
  7418. push(value: T): void;
  7419. /**
  7420. * Pushes a value at the end of the active data.
  7421. * If the data is already present, it won t be added again
  7422. * @param value defines the object to push in the array.
  7423. * @returns true if added false if it was already present
  7424. */
  7425. pushNoDuplicate(value: T): boolean;
  7426. /**
  7427. * Resets the active data to an empty array.
  7428. */
  7429. reset(): void;
  7430. /**
  7431. * Concats the active data with a given array.
  7432. * This ensures no dupplicate will be present in the result.
  7433. * @param array defines the data to concatenate with.
  7434. */
  7435. concatWithNoDuplicate(array: any): void;
  7436. }
  7437. }
  7438. declare module "babylonjs/Materials/multiMaterial" {
  7439. import { Nullable } from "babylonjs/types";
  7440. import { Scene } from "babylonjs/scene";
  7441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7442. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7444. import { Material } from "babylonjs/Materials/material";
  7445. /**
  7446. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7447. * separate meshes. This can be use to improve performances.
  7448. * @see http://doc.babylonjs.com/how_to/multi_materials
  7449. */
  7450. export class MultiMaterial extends Material {
  7451. private _subMaterials;
  7452. /**
  7453. * Gets or Sets the list of Materials used within the multi material.
  7454. * They need to be ordered according to the submeshes order in the associated mesh
  7455. */
  7456. subMaterials: Nullable<Material>[];
  7457. /**
  7458. * Function used to align with Node.getChildren()
  7459. * @returns the list of Materials used within the multi material
  7460. */
  7461. getChildren(): Nullable<Material>[];
  7462. /**
  7463. * Instantiates a new Multi Material
  7464. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7465. * separate meshes. This can be use to improve performances.
  7466. * @see http://doc.babylonjs.com/how_to/multi_materials
  7467. * @param name Define the name in the scene
  7468. * @param scene Define the scene the material belongs to
  7469. */
  7470. constructor(name: string, scene: Scene);
  7471. private _hookArray;
  7472. /**
  7473. * Get one of the submaterial by its index in the submaterials array
  7474. * @param index The index to look the sub material at
  7475. * @returns The Material if the index has been defined
  7476. */
  7477. getSubMaterial(index: number): Nullable<Material>;
  7478. /**
  7479. * Get the list of active textures for the whole sub materials list.
  7480. * @returns All the textures that will be used during the rendering
  7481. */
  7482. getActiveTextures(): BaseTexture[];
  7483. /**
  7484. * Gets the current class name of the material e.g. "MultiMaterial"
  7485. * Mainly use in serialization.
  7486. * @returns the class name
  7487. */
  7488. getClassName(): string;
  7489. /**
  7490. * Checks if the material is ready to render the requested sub mesh
  7491. * @param mesh Define the mesh the submesh belongs to
  7492. * @param subMesh Define the sub mesh to look readyness for
  7493. * @param useInstances Define whether or not the material is used with instances
  7494. * @returns true if ready, otherwise false
  7495. */
  7496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7497. /**
  7498. * Clones the current material and its related sub materials
  7499. * @param name Define the name of the newly cloned material
  7500. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7501. * @returns the cloned material
  7502. */
  7503. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7504. /**
  7505. * Serializes the materials into a JSON representation.
  7506. * @returns the JSON representation
  7507. */
  7508. serialize(): any;
  7509. /**
  7510. * Dispose the material and release its associated resources
  7511. * @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)
  7512. * @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)
  7513. * @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)
  7514. */
  7515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7516. /**
  7517. * Creates a MultiMaterial from parsed MultiMaterial data.
  7518. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7519. * @param scene defines the hosting scene
  7520. * @returns a new MultiMaterial
  7521. */
  7522. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7523. }
  7524. }
  7525. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7526. /**
  7527. * Class used to represent data loading progression
  7528. */
  7529. export class SceneLoaderFlags {
  7530. private static _ForceFullSceneLoadingForIncremental;
  7531. private static _ShowLoadingScreen;
  7532. private static _CleanBoneMatrixWeights;
  7533. private static _loggingLevel;
  7534. /**
  7535. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7536. */
  7537. static ForceFullSceneLoadingForIncremental: boolean;
  7538. /**
  7539. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7540. */
  7541. static ShowLoadingScreen: boolean;
  7542. /**
  7543. * Defines the current logging level (while loading the scene)
  7544. * @ignorenaming
  7545. */
  7546. static loggingLevel: number;
  7547. /**
  7548. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7549. */
  7550. static CleanBoneMatrixWeights: boolean;
  7551. }
  7552. }
  7553. declare module "babylonjs/Meshes/transformNode" {
  7554. import { DeepImmutable } from "babylonjs/types";
  7555. import { Observable } from "babylonjs/Misc/observable";
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Camera } from "babylonjs/Cameras/camera";
  7558. import { Scene } from "babylonjs/scene";
  7559. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7560. import { Node } from "babylonjs/node";
  7561. import { Bone } from "babylonjs/Bones/bone";
  7562. /**
  7563. * 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.
  7564. * @see https://doc.babylonjs.com/how_to/transformnode
  7565. */
  7566. export class TransformNode extends Node {
  7567. /**
  7568. * Object will not rotate to face the camera
  7569. */
  7570. static BILLBOARDMODE_NONE: number;
  7571. /**
  7572. * Object will rotate to face the camera but only on the x axis
  7573. */
  7574. static BILLBOARDMODE_X: number;
  7575. /**
  7576. * Object will rotate to face the camera but only on the y axis
  7577. */
  7578. static BILLBOARDMODE_Y: number;
  7579. /**
  7580. * Object will rotate to face the camera but only on the z axis
  7581. */
  7582. static BILLBOARDMODE_Z: number;
  7583. /**
  7584. * Object will rotate to face the camera
  7585. */
  7586. static BILLBOARDMODE_ALL: number;
  7587. private _forward;
  7588. private _forwardInverted;
  7589. private _up;
  7590. private _right;
  7591. private _rightInverted;
  7592. private _position;
  7593. private _rotation;
  7594. private _rotationQuaternion;
  7595. protected _scaling: Vector3;
  7596. protected _isDirty: boolean;
  7597. private _transformToBoneReferal;
  7598. private _billboardMode;
  7599. /**
  7600. * Gets or sets the billboard mode. Default is 0.
  7601. *
  7602. * | Value | Type | Description |
  7603. * | --- | --- | --- |
  7604. * | 0 | BILLBOARDMODE_NONE | |
  7605. * | 1 | BILLBOARDMODE_X | |
  7606. * | 2 | BILLBOARDMODE_Y | |
  7607. * | 4 | BILLBOARDMODE_Z | |
  7608. * | 7 | BILLBOARDMODE_ALL | |
  7609. *
  7610. */
  7611. billboardMode: number;
  7612. private _preserveParentRotationForBillboard;
  7613. /**
  7614. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7615. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7616. */
  7617. preserveParentRotationForBillboard: boolean;
  7618. /**
  7619. * 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
  7620. */
  7621. scalingDeterminant: number;
  7622. private _infiniteDistance;
  7623. /**
  7624. * Gets or sets the distance of the object to max, often used by skybox
  7625. */
  7626. infiniteDistance: boolean;
  7627. /**
  7628. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7629. * By default the system will update normals to compensate
  7630. */
  7631. ignoreNonUniformScaling: boolean;
  7632. /**
  7633. * 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
  7634. */
  7635. reIntegrateRotationIntoRotationQuaternion: boolean;
  7636. /** @hidden */
  7637. _poseMatrix: Nullable<Matrix>;
  7638. /** @hidden */
  7639. _localMatrix: Matrix;
  7640. private _usePivotMatrix;
  7641. private _absolutePosition;
  7642. private _pivotMatrix;
  7643. private _pivotMatrixInverse;
  7644. protected _postMultiplyPivotMatrix: boolean;
  7645. protected _isWorldMatrixFrozen: boolean;
  7646. /** @hidden */
  7647. _indexInSceneTransformNodesArray: number;
  7648. /**
  7649. * An event triggered after the world matrix is updated
  7650. */
  7651. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7652. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7653. /**
  7654. * Gets a string identifying the name of the class
  7655. * @returns "TransformNode" string
  7656. */
  7657. getClassName(): string;
  7658. /**
  7659. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7660. */
  7661. position: Vector3;
  7662. /**
  7663. * 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)).
  7664. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7665. */
  7666. rotation: Vector3;
  7667. /**
  7668. * 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)).
  7669. */
  7670. scaling: Vector3;
  7671. /**
  7672. * 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).
  7673. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7674. */
  7675. rotationQuaternion: Nullable<Quaternion>;
  7676. /**
  7677. * The forward direction of that transform in world space.
  7678. */
  7679. readonly forward: Vector3;
  7680. /**
  7681. * The up direction of that transform in world space.
  7682. */
  7683. readonly up: Vector3;
  7684. /**
  7685. * The right direction of that transform in world space.
  7686. */
  7687. readonly right: Vector3;
  7688. /**
  7689. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7690. * @param matrix the matrix to copy the pose from
  7691. * @returns this TransformNode.
  7692. */
  7693. updatePoseMatrix(matrix: Matrix): TransformNode;
  7694. /**
  7695. * Returns the mesh Pose matrix.
  7696. * @returns the pose matrix
  7697. */
  7698. getPoseMatrix(): Matrix;
  7699. /** @hidden */
  7700. _isSynchronized(): boolean;
  7701. /** @hidden */
  7702. _initCache(): void;
  7703. /**
  7704. * Flag the transform node as dirty (Forcing it to update everything)
  7705. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7706. * @returns this transform node
  7707. */
  7708. markAsDirty(property: string): TransformNode;
  7709. /**
  7710. * Returns the current mesh absolute position.
  7711. * Returns a Vector3.
  7712. */
  7713. readonly absolutePosition: Vector3;
  7714. /**
  7715. * Sets a new matrix to apply before all other transformation
  7716. * @param matrix defines the transform matrix
  7717. * @returns the current TransformNode
  7718. */
  7719. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7720. /**
  7721. * Sets a new pivot matrix to the current node
  7722. * @param matrix defines the new pivot matrix to use
  7723. * @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
  7724. * @returns the current TransformNode
  7725. */
  7726. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7727. /**
  7728. * Returns the mesh pivot matrix.
  7729. * Default : Identity.
  7730. * @returns the matrix
  7731. */
  7732. getPivotMatrix(): Matrix;
  7733. /**
  7734. * Prevents the World matrix to be computed any longer.
  7735. * @returns the TransformNode.
  7736. */
  7737. freezeWorldMatrix(): TransformNode;
  7738. /**
  7739. * Allows back the World matrix computation.
  7740. * @returns the TransformNode.
  7741. */
  7742. unfreezeWorldMatrix(): this;
  7743. /**
  7744. * True if the World matrix has been frozen.
  7745. */
  7746. readonly isWorldMatrixFrozen: boolean;
  7747. /**
  7748. * Retuns the mesh absolute position in the World.
  7749. * @returns a Vector3.
  7750. */
  7751. getAbsolutePosition(): Vector3;
  7752. /**
  7753. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7754. * @param absolutePosition the absolute position to set
  7755. * @returns the TransformNode.
  7756. */
  7757. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7758. /**
  7759. * Sets the mesh position in its local space.
  7760. * @param vector3 the position to set in localspace
  7761. * @returns the TransformNode.
  7762. */
  7763. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7764. /**
  7765. * Returns the mesh position in the local space from the current World matrix values.
  7766. * @returns a new Vector3.
  7767. */
  7768. getPositionExpressedInLocalSpace(): Vector3;
  7769. /**
  7770. * Translates the mesh along the passed Vector3 in its local space.
  7771. * @param vector3 the distance to translate in localspace
  7772. * @returns the TransformNode.
  7773. */
  7774. locallyTranslate(vector3: Vector3): TransformNode;
  7775. private static _lookAtVectorCache;
  7776. /**
  7777. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7778. * @param targetPoint the position (must be in same space as current mesh) to look at
  7779. * @param yawCor optional yaw (y-axis) correction in radians
  7780. * @param pitchCor optional pitch (x-axis) correction in radians
  7781. * @param rollCor optional roll (z-axis) correction in radians
  7782. * @param space the choosen space of the target
  7783. * @returns the TransformNode.
  7784. */
  7785. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7786. /**
  7787. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7788. * This Vector3 is expressed in the World space.
  7789. * @param localAxis axis to rotate
  7790. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7791. */
  7792. getDirection(localAxis: Vector3): Vector3;
  7793. /**
  7794. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7795. * localAxis is expressed in the mesh local space.
  7796. * result is computed in the Wordl space from the mesh World matrix.
  7797. * @param localAxis axis to rotate
  7798. * @param result the resulting transformnode
  7799. * @returns this TransformNode.
  7800. */
  7801. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7802. /**
  7803. * Sets this transform node rotation to the given local axis.
  7804. * @param localAxis the axis in local space
  7805. * @param yawCor optional yaw (y-axis) correction in radians
  7806. * @param pitchCor optional pitch (x-axis) correction in radians
  7807. * @param rollCor optional roll (z-axis) correction in radians
  7808. * @returns this TransformNode
  7809. */
  7810. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7811. /**
  7812. * Sets a new pivot point to the current node
  7813. * @param point defines the new pivot point to use
  7814. * @param space defines if the point is in world or local space (local by default)
  7815. * @returns the current TransformNode
  7816. */
  7817. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7818. /**
  7819. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7820. * @returns the pivot point
  7821. */
  7822. getPivotPoint(): Vector3;
  7823. /**
  7824. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7825. * @param result the vector3 to store the result
  7826. * @returns this TransformNode.
  7827. */
  7828. getPivotPointToRef(result: Vector3): TransformNode;
  7829. /**
  7830. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7831. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7832. */
  7833. getAbsolutePivotPoint(): Vector3;
  7834. /**
  7835. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7836. * @param result vector3 to store the result
  7837. * @returns this TransformNode.
  7838. */
  7839. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7840. /**
  7841. * Defines the passed node as the parent of the current node.
  7842. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7843. * @see https://doc.babylonjs.com/how_to/parenting
  7844. * @param node the node ot set as the parent
  7845. * @returns this TransformNode.
  7846. */
  7847. setParent(node: Nullable<Node>): TransformNode;
  7848. private _nonUniformScaling;
  7849. /**
  7850. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7851. */
  7852. readonly nonUniformScaling: boolean;
  7853. /** @hidden */
  7854. _updateNonUniformScalingState(value: boolean): boolean;
  7855. /**
  7856. * Attach the current TransformNode to another TransformNode associated with a bone
  7857. * @param bone Bone affecting the TransformNode
  7858. * @param affectedTransformNode TransformNode associated with the bone
  7859. * @returns this object
  7860. */
  7861. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7862. /**
  7863. * Detach the transform node if its associated with a bone
  7864. * @returns this object
  7865. */
  7866. detachFromBone(): TransformNode;
  7867. private static _rotationAxisCache;
  7868. /**
  7869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7870. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7871. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7872. * The passed axis is also normalized.
  7873. * @param axis the axis to rotate around
  7874. * @param amount the amount to rotate in radians
  7875. * @param space Space to rotate in (Default: local)
  7876. * @returns the TransformNode.
  7877. */
  7878. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7879. /**
  7880. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7881. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7882. * The passed axis is also normalized. .
  7883. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7884. * @param point the point to rotate around
  7885. * @param axis the axis to rotate around
  7886. * @param amount the amount to rotate in radians
  7887. * @returns the TransformNode
  7888. */
  7889. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7890. /**
  7891. * Translates the mesh along the axis vector for the passed distance in the given space.
  7892. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7893. * @param axis the axis to translate in
  7894. * @param distance the distance to translate
  7895. * @param space Space to rotate in (Default: local)
  7896. * @returns the TransformNode.
  7897. */
  7898. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7899. /**
  7900. * Adds a rotation step to the mesh current rotation.
  7901. * x, y, z are Euler angles expressed in radians.
  7902. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7903. * This means this rotation is made in the mesh local space only.
  7904. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7905. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7906. * ```javascript
  7907. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7908. * ```
  7909. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7910. * 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.
  7911. * @param x Rotation to add
  7912. * @param y Rotation to add
  7913. * @param z Rotation to add
  7914. * @returns the TransformNode.
  7915. */
  7916. addRotation(x: number, y: number, z: number): TransformNode;
  7917. /**
  7918. * @hidden
  7919. */
  7920. protected _getEffectiveParent(): Nullable<Node>;
  7921. /**
  7922. * Computes the world matrix of the node
  7923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7924. * @returns the world matrix
  7925. */
  7926. computeWorldMatrix(force?: boolean): Matrix;
  7927. protected _afterComputeWorldMatrix(): void;
  7928. /**
  7929. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7930. * @param func callback function to add
  7931. *
  7932. * @returns the TransformNode.
  7933. */
  7934. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7935. /**
  7936. * Removes a registered callback function.
  7937. * @param func callback function to remove
  7938. * @returns the TransformNode.
  7939. */
  7940. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7941. /**
  7942. * Gets the position of the current mesh in camera space
  7943. * @param camera defines the camera to use
  7944. * @returns a position
  7945. */
  7946. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7947. /**
  7948. * Returns the distance from the mesh to the active camera
  7949. * @param camera defines the camera to use
  7950. * @returns the distance
  7951. */
  7952. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7953. /**
  7954. * Clone the current transform node
  7955. * @param name Name of the new clone
  7956. * @param newParent New parent for the clone
  7957. * @param doNotCloneChildren Do not clone children hierarchy
  7958. * @returns the new transform node
  7959. */
  7960. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7961. /**
  7962. * Serializes the objects information.
  7963. * @param currentSerializationObject defines the object to serialize in
  7964. * @returns the serialized object
  7965. */
  7966. serialize(currentSerializationObject?: any): any;
  7967. /**
  7968. * Returns a new TransformNode object parsed from the source provided.
  7969. * @param parsedTransformNode is the source.
  7970. * @param scene the scne the object belongs to
  7971. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7972. * @returns a new TransformNode object parsed from the source provided.
  7973. */
  7974. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7975. /**
  7976. * Get all child-transformNodes of this node
  7977. * @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
  7978. * @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
  7979. * @returns an array of TransformNode
  7980. */
  7981. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7982. /**
  7983. * Releases resources associated with this transform node.
  7984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7986. */
  7987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7988. }
  7989. }
  7990. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7991. /**
  7992. * Class used to override all child animations of a given target
  7993. */
  7994. export class AnimationPropertiesOverride {
  7995. /**
  7996. * Gets or sets a value indicating if animation blending must be used
  7997. */
  7998. enableBlending: boolean;
  7999. /**
  8000. * Gets or sets the blending speed to use when enableBlending is true
  8001. */
  8002. blendingSpeed: number;
  8003. /**
  8004. * Gets or sets the default loop mode to use
  8005. */
  8006. loopMode: number;
  8007. }
  8008. }
  8009. declare module "babylonjs/Bones/bone" {
  8010. import { Skeleton } from "babylonjs/Bones/skeleton";
  8011. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8012. import { Nullable } from "babylonjs/types";
  8013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8014. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8015. import { Node } from "babylonjs/node";
  8016. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8017. /**
  8018. * Class used to store bone information
  8019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8020. */
  8021. export class Bone extends Node {
  8022. /**
  8023. * defines the bone name
  8024. */
  8025. name: string;
  8026. private static _tmpVecs;
  8027. private static _tmpQuat;
  8028. private static _tmpMats;
  8029. /**
  8030. * Gets the list of child bones
  8031. */
  8032. children: Bone[];
  8033. /** Gets the animations associated with this bone */
  8034. animations: import("babylonjs/Animations/animation").Animation[];
  8035. /**
  8036. * Gets or sets bone length
  8037. */
  8038. length: number;
  8039. /**
  8040. * @hidden Internal only
  8041. * Set this value to map this bone to a different index in the transform matrices
  8042. * Set this value to -1 to exclude the bone from the transform matrices
  8043. */
  8044. _index: Nullable<number>;
  8045. private _skeleton;
  8046. private _localMatrix;
  8047. private _restPose;
  8048. private _baseMatrix;
  8049. private _absoluteTransform;
  8050. private _invertedAbsoluteTransform;
  8051. private _parent;
  8052. private _scalingDeterminant;
  8053. private _worldTransform;
  8054. private _localScaling;
  8055. private _localRotation;
  8056. private _localPosition;
  8057. private _needToDecompose;
  8058. private _needToCompose;
  8059. /** @hidden */
  8060. _linkedTransformNode: Nullable<TransformNode>;
  8061. /** @hidden */
  8062. /** @hidden */
  8063. _matrix: Matrix;
  8064. /**
  8065. * Create a new bone
  8066. * @param name defines the bone name
  8067. * @param skeleton defines the parent skeleton
  8068. * @param parentBone defines the parent (can be null if the bone is the root)
  8069. * @param localMatrix defines the local matrix
  8070. * @param restPose defines the rest pose matrix
  8071. * @param baseMatrix defines the base matrix
  8072. * @param index defines index of the bone in the hiearchy
  8073. */
  8074. constructor(
  8075. /**
  8076. * defines the bone name
  8077. */
  8078. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8079. /**
  8080. * Gets the current object class name.
  8081. * @return the class name
  8082. */
  8083. getClassName(): string;
  8084. /**
  8085. * Gets the parent skeleton
  8086. * @returns a skeleton
  8087. */
  8088. getSkeleton(): Skeleton;
  8089. /**
  8090. * Gets parent bone
  8091. * @returns a bone or null if the bone is the root of the bone hierarchy
  8092. */
  8093. getParent(): Nullable<Bone>;
  8094. /**
  8095. * Returns an array containing the root bones
  8096. * @returns an array containing the root bones
  8097. */
  8098. getChildren(): Array<Bone>;
  8099. /**
  8100. * Sets the parent bone
  8101. * @param parent defines the parent (can be null if the bone is the root)
  8102. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8103. */
  8104. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8105. /**
  8106. * Gets the local matrix
  8107. * @returns a matrix
  8108. */
  8109. getLocalMatrix(): Matrix;
  8110. /**
  8111. * Gets the base matrix (initial matrix which remains unchanged)
  8112. * @returns a matrix
  8113. */
  8114. getBaseMatrix(): Matrix;
  8115. /**
  8116. * Gets the rest pose matrix
  8117. * @returns a matrix
  8118. */
  8119. getRestPose(): Matrix;
  8120. /**
  8121. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8122. */
  8123. getWorldMatrix(): Matrix;
  8124. /**
  8125. * Sets the local matrix to rest pose matrix
  8126. */
  8127. returnToRest(): void;
  8128. /**
  8129. * Gets the inverse of the absolute transform matrix.
  8130. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8131. * @returns a matrix
  8132. */
  8133. getInvertedAbsoluteTransform(): Matrix;
  8134. /**
  8135. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8136. * @returns a matrix
  8137. */
  8138. getAbsoluteTransform(): Matrix;
  8139. /**
  8140. * Links with the given transform node.
  8141. * The local matrix of this bone is copied from the transform node every frame.
  8142. * @param transformNode defines the transform node to link to
  8143. */
  8144. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8145. /** Gets or sets current position (in local space) */
  8146. position: Vector3;
  8147. /** Gets or sets current rotation (in local space) */
  8148. rotation: Vector3;
  8149. /** Gets or sets current rotation quaternion (in local space) */
  8150. rotationQuaternion: Quaternion;
  8151. /** Gets or sets current scaling (in local space) */
  8152. scaling: Vector3;
  8153. /**
  8154. * Gets the animation properties override
  8155. */
  8156. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8157. private _decompose;
  8158. private _compose;
  8159. /**
  8160. * Update the base and local matrices
  8161. * @param matrix defines the new base or local matrix
  8162. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8163. * @param updateLocalMatrix defines if the local matrix should be updated
  8164. */
  8165. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8166. /** @hidden */
  8167. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8168. /**
  8169. * Flag the bone as dirty (Forcing it to update everything)
  8170. */
  8171. markAsDirty(): void;
  8172. private _markAsDirtyAndCompose;
  8173. private _markAsDirtyAndDecompose;
  8174. /**
  8175. * Translate the bone in local or world space
  8176. * @param vec The amount to translate the bone
  8177. * @param space The space that the translation is in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. */
  8180. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8181. /**
  8182. * Set the postion of the bone in local or world space
  8183. * @param position The position to set the bone
  8184. * @param space The space that the position is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the absolute position of the bone (world space)
  8190. * @param position The position to set the bone
  8191. * @param mesh The mesh that this bone is attached to
  8192. */
  8193. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Scale the bone on the x, y and z axes (in local space)
  8196. * @param x The amount to scale the bone on the x axis
  8197. * @param y The amount to scale the bone on the y axis
  8198. * @param z The amount to scale the bone on the z axis
  8199. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8200. */
  8201. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8202. /**
  8203. * Set the bone scaling in local space
  8204. * @param scale defines the scaling vector
  8205. */
  8206. setScale(scale: Vector3): void;
  8207. /**
  8208. * Gets the current scaling in local space
  8209. * @returns the current scaling vector
  8210. */
  8211. getScale(): Vector3;
  8212. /**
  8213. * Gets the current scaling in local space and stores it in a target vector
  8214. * @param result defines the target vector
  8215. */
  8216. getScaleToRef(result: Vector3): void;
  8217. /**
  8218. * Set the yaw, pitch, and roll of the bone in local or world space
  8219. * @param yaw The rotation of the bone on the y axis
  8220. * @param pitch The rotation of the bone on the x axis
  8221. * @param roll The rotation of the bone on the z axis
  8222. * @param space The space that the axes of rotation are in
  8223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8224. */
  8225. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8226. /**
  8227. * Add a rotation to the bone on an axis in local or world space
  8228. * @param axis The axis to rotate the bone on
  8229. * @param amount The amount to rotate the bone
  8230. * @param space The space that the axis is in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. */
  8233. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8234. /**
  8235. * Set the rotation of the bone to a particular axis angle in local or world space
  8236. * @param axis The axis to rotate the bone on
  8237. * @param angle The angle that the bone should be rotated to
  8238. * @param space The space that the axis is in
  8239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8240. */
  8241. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8242. /**
  8243. * Set the euler rotation of the bone in local of world space
  8244. * @param rotation The euler rotation that the bone should be set to
  8245. * @param space The space that the rotation is in
  8246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8247. */
  8248. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8249. /**
  8250. * Set the quaternion rotation of the bone in local of world space
  8251. * @param quat The quaternion rotation that the bone should be set to
  8252. * @param space The space that the rotation is in
  8253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8254. */
  8255. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8256. /**
  8257. * Set the rotation matrix of the bone in local of world space
  8258. * @param rotMat The rotation matrix that the bone should be set to
  8259. * @param space The space that the rotation is in
  8260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8261. */
  8262. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8263. private _rotateWithMatrix;
  8264. private _getNegativeRotationToRef;
  8265. /**
  8266. * Get the position of the bone in local or world space
  8267. * @param space The space that the returned position is in
  8268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8269. * @returns The position of the bone
  8270. */
  8271. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8272. /**
  8273. * Copy the position of the bone to a vector3 in local or world space
  8274. * @param space The space that the returned position is in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @param result The vector3 to copy the position to
  8277. */
  8278. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8279. /**
  8280. * Get the absolute position of the bone (world space)
  8281. * @param mesh The mesh that this bone is attached to
  8282. * @returns The absolute position of the bone
  8283. */
  8284. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8285. /**
  8286. * Copy the absolute position of the bone (world space) to the result param
  8287. * @param mesh The mesh that this bone is attached to
  8288. * @param result The vector3 to copy the absolute position to
  8289. */
  8290. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8291. /**
  8292. * Compute the absolute transforms of this bone and its children
  8293. */
  8294. computeAbsoluteTransforms(): void;
  8295. /**
  8296. * Get the world direction from an axis that is in the local space of the bone
  8297. * @param localAxis The local direction that is used to compute the world direction
  8298. * @param mesh The mesh that this bone is attached to
  8299. * @returns The world direction
  8300. */
  8301. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8302. /**
  8303. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8304. * @param localAxis The local direction that is used to compute the world direction
  8305. * @param mesh The mesh that this bone is attached to
  8306. * @param result The vector3 that the world direction will be copied to
  8307. */
  8308. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8309. /**
  8310. * Get the euler rotation of the bone in local or world space
  8311. * @param space The space that the rotation should be in
  8312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8313. * @returns The euler rotation
  8314. */
  8315. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8316. /**
  8317. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8318. * @param space The space that the rotation should be in
  8319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8320. * @param result The vector3 that the rotation should be copied to
  8321. */
  8322. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8323. /**
  8324. * Get the quaternion rotation of the bone in either local or world space
  8325. * @param space The space that the rotation should be in
  8326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8327. * @returns The quaternion rotation
  8328. */
  8329. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8330. /**
  8331. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8332. * @param space The space that the rotation should be in
  8333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8334. * @param result The quaternion that the rotation should be copied to
  8335. */
  8336. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8337. /**
  8338. * Get the rotation matrix of the bone in local or world space
  8339. * @param space The space that the rotation should be in
  8340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8341. * @returns The rotation matrix
  8342. */
  8343. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8344. /**
  8345. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8346. * @param space The space that the rotation should be in
  8347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8348. * @param result The quaternion that the rotation should be copied to
  8349. */
  8350. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8351. /**
  8352. * Get the world position of a point that is in the local space of the bone
  8353. * @param position The local position
  8354. * @param mesh The mesh that this bone is attached to
  8355. * @returns The world position
  8356. */
  8357. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8358. /**
  8359. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8360. * @param position The local position
  8361. * @param mesh The mesh that this bone is attached to
  8362. * @param result The vector3 that the world position should be copied to
  8363. */
  8364. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8365. /**
  8366. * Get the local position of a point that is in world space
  8367. * @param position The world position
  8368. * @param mesh The mesh that this bone is attached to
  8369. * @returns The local position
  8370. */
  8371. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8372. /**
  8373. * Get the local position of a point that is in world space and copy it to the result param
  8374. * @param position The world position
  8375. * @param mesh The mesh that this bone is attached to
  8376. * @param result The vector3 that the local position should be copied to
  8377. */
  8378. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8379. }
  8380. }
  8381. declare module "babylonjs/Misc/iInspectable" {
  8382. /**
  8383. * Enum that determines the text-wrapping mode to use.
  8384. */
  8385. export enum InspectableType {
  8386. /**
  8387. * Checkbox for booleans
  8388. */
  8389. Checkbox = 0,
  8390. /**
  8391. * Sliders for numbers
  8392. */
  8393. Slider = 1,
  8394. /**
  8395. * Vector3
  8396. */
  8397. Vector3 = 2,
  8398. /**
  8399. * Quaternions
  8400. */
  8401. Quaternion = 3,
  8402. /**
  8403. * Color3
  8404. */
  8405. Color3 = 4
  8406. }
  8407. /**
  8408. * Interface used to define custom inspectable properties.
  8409. * This interface is used by the inspector to display custom property grids
  8410. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8411. */
  8412. export interface IInspectable {
  8413. /**
  8414. * Gets the label to display
  8415. */
  8416. label: string;
  8417. /**
  8418. * Gets the name of the property to edit
  8419. */
  8420. propertyName: string;
  8421. /**
  8422. * Gets the type of the editor to use
  8423. */
  8424. type: InspectableType;
  8425. /**
  8426. * Gets the minimum value of the property when using in "slider" mode
  8427. */
  8428. min?: number;
  8429. /**
  8430. * Gets the maximum value of the property when using in "slider" mode
  8431. */
  8432. max?: number;
  8433. /**
  8434. * Gets the setp to use when using in "slider" mode
  8435. */
  8436. step?: number;
  8437. }
  8438. }
  8439. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8440. import { Nullable } from "babylonjs/types";
  8441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8442. /**
  8443. * This represents the required contract to create a new type of texture loader.
  8444. */
  8445. export interface IInternalTextureLoader {
  8446. /**
  8447. * Defines wether the loader supports cascade loading the different faces.
  8448. */
  8449. supportCascades: boolean;
  8450. /**
  8451. * This returns if the loader support the current file information.
  8452. * @param extension defines the file extension of the file being loaded
  8453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8454. * @param fallback defines the fallback internal texture if any
  8455. * @param isBase64 defines whether the texture is encoded as a base64
  8456. * @param isBuffer defines whether the texture data are stored as a buffer
  8457. * @returns true if the loader can load the specified file
  8458. */
  8459. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8460. /**
  8461. * Transform the url before loading if required.
  8462. * @param rootUrl the url of the texture
  8463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8464. * @returns the transformed texture
  8465. */
  8466. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8467. /**
  8468. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8469. * @param rootUrl the url of the texture
  8470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8471. * @returns the fallback texture
  8472. */
  8473. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8474. /**
  8475. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8476. * @param data contains the texture data
  8477. * @param texture defines the BabylonJS internal texture
  8478. * @param createPolynomials will be true if polynomials have been requested
  8479. * @param onLoad defines the callback to trigger once the texture is ready
  8480. * @param onError defines the callback to trigger in case of error
  8481. */
  8482. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8483. /**
  8484. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8485. * @param data contains the texture data
  8486. * @param texture defines the BabylonJS internal texture
  8487. * @param callback defines the method to call once ready to upload
  8488. */
  8489. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8490. }
  8491. }
  8492. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8493. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8494. import { Nullable } from "babylonjs/types";
  8495. import { Scene } from "babylonjs/scene";
  8496. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8497. module "babylonjs/Engines/engine" {
  8498. interface Engine {
  8499. /**
  8500. * Creates a depth stencil cube texture.
  8501. * This is only available in WebGL 2.
  8502. * @param size The size of face edge in the cube texture.
  8503. * @param options The options defining the cube texture.
  8504. * @returns The cube texture
  8505. */
  8506. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8507. /**
  8508. * Creates a cube texture
  8509. * @param rootUrl defines the url where the files to load is located
  8510. * @param scene defines the current scene
  8511. * @param files defines the list of files to load (1 per face)
  8512. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8513. * @param onLoad defines an optional callback raised when the texture is loaded
  8514. * @param onError defines an optional callback raised if there is an issue to load the texture
  8515. * @param format defines the format of the data
  8516. * @param forcedExtension defines the extension to use to pick the right loader
  8517. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8518. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8519. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8520. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8521. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8522. * @returns the cube texture as an InternalTexture
  8523. */
  8524. 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;
  8525. /**
  8526. * Creates a cube texture
  8527. * @param rootUrl defines the url where the files to load is located
  8528. * @param scene defines the current scene
  8529. * @param files defines the list of files to load (1 per face)
  8530. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8531. * @param onLoad defines an optional callback raised when the texture is loaded
  8532. * @param onError defines an optional callback raised if there is an issue to load the texture
  8533. * @param format defines the format of the data
  8534. * @param forcedExtension defines the extension to use to pick the right loader
  8535. * @returns the cube texture as an InternalTexture
  8536. */
  8537. 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;
  8538. /**
  8539. * Creates a cube texture
  8540. * @param rootUrl defines the url where the files to load is located
  8541. * @param scene defines the current scene
  8542. * @param files defines the list of files to load (1 per face)
  8543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8544. * @param onLoad defines an optional callback raised when the texture is loaded
  8545. * @param onError defines an optional callback raised if there is an issue to load the texture
  8546. * @param format defines the format of the data
  8547. * @param forcedExtension defines the extension to use to pick the right loader
  8548. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8551. * @returns the cube texture as an InternalTexture
  8552. */
  8553. 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;
  8554. /** @hidden */
  8555. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8556. /** @hidden */
  8557. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8558. /** @hidden */
  8559. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8562. }
  8563. }
  8564. }
  8565. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8566. import { Nullable } from "babylonjs/types";
  8567. import { Scene } from "babylonjs/scene";
  8568. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8570. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8571. /**
  8572. * Class for creating a cube texture
  8573. */
  8574. export class CubeTexture extends BaseTexture {
  8575. private _delayedOnLoad;
  8576. /**
  8577. * The url of the texture
  8578. */
  8579. url: string;
  8580. /**
  8581. * Gets or sets the center of the bounding box associated with the cube texture.
  8582. * It must define where the camera used to render the texture was set
  8583. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8584. */
  8585. boundingBoxPosition: Vector3;
  8586. private _boundingBoxSize;
  8587. /**
  8588. * Gets or sets the size of the bounding box associated with the cube texture
  8589. * When defined, the cubemap will switch to local mode
  8590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8591. * @example https://www.babylonjs-playground.com/#RNASML
  8592. */
  8593. /**
  8594. * Returns the bounding box size
  8595. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8596. */
  8597. boundingBoxSize: Vector3;
  8598. protected _rotationY: number;
  8599. /**
  8600. * Sets texture matrix rotation angle around Y axis in radians.
  8601. */
  8602. /**
  8603. * Gets texture matrix rotation angle around Y axis radians.
  8604. */
  8605. rotationY: number;
  8606. /**
  8607. * Are mip maps generated for this texture or not.
  8608. */
  8609. readonly noMipmap: boolean;
  8610. private _noMipmap;
  8611. private _files;
  8612. private _extensions;
  8613. private _textureMatrix;
  8614. private _format;
  8615. private _createPolynomials;
  8616. /** @hidden */
  8617. _prefiltered: boolean;
  8618. /**
  8619. * Creates a cube texture from an array of image urls
  8620. * @param files defines an array of image urls
  8621. * @param scene defines the hosting scene
  8622. * @param noMipmap specifies if mip maps are not used
  8623. * @returns a cube texture
  8624. */
  8625. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8626. /**
  8627. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8628. * @param url defines the url of the prefiltered texture
  8629. * @param scene defines the scene the texture is attached to
  8630. * @param forcedExtension defines the extension of the file if different from the url
  8631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8632. * @return the prefiltered texture
  8633. */
  8634. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8635. /**
  8636. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8637. * as prefiltered data.
  8638. * @param rootUrl defines the url of the texture or the root name of the six images
  8639. * @param scene defines the scene the texture is attached to
  8640. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8641. * @param noMipmap defines if mipmaps should be created or not
  8642. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8643. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8644. * @param onError defines a callback triggered in case of error during load
  8645. * @param format defines the internal format to use for the texture once loaded
  8646. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8647. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8648. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8651. * @return the cube texture
  8652. */
  8653. 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);
  8654. /**
  8655. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8656. */
  8657. readonly isPrefiltered: boolean;
  8658. /**
  8659. * Get the current class name of the texture useful for serialization or dynamic coding.
  8660. * @returns "CubeTexture"
  8661. */
  8662. getClassName(): string;
  8663. /**
  8664. * Update the url (and optional buffer) of this texture if url was null during construction.
  8665. * @param url the url of the texture
  8666. * @param forcedExtension defines the extension to use
  8667. * @param onLoad callback called when the texture is loaded (defaults to null)
  8668. */
  8669. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8670. /**
  8671. * Delays loading of the cube texture
  8672. * @param forcedExtension defines the extension to use
  8673. */
  8674. delayLoad(forcedExtension?: string): void;
  8675. /**
  8676. * Returns the reflection texture matrix
  8677. * @returns the reflection texture matrix
  8678. */
  8679. getReflectionTextureMatrix(): Matrix;
  8680. /**
  8681. * Sets the reflection texture matrix
  8682. * @param value Reflection texture matrix
  8683. */
  8684. setReflectionTextureMatrix(value: Matrix): void;
  8685. /**
  8686. * Parses text to create a cube texture
  8687. * @param parsedTexture define the serialized text to read from
  8688. * @param scene defines the hosting scene
  8689. * @param rootUrl defines the root url of the cube texture
  8690. * @returns a cube texture
  8691. */
  8692. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8693. /**
  8694. * Makes a clone, or deep copy, of the cube texture
  8695. * @returns a new cube texture
  8696. */
  8697. clone(): CubeTexture;
  8698. }
  8699. }
  8700. declare module "babylonjs/Shaders/postprocess.vertex" {
  8701. /** @hidden */
  8702. export var postprocessVertexShader: {
  8703. name: string;
  8704. shader: string;
  8705. };
  8706. }
  8707. declare module "babylonjs/Cameras/targetCamera" {
  8708. import { Nullable } from "babylonjs/types";
  8709. import { Camera } from "babylonjs/Cameras/camera";
  8710. import { Scene } from "babylonjs/scene";
  8711. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8712. /**
  8713. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8714. * This is the base of the follow, arc rotate cameras and Free camera
  8715. * @see http://doc.babylonjs.com/features/cameras
  8716. */
  8717. export class TargetCamera extends Camera {
  8718. private static _RigCamTransformMatrix;
  8719. private static _TargetTransformMatrix;
  8720. private static _TargetFocalPoint;
  8721. /**
  8722. * Define the current direction the camera is moving to
  8723. */
  8724. cameraDirection: Vector3;
  8725. /**
  8726. * Define the current rotation the camera is rotating to
  8727. */
  8728. cameraRotation: Vector2;
  8729. /**
  8730. * When set, the up vector of the camera will be updated by the rotation of the camera
  8731. */
  8732. updateUpVectorFromRotation: boolean;
  8733. private _tmpQuaternion;
  8734. /**
  8735. * Define the current rotation of the camera
  8736. */
  8737. rotation: Vector3;
  8738. /**
  8739. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8740. */
  8741. rotationQuaternion: Quaternion;
  8742. /**
  8743. * Define the current speed of the camera
  8744. */
  8745. speed: number;
  8746. /**
  8747. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8748. * around all axis.
  8749. */
  8750. noRotationConstraint: boolean;
  8751. /**
  8752. * Define the current target of the camera as an object or a position.
  8753. */
  8754. lockedTarget: any;
  8755. /** @hidden */
  8756. _currentTarget: Vector3;
  8757. /** @hidden */
  8758. _initialFocalDistance: number;
  8759. /** @hidden */
  8760. _viewMatrix: Matrix;
  8761. /** @hidden */
  8762. _camMatrix: Matrix;
  8763. /** @hidden */
  8764. _cameraTransformMatrix: Matrix;
  8765. /** @hidden */
  8766. _cameraRotationMatrix: Matrix;
  8767. /** @hidden */
  8768. _referencePoint: Vector3;
  8769. /** @hidden */
  8770. _transformedReferencePoint: Vector3;
  8771. protected _globalCurrentTarget: Vector3;
  8772. protected _globalCurrentUpVector: Vector3;
  8773. /** @hidden */
  8774. _reset: () => void;
  8775. private _defaultUp;
  8776. /**
  8777. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8778. * This is the base of the follow, arc rotate cameras and Free camera
  8779. * @see http://doc.babylonjs.com/features/cameras
  8780. * @param name Defines the name of the camera in the scene
  8781. * @param position Defines the start position of the camera in the scene
  8782. * @param scene Defines the scene the camera belongs to
  8783. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8784. */
  8785. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8786. /**
  8787. * Gets the position in front of the camera at a given distance.
  8788. * @param distance The distance from the camera we want the position to be
  8789. * @returns the position
  8790. */
  8791. getFrontPosition(distance: number): Vector3;
  8792. /** @hidden */
  8793. _getLockedTargetPosition(): Nullable<Vector3>;
  8794. private _storedPosition;
  8795. private _storedRotation;
  8796. private _storedRotationQuaternion;
  8797. /**
  8798. * Store current camera state of the camera (fov, position, rotation, etc..)
  8799. * @returns the camera
  8800. */
  8801. storeState(): Camera;
  8802. /**
  8803. * Restored camera state. You must call storeState() first
  8804. * @returns whether it was successful or not
  8805. * @hidden
  8806. */
  8807. _restoreStateValues(): boolean;
  8808. /** @hidden */
  8809. _initCache(): void;
  8810. /** @hidden */
  8811. _updateCache(ignoreParentClass?: boolean): void;
  8812. /** @hidden */
  8813. _isSynchronizedViewMatrix(): boolean;
  8814. /** @hidden */
  8815. _computeLocalCameraSpeed(): number;
  8816. /**
  8817. * Defines the target the camera should look at.
  8818. * This will automatically adapt alpha beta and radius to fit within the new target.
  8819. * @param target Defines the new target as a Vector or a mesh
  8820. */
  8821. setTarget(target: Vector3): void;
  8822. /**
  8823. * Return the current target position of the camera. This value is expressed in local space.
  8824. * @returns the target position
  8825. */
  8826. getTarget(): Vector3;
  8827. /** @hidden */
  8828. _decideIfNeedsToMove(): boolean;
  8829. /** @hidden */
  8830. _updatePosition(): void;
  8831. /** @hidden */
  8832. _checkInputs(): void;
  8833. protected _updateCameraRotationMatrix(): void;
  8834. /**
  8835. * 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)
  8836. * @returns the current camera
  8837. */
  8838. private _rotateUpVectorWithCameraRotationMatrix;
  8839. private _cachedRotationZ;
  8840. private _cachedQuaternionRotationZ;
  8841. /** @hidden */
  8842. _getViewMatrix(): Matrix;
  8843. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8844. /**
  8845. * @hidden
  8846. */
  8847. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8848. /**
  8849. * @hidden
  8850. */
  8851. _updateRigCameras(): void;
  8852. private _getRigCamPositionAndTarget;
  8853. /**
  8854. * Gets the current object class name.
  8855. * @return the class name
  8856. */
  8857. getClassName(): string;
  8858. }
  8859. }
  8860. declare module "babylonjs/Cameras/cameraInputsManager" {
  8861. import { Nullable } from "babylonjs/types";
  8862. import { Camera } from "babylonjs/Cameras/camera";
  8863. /**
  8864. * @ignore
  8865. * This is a list of all the different input types that are available in the application.
  8866. * Fo instance: ArcRotateCameraGamepadInput...
  8867. */
  8868. export var CameraInputTypes: {};
  8869. /**
  8870. * This is the contract to implement in order to create a new input class.
  8871. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8872. */
  8873. export interface ICameraInput<TCamera extends Camera> {
  8874. /**
  8875. * Defines the camera the input is attached to.
  8876. */
  8877. camera: Nullable<TCamera>;
  8878. /**
  8879. * Gets the class name of the current intput.
  8880. * @returns the class name
  8881. */
  8882. getClassName(): string;
  8883. /**
  8884. * Get the friendly name associated with the input class.
  8885. * @returns the input friendly name
  8886. */
  8887. getSimpleName(): string;
  8888. /**
  8889. * Attach the input controls to a specific dom element to get the input from.
  8890. * @param element Defines the element the controls should be listened from
  8891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8892. */
  8893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8894. /**
  8895. * Detach the current controls from the specified dom element.
  8896. * @param element Defines the element to stop listening the inputs from
  8897. */
  8898. detachControl(element: Nullable<HTMLElement>): void;
  8899. /**
  8900. * Update the current camera state depending on the inputs that have been used this frame.
  8901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8902. */
  8903. checkInputs?: () => void;
  8904. }
  8905. /**
  8906. * Represents a map of input types to input instance or input index to input instance.
  8907. */
  8908. export interface CameraInputsMap<TCamera extends Camera> {
  8909. /**
  8910. * Accessor to the input by input type.
  8911. */
  8912. [name: string]: ICameraInput<TCamera>;
  8913. /**
  8914. * Accessor to the input by input index.
  8915. */
  8916. [idx: number]: ICameraInput<TCamera>;
  8917. }
  8918. /**
  8919. * This represents the input manager used within a camera.
  8920. * It helps dealing with all the different kind of input attached to a camera.
  8921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8922. */
  8923. export class CameraInputsManager<TCamera extends Camera> {
  8924. /**
  8925. * Defines the list of inputs attahed to the camera.
  8926. */
  8927. attached: CameraInputsMap<TCamera>;
  8928. /**
  8929. * Defines the dom element the camera is collecting inputs from.
  8930. * This is null if the controls have not been attached.
  8931. */
  8932. attachedElement: Nullable<HTMLElement>;
  8933. /**
  8934. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8935. */
  8936. noPreventDefault: boolean;
  8937. /**
  8938. * Defined the camera the input manager belongs to.
  8939. */
  8940. camera: TCamera;
  8941. /**
  8942. * Update the current camera state depending on the inputs that have been used this frame.
  8943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8944. */
  8945. checkInputs: () => void;
  8946. /**
  8947. * Instantiate a new Camera Input Manager.
  8948. * @param camera Defines the camera the input manager blongs to
  8949. */
  8950. constructor(camera: TCamera);
  8951. /**
  8952. * Add an input method to a camera
  8953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8954. * @param input camera input method
  8955. */
  8956. add(input: ICameraInput<TCamera>): void;
  8957. /**
  8958. * Remove a specific input method from a camera
  8959. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8960. * @param inputToRemove camera input method
  8961. */
  8962. remove(inputToRemove: ICameraInput<TCamera>): void;
  8963. /**
  8964. * Remove a specific input type from a camera
  8965. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8966. * @param inputType the type of the input to remove
  8967. */
  8968. removeByType(inputType: string): void;
  8969. private _addCheckInputs;
  8970. /**
  8971. * Attach the input controls to the currently attached dom element to listen the events from.
  8972. * @param input Defines the input to attach
  8973. */
  8974. attachInput(input: ICameraInput<TCamera>): void;
  8975. /**
  8976. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8977. * @param element Defines the dom element to collect the events from
  8978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8979. */
  8980. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8981. /**
  8982. * Detach the current manager inputs controls from a specific dom element.
  8983. * @param element Defines the dom element to collect the events from
  8984. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8985. */
  8986. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8987. /**
  8988. * Rebuild the dynamic inputCheck function from the current list of
  8989. * defined inputs in the manager.
  8990. */
  8991. rebuildInputCheck(): void;
  8992. /**
  8993. * Remove all attached input methods from a camera
  8994. */
  8995. clear(): void;
  8996. /**
  8997. * Serialize the current input manager attached to a camera.
  8998. * This ensures than once parsed,
  8999. * the input associated to the camera will be identical to the current ones
  9000. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9001. */
  9002. serialize(serializedCamera: any): void;
  9003. /**
  9004. * Parses an input manager serialized JSON to restore the previous list of inputs
  9005. * and states associated to a camera.
  9006. * @param parsedCamera Defines the JSON to parse
  9007. */
  9008. parse(parsedCamera: any): void;
  9009. }
  9010. }
  9011. declare module "babylonjs/Events/keyboardEvents" {
  9012. /**
  9013. * Gather the list of keyboard event types as constants.
  9014. */
  9015. export class KeyboardEventTypes {
  9016. /**
  9017. * The keydown event is fired when a key becomes active (pressed).
  9018. */
  9019. static readonly KEYDOWN: number;
  9020. /**
  9021. * The keyup event is fired when a key has been released.
  9022. */
  9023. static readonly KEYUP: number;
  9024. }
  9025. /**
  9026. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9027. */
  9028. export class KeyboardInfo {
  9029. /**
  9030. * Defines the type of event (KeyboardEventTypes)
  9031. */
  9032. type: number;
  9033. /**
  9034. * Defines the related dom event
  9035. */
  9036. event: KeyboardEvent;
  9037. /**
  9038. * Instantiates a new keyboard info.
  9039. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9040. * @param type Defines the type of event (KeyboardEventTypes)
  9041. * @param event Defines the related dom event
  9042. */
  9043. constructor(
  9044. /**
  9045. * Defines the type of event (KeyboardEventTypes)
  9046. */
  9047. type: number,
  9048. /**
  9049. * Defines the related dom event
  9050. */
  9051. event: KeyboardEvent);
  9052. }
  9053. /**
  9054. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9055. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9056. */
  9057. export class KeyboardInfoPre extends KeyboardInfo {
  9058. /**
  9059. * Defines the type of event (KeyboardEventTypes)
  9060. */
  9061. type: number;
  9062. /**
  9063. * Defines the related dom event
  9064. */
  9065. event: KeyboardEvent;
  9066. /**
  9067. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9068. */
  9069. skipOnPointerObservable: boolean;
  9070. /**
  9071. * Instantiates a new keyboard pre info.
  9072. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9073. * @param type Defines the type of event (KeyboardEventTypes)
  9074. * @param event Defines the related dom event
  9075. */
  9076. constructor(
  9077. /**
  9078. * Defines the type of event (KeyboardEventTypes)
  9079. */
  9080. type: number,
  9081. /**
  9082. * Defines the related dom event
  9083. */
  9084. event: KeyboardEvent);
  9085. }
  9086. }
  9087. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9088. import { Nullable } from "babylonjs/types";
  9089. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9090. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9091. /**
  9092. * Manage the keyboard inputs to control the movement of a free camera.
  9093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9094. */
  9095. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9096. /**
  9097. * Defines the camera the input is attached to.
  9098. */
  9099. camera: FreeCamera;
  9100. /**
  9101. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9102. */
  9103. keysUp: number[];
  9104. /**
  9105. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9106. */
  9107. keysDown: number[];
  9108. /**
  9109. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9110. */
  9111. keysLeft: number[];
  9112. /**
  9113. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9114. */
  9115. keysRight: number[];
  9116. private _keys;
  9117. private _onCanvasBlurObserver;
  9118. private _onKeyboardObserver;
  9119. private _engine;
  9120. private _scene;
  9121. /**
  9122. * Attach the input controls to a specific dom element to get the input from.
  9123. * @param element Defines the element the controls should be listened from
  9124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9125. */
  9126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9127. /**
  9128. * Detach the current controls from the specified dom element.
  9129. * @param element Defines the element to stop listening the inputs from
  9130. */
  9131. detachControl(element: Nullable<HTMLElement>): void;
  9132. /**
  9133. * Update the current camera state depending on the inputs that have been used this frame.
  9134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9135. */
  9136. checkInputs(): void;
  9137. /**
  9138. * Gets the class name of the current intput.
  9139. * @returns the class name
  9140. */
  9141. getClassName(): string;
  9142. /** @hidden */
  9143. _onLostFocus(): void;
  9144. /**
  9145. * Get the friendly name associated with the input class.
  9146. * @returns the input friendly name
  9147. */
  9148. getSimpleName(): string;
  9149. }
  9150. }
  9151. declare module "babylonjs/Lights/shadowLight" {
  9152. import { Camera } from "babylonjs/Cameras/camera";
  9153. import { Scene } from "babylonjs/scene";
  9154. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9156. import { Light } from "babylonjs/Lights/light";
  9157. /**
  9158. * Interface describing all the common properties and methods a shadow light needs to implement.
  9159. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9160. * as well as binding the different shadow properties to the effects.
  9161. */
  9162. export interface IShadowLight extends Light {
  9163. /**
  9164. * The light id in the scene (used in scene.findLighById for instance)
  9165. */
  9166. id: string;
  9167. /**
  9168. * The position the shdow will be casted from.
  9169. */
  9170. position: Vector3;
  9171. /**
  9172. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9173. */
  9174. direction: Vector3;
  9175. /**
  9176. * The transformed position. Position of the light in world space taking parenting in account.
  9177. */
  9178. transformedPosition: Vector3;
  9179. /**
  9180. * The transformed direction. Direction of the light in world space taking parenting in account.
  9181. */
  9182. transformedDirection: Vector3;
  9183. /**
  9184. * The friendly name of the light in the scene.
  9185. */
  9186. name: string;
  9187. /**
  9188. * Defines the shadow projection clipping minimum z value.
  9189. */
  9190. shadowMinZ: number;
  9191. /**
  9192. * Defines the shadow projection clipping maximum z value.
  9193. */
  9194. shadowMaxZ: number;
  9195. /**
  9196. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9197. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9198. */
  9199. computeTransformedInformation(): boolean;
  9200. /**
  9201. * Gets the scene the light belongs to.
  9202. * @returns The scene
  9203. */
  9204. getScene(): Scene;
  9205. /**
  9206. * Callback defining a custom Projection Matrix Builder.
  9207. * This can be used to override the default projection matrix computation.
  9208. */
  9209. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9210. /**
  9211. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9212. * @param matrix The materix to updated with the projection information
  9213. * @param viewMatrix The transform matrix of the light
  9214. * @param renderList The list of mesh to render in the map
  9215. * @returns The current light
  9216. */
  9217. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9218. /**
  9219. * Gets the current depth scale used in ESM.
  9220. * @returns The scale
  9221. */
  9222. getDepthScale(): number;
  9223. /**
  9224. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9225. * @returns true if a cube texture needs to be use
  9226. */
  9227. needCube(): boolean;
  9228. /**
  9229. * Detects if the projection matrix requires to be recomputed this frame.
  9230. * @returns true if it requires to be recomputed otherwise, false.
  9231. */
  9232. needProjectionMatrixCompute(): boolean;
  9233. /**
  9234. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9235. */
  9236. forceProjectionMatrixCompute(): void;
  9237. /**
  9238. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9239. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9240. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9241. */
  9242. getShadowDirection(faceIndex?: number): Vector3;
  9243. /**
  9244. * Gets the minZ used for shadow according to both the scene and the light.
  9245. * @param activeCamera The camera we are returning the min for
  9246. * @returns the depth min z
  9247. */
  9248. getDepthMinZ(activeCamera: Camera): number;
  9249. /**
  9250. * Gets the maxZ used for shadow according to both the scene and the light.
  9251. * @param activeCamera The camera we are returning the max for
  9252. * @returns the depth max z
  9253. */
  9254. getDepthMaxZ(activeCamera: Camera): number;
  9255. }
  9256. /**
  9257. * Base implementation IShadowLight
  9258. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9259. */
  9260. export abstract class ShadowLight extends Light implements IShadowLight {
  9261. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9262. protected _position: Vector3;
  9263. protected _setPosition(value: Vector3): void;
  9264. /**
  9265. * Sets the position the shadow will be casted from. Also use as the light position for both
  9266. * point and spot lights.
  9267. */
  9268. /**
  9269. * Sets the position the shadow will be casted from. Also use as the light position for both
  9270. * point and spot lights.
  9271. */
  9272. position: Vector3;
  9273. protected _direction: Vector3;
  9274. protected _setDirection(value: Vector3): void;
  9275. /**
  9276. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9277. * Also use as the light direction on spot and directional lights.
  9278. */
  9279. /**
  9280. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9281. * Also use as the light direction on spot and directional lights.
  9282. */
  9283. direction: Vector3;
  9284. private _shadowMinZ;
  9285. /**
  9286. * Gets the shadow projection clipping minimum z value.
  9287. */
  9288. /**
  9289. * Sets the shadow projection clipping minimum z value.
  9290. */
  9291. shadowMinZ: number;
  9292. private _shadowMaxZ;
  9293. /**
  9294. * Sets the shadow projection clipping maximum z value.
  9295. */
  9296. /**
  9297. * Gets the shadow projection clipping maximum z value.
  9298. */
  9299. shadowMaxZ: number;
  9300. /**
  9301. * Callback defining a custom Projection Matrix Builder.
  9302. * This can be used to override the default projection matrix computation.
  9303. */
  9304. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9305. /**
  9306. * The transformed position. Position of the light in world space taking parenting in account.
  9307. */
  9308. transformedPosition: Vector3;
  9309. /**
  9310. * The transformed direction. Direction of the light in world space taking parenting in account.
  9311. */
  9312. transformedDirection: Vector3;
  9313. private _needProjectionMatrixCompute;
  9314. /**
  9315. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9316. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9317. */
  9318. computeTransformedInformation(): boolean;
  9319. /**
  9320. * Return the depth scale used for the shadow map.
  9321. * @returns the depth scale.
  9322. */
  9323. getDepthScale(): number;
  9324. /**
  9325. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9326. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9327. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9328. */
  9329. getShadowDirection(faceIndex?: number): Vector3;
  9330. /**
  9331. * Returns the ShadowLight absolute position in the World.
  9332. * @returns the position vector in world space
  9333. */
  9334. getAbsolutePosition(): Vector3;
  9335. /**
  9336. * Sets the ShadowLight direction toward the passed target.
  9337. * @param target The point to target in local space
  9338. * @returns the updated ShadowLight direction
  9339. */
  9340. setDirectionToTarget(target: Vector3): Vector3;
  9341. /**
  9342. * Returns the light rotation in euler definition.
  9343. * @returns the x y z rotation in local space.
  9344. */
  9345. getRotation(): Vector3;
  9346. /**
  9347. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9348. * @returns true if a cube texture needs to be use
  9349. */
  9350. needCube(): boolean;
  9351. /**
  9352. * Detects if the projection matrix requires to be recomputed this frame.
  9353. * @returns true if it requires to be recomputed otherwise, false.
  9354. */
  9355. needProjectionMatrixCompute(): boolean;
  9356. /**
  9357. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9358. */
  9359. forceProjectionMatrixCompute(): void;
  9360. /** @hidden */
  9361. _initCache(): void;
  9362. /** @hidden */
  9363. _isSynchronized(): boolean;
  9364. /**
  9365. * Computes the world matrix of the node
  9366. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9367. * @returns the world matrix
  9368. */
  9369. computeWorldMatrix(force?: boolean): Matrix;
  9370. /**
  9371. * Gets the minZ used for shadow according to both the scene and the light.
  9372. * @param activeCamera The camera we are returning the min for
  9373. * @returns the depth min z
  9374. */
  9375. getDepthMinZ(activeCamera: Camera): number;
  9376. /**
  9377. * Gets the maxZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the max for
  9379. * @returns the depth max z
  9380. */
  9381. getDepthMaxZ(activeCamera: Camera): number;
  9382. /**
  9383. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9384. * @param matrix The materix to updated with the projection information
  9385. * @param viewMatrix The transform matrix of the light
  9386. * @param renderList The list of mesh to render in the map
  9387. * @returns The current light
  9388. */
  9389. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9390. }
  9391. }
  9392. declare module "babylonjs/Materials/materialHelper" {
  9393. import { Nullable } from "babylonjs/types";
  9394. import { Scene } from "babylonjs/scene";
  9395. import { Engine } from "babylonjs/Engines/engine";
  9396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9397. import { Light } from "babylonjs/Lights/light";
  9398. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9399. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9401. /**
  9402. * "Static Class" containing the most commonly used helper while dealing with material for
  9403. * rendering purpose.
  9404. *
  9405. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9406. *
  9407. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9408. */
  9409. export class MaterialHelper {
  9410. /**
  9411. * Bind the current view position to an effect.
  9412. * @param effect The effect to be bound
  9413. * @param scene The scene the eyes position is used from
  9414. */
  9415. static BindEyePosition(effect: Effect, scene: Scene): void;
  9416. /**
  9417. * Helps preparing the defines values about the UVs in used in the effect.
  9418. * UVs are shared as much as we can accross channels in the shaders.
  9419. * @param texture The texture we are preparing the UVs for
  9420. * @param defines The defines to update
  9421. * @param key The channel key "diffuse", "specular"... used in the shader
  9422. */
  9423. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9424. /**
  9425. * Binds a texture matrix value to its corrsponding uniform
  9426. * @param texture The texture to bind the matrix for
  9427. * @param uniformBuffer The uniform buffer receivin the data
  9428. * @param key The channel key "diffuse", "specular"... used in the shader
  9429. */
  9430. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9431. /**
  9432. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9433. * @param mesh defines the current mesh
  9434. * @param scene defines the current scene
  9435. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9436. * @param pointsCloud defines if point cloud rendering has to be turned on
  9437. * @param fogEnabled defines if fog has to be turned on
  9438. * @param alphaTest defines if alpha testing has to be turned on
  9439. * @param defines defines the current list of defines
  9440. */
  9441. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9442. /**
  9443. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9444. * @param scene defines the current scene
  9445. * @param engine defines the current engine
  9446. * @param defines specifies the list of active defines
  9447. * @param useInstances defines if instances have to be turned on
  9448. * @param useClipPlane defines if clip plane have to be turned on
  9449. */
  9450. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9451. /**
  9452. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9453. * @param mesh The mesh containing the geometry data we will draw
  9454. * @param defines The defines to update
  9455. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9456. * @param useBones Precise whether bones should be used or not (override mesh info)
  9457. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9458. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9459. * @returns false if defines are considered not dirty and have not been checked
  9460. */
  9461. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9462. /**
  9463. * Prepares the defines related to multiview
  9464. * @param scene The scene we are intending to draw
  9465. * @param defines The defines to update
  9466. */
  9467. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9468. /**
  9469. * Prepares the defines related to the light information passed in parameter
  9470. * @param scene The scene we are intending to draw
  9471. * @param mesh The mesh the effect is compiling for
  9472. * @param defines The defines to update
  9473. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9474. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9475. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9476. * @returns true if normals will be required for the rest of the effect
  9477. */
  9478. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9479. /**
  9480. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9481. * that won t be acctive due to defines being turned off.
  9482. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9483. * @param samplersList The samplers list
  9484. * @param defines The defines helping in the list generation
  9485. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9486. */
  9487. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9488. /**
  9489. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9490. * @param defines The defines to update while falling back
  9491. * @param fallbacks The authorized effect fallbacks
  9492. * @param maxSimultaneousLights The maximum number of lights allowed
  9493. * @param rank the current rank of the Effect
  9494. * @returns The newly affected rank
  9495. */
  9496. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9497. /**
  9498. * Prepares the list of attributes required for morph targets according to the effect defines.
  9499. * @param attribs The current list of supported attribs
  9500. * @param mesh The mesh to prepare the morph targets attributes for
  9501. * @param defines The current Defines of the effect
  9502. */
  9503. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9504. /**
  9505. * Prepares the list of attributes required for bones according to the effect defines.
  9506. * @param attribs The current list of supported attribs
  9507. * @param mesh The mesh to prepare the bones attributes for
  9508. * @param defines The current Defines of the effect
  9509. * @param fallbacks The current efffect fallback strategy
  9510. */
  9511. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9512. /**
  9513. * Prepares the list of attributes required for instances according to the effect defines.
  9514. * @param attribs The current list of supported attribs
  9515. * @param defines The current Defines of the effect
  9516. */
  9517. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9518. /**
  9519. * Binds the light shadow information to the effect for the given mesh.
  9520. * @param light The light containing the generator
  9521. * @param scene The scene the lights belongs to
  9522. * @param mesh The mesh we are binding the information to render
  9523. * @param lightIndex The light index in the effect used to render the mesh
  9524. * @param effect The effect we are binding the data to
  9525. */
  9526. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9527. /**
  9528. * Binds the light information to the effect.
  9529. * @param light The light containing the generator
  9530. * @param effect The effect we are binding the data to
  9531. * @param lightIndex The light index in the effect used to render
  9532. */
  9533. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9534. /**
  9535. * Binds the lights information from the scene to the effect for the given mesh.
  9536. * @param scene The scene the lights belongs to
  9537. * @param mesh The mesh we are binding the information to render
  9538. * @param effect The effect we are binding the data to
  9539. * @param defines The generated defines for the effect
  9540. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9541. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9542. */
  9543. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9544. private static _tempFogColor;
  9545. /**
  9546. * Binds the fog information from the scene to the effect for the given mesh.
  9547. * @param scene The scene the lights belongs to
  9548. * @param mesh The mesh we are binding the information to render
  9549. * @param effect The effect we are binding the data to
  9550. * @param linearSpace Defines if the fog effect is applied in linear space
  9551. */
  9552. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9553. /**
  9554. * Binds the bones information from the mesh to the effect.
  9555. * @param mesh The mesh we are binding the information to render
  9556. * @param effect The effect we are binding the data to
  9557. */
  9558. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9559. /**
  9560. * Binds the morph targets information from the mesh to the effect.
  9561. * @param abstractMesh The mesh we are binding the information to render
  9562. * @param effect The effect we are binding the data to
  9563. */
  9564. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9565. /**
  9566. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9567. * @param defines The generated defines used in the effect
  9568. * @param effect The effect we are binding the data to
  9569. * @param scene The scene we are willing to render with logarithmic scale for
  9570. */
  9571. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9572. /**
  9573. * Binds the clip plane information from the scene to the effect.
  9574. * @param scene The scene the clip plane information are extracted from
  9575. * @param effect The effect we are binding the data to
  9576. */
  9577. static BindClipPlane(effect: Effect, scene: Scene): void;
  9578. }
  9579. }
  9580. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9581. /** @hidden */
  9582. export var kernelBlurVaryingDeclaration: {
  9583. name: string;
  9584. shader: string;
  9585. };
  9586. }
  9587. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9588. /** @hidden */
  9589. export var kernelBlurFragment: {
  9590. name: string;
  9591. shader: string;
  9592. };
  9593. }
  9594. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9595. /** @hidden */
  9596. export var kernelBlurFragment2: {
  9597. name: string;
  9598. shader: string;
  9599. };
  9600. }
  9601. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9602. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9603. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9604. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9605. /** @hidden */
  9606. export var kernelBlurPixelShader: {
  9607. name: string;
  9608. shader: string;
  9609. };
  9610. }
  9611. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9612. /** @hidden */
  9613. export var kernelBlurVertex: {
  9614. name: string;
  9615. shader: string;
  9616. };
  9617. }
  9618. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9619. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9620. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9621. /** @hidden */
  9622. export var kernelBlurVertexShader: {
  9623. name: string;
  9624. shader: string;
  9625. };
  9626. }
  9627. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9628. import { Vector2 } from "babylonjs/Maths/math";
  9629. import { Nullable } from "babylonjs/types";
  9630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9631. import { Camera } from "babylonjs/Cameras/camera";
  9632. import { Effect } from "babylonjs/Materials/effect";
  9633. import { Engine } from "babylonjs/Engines/engine";
  9634. import "babylonjs/Shaders/kernelBlur.fragment";
  9635. import "babylonjs/Shaders/kernelBlur.vertex";
  9636. /**
  9637. * The Blur Post Process which blurs an image based on a kernel and direction.
  9638. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9639. */
  9640. export class BlurPostProcess extends PostProcess {
  9641. /** The direction in which to blur the image. */
  9642. direction: Vector2;
  9643. private blockCompilation;
  9644. protected _kernel: number;
  9645. protected _idealKernel: number;
  9646. protected _packedFloat: boolean;
  9647. private _staticDefines;
  9648. /**
  9649. * Sets the length in pixels of the blur sample region
  9650. */
  9651. /**
  9652. * Gets the length in pixels of the blur sample region
  9653. */
  9654. kernel: number;
  9655. /**
  9656. * Sets wether or not the blur needs to unpack/repack floats
  9657. */
  9658. /**
  9659. * Gets wether or not the blur is unpacking/repacking floats
  9660. */
  9661. packedFloat: boolean;
  9662. /**
  9663. * Creates a new instance BlurPostProcess
  9664. * @param name The name of the effect.
  9665. * @param direction The direction in which to blur the image.
  9666. * @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.
  9667. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9668. * @param camera The camera to apply the render pass to.
  9669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9670. * @param engine The engine which the post process will be applied. (default: current engine)
  9671. * @param reusable If the post process can be reused on the same frame. (default: false)
  9672. * @param textureType Type of textures used when performing the post process. (default: 0)
  9673. * @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)
  9674. */
  9675. constructor(name: string,
  9676. /** The direction in which to blur the image. */
  9677. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9678. /**
  9679. * Updates the effect with the current post process compile time values and recompiles the shader.
  9680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9683. * @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
  9684. * @param onCompiled Called when the shader has been compiled.
  9685. * @param onError Called if there is an error when compiling a shader.
  9686. */
  9687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9688. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9689. /**
  9690. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9691. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9692. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9693. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9694. * The gaps between physical kernels are compensated for in the weighting of the samples
  9695. * @param idealKernel Ideal blur kernel.
  9696. * @return Nearest best kernel.
  9697. */
  9698. protected _nearestBestKernel(idealKernel: number): number;
  9699. /**
  9700. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9701. * @param x The point on the Gaussian distribution to sample.
  9702. * @return the value of the Gaussian function at x.
  9703. */
  9704. protected _gaussianWeight(x: number): number;
  9705. /**
  9706. * Generates a string that can be used as a floating point number in GLSL.
  9707. * @param x Value to print.
  9708. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9709. * @return GLSL float string.
  9710. */
  9711. protected _glslFloat(x: number, decimalFigures?: number): string;
  9712. }
  9713. }
  9714. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9715. /** @hidden */
  9716. export var shadowMapPixelShader: {
  9717. name: string;
  9718. shader: string;
  9719. };
  9720. }
  9721. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9722. /** @hidden */
  9723. export var bonesDeclaration: {
  9724. name: string;
  9725. shader: string;
  9726. };
  9727. }
  9728. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9729. /** @hidden */
  9730. export var morphTargetsVertexGlobalDeclaration: {
  9731. name: string;
  9732. shader: string;
  9733. };
  9734. }
  9735. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9736. /** @hidden */
  9737. export var morphTargetsVertexDeclaration: {
  9738. name: string;
  9739. shader: string;
  9740. };
  9741. }
  9742. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9743. /** @hidden */
  9744. export var instancesDeclaration: {
  9745. name: string;
  9746. shader: string;
  9747. };
  9748. }
  9749. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9750. /** @hidden */
  9751. export var helperFunctions: {
  9752. name: string;
  9753. shader: string;
  9754. };
  9755. }
  9756. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9757. /** @hidden */
  9758. export var morphTargetsVertex: {
  9759. name: string;
  9760. shader: string;
  9761. };
  9762. }
  9763. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9764. /** @hidden */
  9765. export var instancesVertex: {
  9766. name: string;
  9767. shader: string;
  9768. };
  9769. }
  9770. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9771. /** @hidden */
  9772. export var bonesVertex: {
  9773. name: string;
  9774. shader: string;
  9775. };
  9776. }
  9777. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9778. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9780. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9781. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9782. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9784. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9785. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9786. /** @hidden */
  9787. export var shadowMapVertexShader: {
  9788. name: string;
  9789. shader: string;
  9790. };
  9791. }
  9792. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9793. /** @hidden */
  9794. export var depthBoxBlurPixelShader: {
  9795. name: string;
  9796. shader: string;
  9797. };
  9798. }
  9799. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9800. import { Nullable } from "babylonjs/types";
  9801. import { Scene } from "babylonjs/scene";
  9802. import { Matrix } from "babylonjs/Maths/math";
  9803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9805. import { Mesh } from "babylonjs/Meshes/mesh";
  9806. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9807. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9808. import { Effect } from "babylonjs/Materials/effect";
  9809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9810. import "babylonjs/Shaders/shadowMap.fragment";
  9811. import "babylonjs/Shaders/shadowMap.vertex";
  9812. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9813. import { Observable } from "babylonjs/Misc/observable";
  9814. /**
  9815. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9816. */
  9817. export interface ICustomShaderOptions {
  9818. /**
  9819. * Gets or sets the custom shader name to use
  9820. */
  9821. shaderName: string;
  9822. /**
  9823. * The list of attribute names used in the shader
  9824. */
  9825. attributes?: string[];
  9826. /**
  9827. * The list of unifrom names used in the shader
  9828. */
  9829. uniforms?: string[];
  9830. /**
  9831. * The list of sampler names used in the shader
  9832. */
  9833. samplers?: string[];
  9834. /**
  9835. * The list of defines used in the shader
  9836. */
  9837. defines?: string[];
  9838. }
  9839. /**
  9840. * Interface to implement to create a shadow generator compatible with BJS.
  9841. */
  9842. export interface IShadowGenerator {
  9843. /**
  9844. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9845. * @returns The render target texture if present otherwise, null
  9846. */
  9847. getShadowMap(): Nullable<RenderTargetTexture>;
  9848. /**
  9849. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9850. * @returns The render target texture if the shadow map is present otherwise, null
  9851. */
  9852. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9853. /**
  9854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9855. * @param subMesh The submesh we want to render in the shadow map
  9856. * @param useInstances Defines wether will draw in the map using instances
  9857. * @returns true if ready otherwise, false
  9858. */
  9859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9860. /**
  9861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9862. * @param defines Defines of the material we want to update
  9863. * @param lightIndex Index of the light in the enabled light list of the material
  9864. */
  9865. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9866. /**
  9867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9868. * defined in the generator but impacting the effect).
  9869. * It implies the unifroms available on the materials are the standard BJS ones.
  9870. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9871. * @param effect The effect we are binfing the information for
  9872. */
  9873. bindShadowLight(lightIndex: string, effect: Effect): void;
  9874. /**
  9875. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9876. * (eq to shadow prjection matrix * light transform matrix)
  9877. * @returns The transform matrix used to create the shadow map
  9878. */
  9879. getTransformMatrix(): Matrix;
  9880. /**
  9881. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9882. * Cube and 2D textures for instance.
  9883. */
  9884. recreateShadowMap(): void;
  9885. /**
  9886. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9887. * @param onCompiled Callback triggered at the and of the effects compilation
  9888. * @param options Sets of optional options forcing the compilation with different modes
  9889. */
  9890. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9891. useInstances: boolean;
  9892. }>): void;
  9893. /**
  9894. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9895. * @param options Sets of optional options forcing the compilation with different modes
  9896. * @returns A promise that resolves when the compilation completes
  9897. */
  9898. forceCompilationAsync(options?: Partial<{
  9899. useInstances: boolean;
  9900. }>): Promise<void>;
  9901. /**
  9902. * Serializes the shadow generator setup to a json object.
  9903. * @returns The serialized JSON object
  9904. */
  9905. serialize(): any;
  9906. /**
  9907. * Disposes the Shadow map and related Textures and effects.
  9908. */
  9909. dispose(): void;
  9910. }
  9911. /**
  9912. * Default implementation IShadowGenerator.
  9913. * This is the main object responsible of generating shadows in the framework.
  9914. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9915. */
  9916. export class ShadowGenerator implements IShadowGenerator {
  9917. /**
  9918. * Shadow generator mode None: no filtering applied.
  9919. */
  9920. static readonly FILTER_NONE: number;
  9921. /**
  9922. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9924. */
  9925. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9926. /**
  9927. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9928. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9929. */
  9930. static readonly FILTER_POISSONSAMPLING: number;
  9931. /**
  9932. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9933. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9934. */
  9935. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9936. /**
  9937. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9938. * edge artifacts on steep falloff.
  9939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9940. */
  9941. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9942. /**
  9943. * Shadow generator mode ESM: Blurred 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_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9948. /**
  9949. * Shadow generator mode PCF: Percentage Closer Filtering
  9950. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9951. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9952. */
  9953. static readonly FILTER_PCF: number;
  9954. /**
  9955. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9956. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9957. * Contact Hardening
  9958. */
  9959. static readonly FILTER_PCSS: number;
  9960. /**
  9961. * Reserved for PCF and PCSS
  9962. * Highest Quality.
  9963. *
  9964. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9965. *
  9966. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9967. */
  9968. static readonly QUALITY_HIGH: number;
  9969. /**
  9970. * Reserved for PCF and PCSS
  9971. * Good tradeoff for quality/perf cross devices
  9972. *
  9973. * Execute PCF on a 3*3 kernel.
  9974. *
  9975. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9976. */
  9977. static readonly QUALITY_MEDIUM: number;
  9978. /**
  9979. * Reserved for PCF and PCSS
  9980. * The lowest quality but the fastest.
  9981. *
  9982. * Execute PCF on a 1*1 kernel.
  9983. *
  9984. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9985. */
  9986. static readonly QUALITY_LOW: number;
  9987. /** Gets or sets the custom shader name to use */
  9988. customShaderOptions: ICustomShaderOptions;
  9989. /**
  9990. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9991. */
  9992. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9993. /**
  9994. * Observable triggered before a mesh is rendered in the shadow map.
  9995. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9996. */
  9997. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9998. private _bias;
  9999. /**
  10000. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10001. */
  10002. /**
  10003. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10004. */
  10005. bias: number;
  10006. private _normalBias;
  10007. /**
  10008. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10009. */
  10010. /**
  10011. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10012. */
  10013. normalBias: number;
  10014. private _blurBoxOffset;
  10015. /**
  10016. * Gets the blur box offset: offset applied during the blur pass.
  10017. * Only useful if useKernelBlur = false
  10018. */
  10019. /**
  10020. * Sets the blur box offset: offset applied during the blur pass.
  10021. * Only useful if useKernelBlur = false
  10022. */
  10023. blurBoxOffset: number;
  10024. private _blurScale;
  10025. /**
  10026. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10027. * 2 means half of the size.
  10028. */
  10029. /**
  10030. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10031. * 2 means half of the size.
  10032. */
  10033. blurScale: number;
  10034. private _blurKernel;
  10035. /**
  10036. * Gets the blur kernel: kernel size of the blur pass.
  10037. * Only useful if useKernelBlur = true
  10038. */
  10039. /**
  10040. * Sets the blur kernel: kernel size of the blur pass.
  10041. * Only useful if useKernelBlur = true
  10042. */
  10043. blurKernel: number;
  10044. private _useKernelBlur;
  10045. /**
  10046. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10047. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10048. */
  10049. /**
  10050. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10051. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10052. */
  10053. useKernelBlur: boolean;
  10054. private _depthScale;
  10055. /**
  10056. * Gets the depth scale used in ESM mode.
  10057. */
  10058. /**
  10059. * Sets the depth scale used in ESM mode.
  10060. * This can override the scale stored on the light.
  10061. */
  10062. depthScale: number;
  10063. private _filter;
  10064. /**
  10065. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10066. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10067. */
  10068. /**
  10069. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10071. */
  10072. filter: number;
  10073. /**
  10074. * Gets if the current filter is set to Poisson Sampling.
  10075. */
  10076. /**
  10077. * Sets the current filter to Poisson Sampling.
  10078. */
  10079. usePoissonSampling: boolean;
  10080. /**
  10081. * Gets if the current filter is set to ESM.
  10082. */
  10083. /**
  10084. * Sets the current filter is to ESM.
  10085. */
  10086. useExponentialShadowMap: boolean;
  10087. /**
  10088. * Gets if the current filter is set to filtered ESM.
  10089. */
  10090. /**
  10091. * Gets if the current filter is set to filtered ESM.
  10092. */
  10093. useBlurExponentialShadowMap: boolean;
  10094. /**
  10095. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10096. * exponential to prevent steep falloff artifacts).
  10097. */
  10098. /**
  10099. * Sets the current filter to "close ESM" (using the inverse of the
  10100. * exponential to prevent steep falloff artifacts).
  10101. */
  10102. useCloseExponentialShadowMap: boolean;
  10103. /**
  10104. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10105. * exponential to prevent steep falloff artifacts).
  10106. */
  10107. /**
  10108. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10109. * exponential to prevent steep falloff artifacts).
  10110. */
  10111. useBlurCloseExponentialShadowMap: boolean;
  10112. /**
  10113. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10114. */
  10115. /**
  10116. * Sets the current filter to "PCF" (percentage closer filtering).
  10117. */
  10118. usePercentageCloserFiltering: boolean;
  10119. private _filteringQuality;
  10120. /**
  10121. * Gets the PCF or PCSS Quality.
  10122. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10123. */
  10124. /**
  10125. * Sets the PCF or PCSS Quality.
  10126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10127. */
  10128. filteringQuality: number;
  10129. /**
  10130. * Gets if the current filter is set to "PCSS" (contact hardening).
  10131. */
  10132. /**
  10133. * Sets the current filter to "PCSS" (contact hardening).
  10134. */
  10135. useContactHardeningShadow: boolean;
  10136. private _contactHardeningLightSizeUVRatio;
  10137. /**
  10138. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10139. * Using a ratio helps keeping shape stability independently of the map size.
  10140. *
  10141. * It does not account for the light projection as it was having too much
  10142. * instability during the light setup or during light position changes.
  10143. *
  10144. * Only valid if useContactHardeningShadow is true.
  10145. */
  10146. /**
  10147. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10148. * Using a ratio helps keeping shape stability independently of the map size.
  10149. *
  10150. * It does not account for the light projection as it was having too much
  10151. * instability during the light setup or during light position changes.
  10152. *
  10153. * Only valid if useContactHardeningShadow is true.
  10154. */
  10155. contactHardeningLightSizeUVRatio: number;
  10156. private _darkness;
  10157. /**
  10158. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10159. * 0 means strongest and 1 would means no shadow.
  10160. * @returns the darkness.
  10161. */
  10162. getDarkness(): number;
  10163. /**
  10164. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10165. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10166. * @returns the shadow generator allowing fluent coding.
  10167. */
  10168. setDarkness(darkness: number): ShadowGenerator;
  10169. private _transparencyShadow;
  10170. /**
  10171. * Sets the ability to have transparent shadow (boolean).
  10172. * @param transparent True if transparent else False
  10173. * @returns the shadow generator allowing fluent coding
  10174. */
  10175. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10176. private _shadowMap;
  10177. private _shadowMap2;
  10178. /**
  10179. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10180. * @returns The render target texture if present otherwise, null
  10181. */
  10182. getShadowMap(): Nullable<RenderTargetTexture>;
  10183. /**
  10184. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10185. * @returns The render target texture if the shadow map is present otherwise, null
  10186. */
  10187. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10188. /**
  10189. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10190. * @param mesh Mesh to add
  10191. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10192. * @returns the Shadow Generator itself
  10193. */
  10194. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10195. /**
  10196. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10197. * @param mesh Mesh to remove
  10198. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10199. * @returns the Shadow Generator itself
  10200. */
  10201. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10202. /**
  10203. * Controls the extent to which the shadows fade out at the edge of the frustum
  10204. * Used only by directionals and spots
  10205. */
  10206. frustumEdgeFalloff: number;
  10207. private _light;
  10208. /**
  10209. * Returns the associated light object.
  10210. * @returns the light generating the shadow
  10211. */
  10212. getLight(): IShadowLight;
  10213. /**
  10214. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10215. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10216. * It might on the other hand introduce peter panning.
  10217. */
  10218. forceBackFacesOnly: boolean;
  10219. private _scene;
  10220. private _lightDirection;
  10221. private _effect;
  10222. private _viewMatrix;
  10223. private _projectionMatrix;
  10224. private _transformMatrix;
  10225. private _cachedPosition;
  10226. private _cachedDirection;
  10227. private _cachedDefines;
  10228. private _currentRenderID;
  10229. private _boxBlurPostprocess;
  10230. private _kernelBlurXPostprocess;
  10231. private _kernelBlurYPostprocess;
  10232. private _blurPostProcesses;
  10233. private _mapSize;
  10234. private _currentFaceIndex;
  10235. private _currentFaceIndexCache;
  10236. private _textureType;
  10237. private _defaultTextureMatrix;
  10238. /** @hidden */
  10239. static _SceneComponentInitialization: (scene: Scene) => void;
  10240. /**
  10241. * Creates a ShadowGenerator object.
  10242. * A ShadowGenerator is the required tool to use the shadows.
  10243. * Each light casting shadows needs to use its own ShadowGenerator.
  10244. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10245. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10246. * @param light The light object generating the shadows.
  10247. * @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.
  10248. */
  10249. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10250. private _initializeGenerator;
  10251. private _initializeShadowMap;
  10252. private _initializeBlurRTTAndPostProcesses;
  10253. private _renderForShadowMap;
  10254. private _renderSubMeshForShadowMap;
  10255. private _applyFilterValues;
  10256. /**
  10257. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10258. * @param onCompiled Callback triggered at the and of the effects compilation
  10259. * @param options Sets of optional options forcing the compilation with different modes
  10260. */
  10261. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10262. useInstances: boolean;
  10263. }>): void;
  10264. /**
  10265. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10266. * @param options Sets of optional options forcing the compilation with different modes
  10267. * @returns A promise that resolves when the compilation completes
  10268. */
  10269. forceCompilationAsync(options?: Partial<{
  10270. useInstances: boolean;
  10271. }>): Promise<void>;
  10272. /**
  10273. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10274. * @param subMesh The submesh we want to render in the shadow map
  10275. * @param useInstances Defines wether will draw in the map using instances
  10276. * @returns true if ready otherwise, false
  10277. */
  10278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10279. /**
  10280. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10281. * @param defines Defines of the material we want to update
  10282. * @param lightIndex Index of the light in the enabled light list of the material
  10283. */
  10284. prepareDefines(defines: any, lightIndex: number): void;
  10285. /**
  10286. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10287. * defined in the generator but impacting the effect).
  10288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10289. * @param effect The effect we are binfing the information for
  10290. */
  10291. bindShadowLight(lightIndex: string, effect: Effect): void;
  10292. /**
  10293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10294. * (eq to shadow prjection matrix * light transform matrix)
  10295. * @returns The transform matrix used to create the shadow map
  10296. */
  10297. getTransformMatrix(): Matrix;
  10298. /**
  10299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10300. * Cube and 2D textures for instance.
  10301. */
  10302. recreateShadowMap(): void;
  10303. private _disposeBlurPostProcesses;
  10304. private _disposeRTTandPostProcesses;
  10305. /**
  10306. * Disposes the ShadowGenerator.
  10307. * Returns nothing.
  10308. */
  10309. dispose(): void;
  10310. /**
  10311. * Serializes the shadow generator setup to a json object.
  10312. * @returns The serialized JSON object
  10313. */
  10314. serialize(): any;
  10315. /**
  10316. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10317. * @param parsedShadowGenerator The JSON object to parse
  10318. * @param scene The scene to create the shadow map for
  10319. * @returns The parsed shadow generator
  10320. */
  10321. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10322. }
  10323. }
  10324. declare module "babylonjs/Lights/light" {
  10325. import { Nullable } from "babylonjs/types";
  10326. import { Scene } from "babylonjs/scene";
  10327. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10328. import { Node } from "babylonjs/node";
  10329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10330. import { Effect } from "babylonjs/Materials/effect";
  10331. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10332. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10333. /**
  10334. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10335. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10336. * 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.
  10337. */
  10338. export abstract class Light extends Node {
  10339. /**
  10340. * Falloff Default: light is falling off following the material specification:
  10341. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10342. */
  10343. static readonly FALLOFF_DEFAULT: number;
  10344. /**
  10345. * Falloff Physical: light is falling off following the inverse squared distance law.
  10346. */
  10347. static readonly FALLOFF_PHYSICAL: number;
  10348. /**
  10349. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10350. * to enhance interoperability with other engines.
  10351. */
  10352. static readonly FALLOFF_GLTF: number;
  10353. /**
  10354. * Falloff Standard: light is falling off like in the standard material
  10355. * to enhance interoperability with other materials.
  10356. */
  10357. static readonly FALLOFF_STANDARD: number;
  10358. /**
  10359. * If every light affecting the material is in this lightmapMode,
  10360. * material.lightmapTexture adds or multiplies
  10361. * (depends on material.useLightmapAsShadowmap)
  10362. * after every other light calculations.
  10363. */
  10364. static readonly LIGHTMAP_DEFAULT: number;
  10365. /**
  10366. * material.lightmapTexture as only diffuse lighting from this light
  10367. * adds only specular lighting from this light
  10368. * adds dynamic shadows
  10369. */
  10370. static readonly LIGHTMAP_SPECULAR: number;
  10371. /**
  10372. * material.lightmapTexture as only lighting
  10373. * no light calculation from this light
  10374. * only adds dynamic shadows from this light
  10375. */
  10376. static readonly LIGHTMAP_SHADOWSONLY: number;
  10377. /**
  10378. * Each light type uses the default quantity according to its type:
  10379. * point/spot lights use luminous intensity
  10380. * directional lights use illuminance
  10381. */
  10382. static readonly INTENSITYMODE_AUTOMATIC: number;
  10383. /**
  10384. * lumen (lm)
  10385. */
  10386. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10387. /**
  10388. * candela (lm/sr)
  10389. */
  10390. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10391. /**
  10392. * lux (lm/m^2)
  10393. */
  10394. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10395. /**
  10396. * nit (cd/m^2)
  10397. */
  10398. static readonly INTENSITYMODE_LUMINANCE: number;
  10399. /**
  10400. * Light type const id of the point light.
  10401. */
  10402. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10403. /**
  10404. * Light type const id of the directional light.
  10405. */
  10406. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10407. /**
  10408. * Light type const id of the spot light.
  10409. */
  10410. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10411. /**
  10412. * Light type const id of the hemispheric light.
  10413. */
  10414. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10415. /**
  10416. * Diffuse gives the basic color to an object.
  10417. */
  10418. diffuse: Color3;
  10419. /**
  10420. * Specular produces a highlight color on an object.
  10421. * Note: This is note affecting PBR materials.
  10422. */
  10423. specular: Color3;
  10424. /**
  10425. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10426. * falling off base on range or angle.
  10427. * This can be set to any values in Light.FALLOFF_x.
  10428. *
  10429. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10430. * other types of materials.
  10431. */
  10432. falloffType: number;
  10433. /**
  10434. * Strength of the light.
  10435. * Note: By default it is define in the framework own unit.
  10436. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10437. */
  10438. intensity: number;
  10439. private _range;
  10440. protected _inverseSquaredRange: number;
  10441. /**
  10442. * Defines how far from the source the light is impacting in scene units.
  10443. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10444. */
  10445. /**
  10446. * Defines how far from the source the light is impacting in scene units.
  10447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10448. */
  10449. range: number;
  10450. /**
  10451. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10452. * of light.
  10453. */
  10454. private _photometricScale;
  10455. private _intensityMode;
  10456. /**
  10457. * Gets the photometric scale used to interpret the intensity.
  10458. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10459. */
  10460. /**
  10461. * Sets the photometric scale used to interpret the intensity.
  10462. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10463. */
  10464. intensityMode: number;
  10465. private _radius;
  10466. /**
  10467. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10468. */
  10469. /**
  10470. * sets the light radius used by PBR Materials to simulate soft area lights.
  10471. */
  10472. radius: number;
  10473. private _renderPriority;
  10474. /**
  10475. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10476. * exceeding the number allowed of the materials.
  10477. */
  10478. renderPriority: number;
  10479. private _shadowEnabled;
  10480. /**
  10481. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10482. * the current shadow generator.
  10483. */
  10484. /**
  10485. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10486. * the current shadow generator.
  10487. */
  10488. shadowEnabled: boolean;
  10489. private _includedOnlyMeshes;
  10490. /**
  10491. * Gets the only meshes impacted by this light.
  10492. */
  10493. /**
  10494. * Sets the only meshes impacted by this light.
  10495. */
  10496. includedOnlyMeshes: AbstractMesh[];
  10497. private _excludedMeshes;
  10498. /**
  10499. * Gets the meshes not impacted by this light.
  10500. */
  10501. /**
  10502. * Sets the meshes not impacted by this light.
  10503. */
  10504. excludedMeshes: AbstractMesh[];
  10505. private _excludeWithLayerMask;
  10506. /**
  10507. * Gets the layer id use to find what meshes are not impacted by the light.
  10508. * Inactive if 0
  10509. */
  10510. /**
  10511. * Sets the layer id use to find what meshes are not impacted by the light.
  10512. * Inactive if 0
  10513. */
  10514. excludeWithLayerMask: number;
  10515. private _includeOnlyWithLayerMask;
  10516. /**
  10517. * Gets the layer id use to find what meshes are impacted by the light.
  10518. * Inactive if 0
  10519. */
  10520. /**
  10521. * Sets the layer id use to find what meshes are impacted by the light.
  10522. * Inactive if 0
  10523. */
  10524. includeOnlyWithLayerMask: number;
  10525. private _lightmapMode;
  10526. /**
  10527. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10528. */
  10529. /**
  10530. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10531. */
  10532. lightmapMode: number;
  10533. /**
  10534. * Shadow generator associted to the light.
  10535. * @hidden Internal use only.
  10536. */
  10537. _shadowGenerator: Nullable<IShadowGenerator>;
  10538. /**
  10539. * @hidden Internal use only.
  10540. */
  10541. _excludedMeshesIds: string[];
  10542. /**
  10543. * @hidden Internal use only.
  10544. */
  10545. _includedOnlyMeshesIds: string[];
  10546. /**
  10547. * The current light unifom buffer.
  10548. * @hidden Internal use only.
  10549. */
  10550. _uniformBuffer: UniformBuffer;
  10551. /**
  10552. * Creates a Light object in the scene.
  10553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10554. * @param name The firendly name of the light
  10555. * @param scene The scene the light belongs too
  10556. */
  10557. constructor(name: string, scene: Scene);
  10558. protected abstract _buildUniformLayout(): void;
  10559. /**
  10560. * Sets the passed Effect "effect" with the Light information.
  10561. * @param effect The effect to update
  10562. * @param lightIndex The index of the light in the effect to update
  10563. * @returns The light
  10564. */
  10565. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10566. /**
  10567. * Returns the string "Light".
  10568. * @returns the class name
  10569. */
  10570. getClassName(): string;
  10571. /** @hidden */
  10572. readonly _isLight: boolean;
  10573. /**
  10574. * Converts the light information to a readable string for debug purpose.
  10575. * @param fullDetails Supports for multiple levels of logging within scene loading
  10576. * @returns the human readable light info
  10577. */
  10578. toString(fullDetails?: boolean): string;
  10579. /** @hidden */
  10580. protected _syncParentEnabledState(): void;
  10581. /**
  10582. * Set the enabled state of this node.
  10583. * @param value - the new enabled state
  10584. */
  10585. setEnabled(value: boolean): void;
  10586. /**
  10587. * Returns the Light associated shadow generator if any.
  10588. * @return the associated shadow generator.
  10589. */
  10590. getShadowGenerator(): Nullable<IShadowGenerator>;
  10591. /**
  10592. * Returns a Vector3, the absolute light position in the World.
  10593. * @returns the world space position of the light
  10594. */
  10595. getAbsolutePosition(): Vector3;
  10596. /**
  10597. * Specifies if the light will affect the passed mesh.
  10598. * @param mesh The mesh to test against the light
  10599. * @return true the mesh is affected otherwise, false.
  10600. */
  10601. canAffectMesh(mesh: AbstractMesh): boolean;
  10602. /**
  10603. * Sort function to order lights for rendering.
  10604. * @param a First Light object to compare to second.
  10605. * @param b Second Light object to compare first.
  10606. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10607. */
  10608. static CompareLightsPriority(a: Light, b: Light): number;
  10609. /**
  10610. * Releases resources associated with this node.
  10611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10613. */
  10614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10615. /**
  10616. * Returns the light type ID (integer).
  10617. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10618. */
  10619. getTypeID(): number;
  10620. /**
  10621. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10622. * @returns the scaled intensity in intensity mode unit
  10623. */
  10624. getScaledIntensity(): number;
  10625. /**
  10626. * Returns a new Light object, named "name", from the current one.
  10627. * @param name The name of the cloned light
  10628. * @returns the new created light
  10629. */
  10630. clone(name: string): Nullable<Light>;
  10631. /**
  10632. * Serializes the current light into a Serialization object.
  10633. * @returns the serialized object.
  10634. */
  10635. serialize(): any;
  10636. /**
  10637. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10638. * This new light is named "name" and added to the passed scene.
  10639. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10640. * @param name The friendly name of the light
  10641. * @param scene The scene the new light will belong to
  10642. * @returns the constructor function
  10643. */
  10644. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10645. /**
  10646. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10647. * @param parsedLight The JSON representation of the light
  10648. * @param scene The scene to create the parsed light in
  10649. * @returns the created light after parsing
  10650. */
  10651. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10652. private _hookArrayForExcluded;
  10653. private _hookArrayForIncludedOnly;
  10654. private _resyncMeshes;
  10655. /**
  10656. * Forces the meshes to update their light related information in their rendering used effects
  10657. * @hidden Internal Use Only
  10658. */
  10659. _markMeshesAsLightDirty(): void;
  10660. /**
  10661. * Recomputes the cached photometric scale if needed.
  10662. */
  10663. private _computePhotometricScale;
  10664. /**
  10665. * Returns the Photometric Scale according to the light type and intensity mode.
  10666. */
  10667. private _getPhotometricScale;
  10668. /**
  10669. * Reorder the light in the scene according to their defined priority.
  10670. * @hidden Internal Use Only
  10671. */
  10672. _reorderLightsInScene(): void;
  10673. /**
  10674. * Prepares the list of defines specific to the light type.
  10675. * @param defines the list of defines
  10676. * @param lightIndex defines the index of the light for the effect
  10677. */
  10678. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10679. }
  10680. }
  10681. declare module "babylonjs/Actions/action" {
  10682. import { Observable } from "babylonjs/Misc/observable";
  10683. import { Condition } from "babylonjs/Actions/condition";
  10684. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10685. import { ActionManager } from "babylonjs/Actions/actionManager";
  10686. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10687. /**
  10688. * Interface used to define Action
  10689. */
  10690. export interface IAction {
  10691. /**
  10692. * Trigger for the action
  10693. */
  10694. trigger: number;
  10695. /** Options of the trigger */
  10696. triggerOptions: any;
  10697. /**
  10698. * Gets the trigger parameters
  10699. * @returns the trigger parameters
  10700. */
  10701. getTriggerParameter(): any;
  10702. /**
  10703. * Internal only - executes current action event
  10704. * @hidden
  10705. */
  10706. _executeCurrent(evt?: ActionEvent): void;
  10707. /**
  10708. * Serialize placeholder for child classes
  10709. * @param parent of child
  10710. * @returns the serialized object
  10711. */
  10712. serialize(parent: any): any;
  10713. /**
  10714. * Internal only
  10715. * @hidden
  10716. */
  10717. _prepare(): void;
  10718. /**
  10719. * Internal only - manager for action
  10720. * @hidden
  10721. */
  10722. _actionManager: AbstractActionManager;
  10723. }
  10724. /**
  10725. * The action to be carried out following a trigger
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10727. */
  10728. export class Action implements IAction {
  10729. /** the trigger, with or without parameters, for the action */
  10730. triggerOptions: any;
  10731. /**
  10732. * Trigger for the action
  10733. */
  10734. trigger: number;
  10735. /**
  10736. * Internal only - manager for action
  10737. * @hidden
  10738. */
  10739. _actionManager: ActionManager;
  10740. private _nextActiveAction;
  10741. private _child;
  10742. private _condition?;
  10743. private _triggerParameter;
  10744. /**
  10745. * An event triggered prior to action being executed.
  10746. */
  10747. onBeforeExecuteObservable: Observable<Action>;
  10748. /**
  10749. * Creates a new Action
  10750. * @param triggerOptions the trigger, with or without parameters, for the action
  10751. * @param condition an optional determinant of action
  10752. */
  10753. constructor(
  10754. /** the trigger, with or without parameters, for the action */
  10755. triggerOptions: any, condition?: Condition);
  10756. /**
  10757. * Internal only
  10758. * @hidden
  10759. */
  10760. _prepare(): void;
  10761. /**
  10762. * Gets the trigger parameters
  10763. * @returns the trigger parameters
  10764. */
  10765. getTriggerParameter(): any;
  10766. /**
  10767. * Internal only - executes current action event
  10768. * @hidden
  10769. */
  10770. _executeCurrent(evt?: ActionEvent): void;
  10771. /**
  10772. * Execute placeholder for child classes
  10773. * @param evt optional action event
  10774. */
  10775. execute(evt?: ActionEvent): void;
  10776. /**
  10777. * Skips to next active action
  10778. */
  10779. skipToNextActiveAction(): void;
  10780. /**
  10781. * Adds action to chain of actions, may be a DoNothingAction
  10782. * @param action defines the next action to execute
  10783. * @returns The action passed in
  10784. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10785. */
  10786. then(action: Action): Action;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Internal only
  10794. * @hidden
  10795. */
  10796. _getEffectiveTarget(target: any, propertyPath: string): any;
  10797. /**
  10798. * Serialize placeholder for child classes
  10799. * @param parent of child
  10800. * @returns the serialized object
  10801. */
  10802. serialize(parent: any): any;
  10803. /**
  10804. * Internal only called by serialize
  10805. * @hidden
  10806. */
  10807. protected _serialize(serializedAction: any, parent?: any): any;
  10808. /**
  10809. * Internal only
  10810. * @hidden
  10811. */
  10812. static _SerializeValueAsString: (value: any) => string;
  10813. /**
  10814. * Internal only
  10815. * @hidden
  10816. */
  10817. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10818. name: string;
  10819. targetType: string;
  10820. value: string;
  10821. };
  10822. }
  10823. }
  10824. declare module "babylonjs/Actions/condition" {
  10825. import { ActionManager } from "babylonjs/Actions/actionManager";
  10826. /**
  10827. * A Condition applied to an Action
  10828. */
  10829. export class Condition {
  10830. /**
  10831. * Internal only - manager for action
  10832. * @hidden
  10833. */
  10834. _actionManager: ActionManager;
  10835. /**
  10836. * Internal only
  10837. * @hidden
  10838. */
  10839. _evaluationId: number;
  10840. /**
  10841. * Internal only
  10842. * @hidden
  10843. */
  10844. _currentResult: boolean;
  10845. /**
  10846. * Creates a new Condition
  10847. * @param actionManager the manager of the action the condition is applied to
  10848. */
  10849. constructor(actionManager: ActionManager);
  10850. /**
  10851. * Check if the current condition is valid
  10852. * @returns a boolean
  10853. */
  10854. isValid(): boolean;
  10855. /**
  10856. * Internal only
  10857. * @hidden
  10858. */
  10859. _getProperty(propertyPath: string): string;
  10860. /**
  10861. * Internal only
  10862. * @hidden
  10863. */
  10864. _getEffectiveTarget(target: any, propertyPath: string): any;
  10865. /**
  10866. * Serialize placeholder for child classes
  10867. * @returns the serialized object
  10868. */
  10869. serialize(): any;
  10870. /**
  10871. * Internal only
  10872. * @hidden
  10873. */
  10874. protected _serialize(serializedCondition: any): any;
  10875. }
  10876. /**
  10877. * Defines specific conditional operators as extensions of Condition
  10878. */
  10879. export class ValueCondition extends Condition {
  10880. /** path to specify the property of the target the conditional operator uses */
  10881. propertyPath: string;
  10882. /** the value compared by the conditional operator against the current value of the property */
  10883. value: any;
  10884. /** the conditional operator, default ValueCondition.IsEqual */
  10885. operator: number;
  10886. /**
  10887. * Internal only
  10888. * @hidden
  10889. */
  10890. private static _IsEqual;
  10891. /**
  10892. * Internal only
  10893. * @hidden
  10894. */
  10895. private static _IsDifferent;
  10896. /**
  10897. * Internal only
  10898. * @hidden
  10899. */
  10900. private static _IsGreater;
  10901. /**
  10902. * Internal only
  10903. * @hidden
  10904. */
  10905. private static _IsLesser;
  10906. /**
  10907. * returns the number for IsEqual
  10908. */
  10909. static readonly IsEqual: number;
  10910. /**
  10911. * Returns the number for IsDifferent
  10912. */
  10913. static readonly IsDifferent: number;
  10914. /**
  10915. * Returns the number for IsGreater
  10916. */
  10917. static readonly IsGreater: number;
  10918. /**
  10919. * Returns the number for IsLesser
  10920. */
  10921. static readonly IsLesser: number;
  10922. /**
  10923. * Internal only The action manager for the condition
  10924. * @hidden
  10925. */
  10926. _actionManager: ActionManager;
  10927. /**
  10928. * Internal only
  10929. * @hidden
  10930. */
  10931. private _target;
  10932. /**
  10933. * Internal only
  10934. * @hidden
  10935. */
  10936. private _effectiveTarget;
  10937. /**
  10938. * Internal only
  10939. * @hidden
  10940. */
  10941. private _property;
  10942. /**
  10943. * Creates a new ValueCondition
  10944. * @param actionManager manager for the action the condition applies to
  10945. * @param target for the action
  10946. * @param propertyPath path to specify the property of the target the conditional operator uses
  10947. * @param value the value compared by the conditional operator against the current value of the property
  10948. * @param operator the conditional operator, default ValueCondition.IsEqual
  10949. */
  10950. constructor(actionManager: ActionManager, target: any,
  10951. /** path to specify the property of the target the conditional operator uses */
  10952. propertyPath: string,
  10953. /** the value compared by the conditional operator against the current value of the property */
  10954. value: any,
  10955. /** the conditional operator, default ValueCondition.IsEqual */
  10956. operator?: number);
  10957. /**
  10958. * Compares the given value with the property value for the specified conditional operator
  10959. * @returns the result of the comparison
  10960. */
  10961. isValid(): boolean;
  10962. /**
  10963. * Serialize the ValueCondition into a JSON compatible object
  10964. * @returns serialization object
  10965. */
  10966. serialize(): any;
  10967. /**
  10968. * Gets the name of the conditional operator for the ValueCondition
  10969. * @param operator the conditional operator
  10970. * @returns the name
  10971. */
  10972. static GetOperatorName(operator: number): string;
  10973. }
  10974. /**
  10975. * Defines a predicate condition as an extension of Condition
  10976. */
  10977. export class PredicateCondition extends Condition {
  10978. /** defines the predicate function used to validate the condition */
  10979. predicate: () => boolean;
  10980. /**
  10981. * Internal only - manager for action
  10982. * @hidden
  10983. */
  10984. _actionManager: ActionManager;
  10985. /**
  10986. * Creates a new PredicateCondition
  10987. * @param actionManager manager for the action the condition applies to
  10988. * @param predicate defines the predicate function used to validate the condition
  10989. */
  10990. constructor(actionManager: ActionManager,
  10991. /** defines the predicate function used to validate the condition */
  10992. predicate: () => boolean);
  10993. /**
  10994. * @returns the validity of the predicate condition
  10995. */
  10996. isValid(): boolean;
  10997. }
  10998. /**
  10999. * Defines a state condition as an extension of Condition
  11000. */
  11001. export class StateCondition extends Condition {
  11002. /** Value to compare with target state */
  11003. value: string;
  11004. /**
  11005. * Internal only - manager for action
  11006. * @hidden
  11007. */
  11008. _actionManager: ActionManager;
  11009. /**
  11010. * Internal only
  11011. * @hidden
  11012. */
  11013. private _target;
  11014. /**
  11015. * Creates a new StateCondition
  11016. * @param actionManager manager for the action the condition applies to
  11017. * @param target of the condition
  11018. * @param value to compare with target state
  11019. */
  11020. constructor(actionManager: ActionManager, target: any,
  11021. /** Value to compare with target state */
  11022. value: string);
  11023. /**
  11024. * Gets a boolean indicating if the current condition is met
  11025. * @returns the validity of the state
  11026. */
  11027. isValid(): boolean;
  11028. /**
  11029. * Serialize the StateCondition into a JSON compatible object
  11030. * @returns serialization object
  11031. */
  11032. serialize(): any;
  11033. }
  11034. }
  11035. declare module "babylonjs/Actions/directActions" {
  11036. import { Action } from "babylonjs/Actions/action";
  11037. import { Condition } from "babylonjs/Actions/condition";
  11038. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11039. /**
  11040. * This defines an action responsible to toggle a boolean once triggered.
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11042. */
  11043. export class SwitchBooleanAction extends Action {
  11044. /**
  11045. * The path to the boolean property in the target object
  11046. */
  11047. propertyPath: string;
  11048. private _target;
  11049. private _effectiveTarget;
  11050. private _property;
  11051. /**
  11052. * Instantiate the action
  11053. * @param triggerOptions defines the trigger options
  11054. * @param target defines the object containing the boolean
  11055. * @param propertyPath defines the path to the boolean property in the target object
  11056. * @param condition defines the trigger related conditions
  11057. */
  11058. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11059. /** @hidden */
  11060. _prepare(): void;
  11061. /**
  11062. * Execute the action toggle the boolean value.
  11063. */
  11064. execute(): void;
  11065. /**
  11066. * Serializes the actions and its related information.
  11067. * @param parent defines the object to serialize in
  11068. * @returns the serialized object
  11069. */
  11070. serialize(parent: any): any;
  11071. }
  11072. /**
  11073. * This defines an action responsible to set a the state field of the target
  11074. * to a desired value once triggered.
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11076. */
  11077. export class SetStateAction extends Action {
  11078. /**
  11079. * The value to store in the state field.
  11080. */
  11081. value: string;
  11082. private _target;
  11083. /**
  11084. * Instantiate the action
  11085. * @param triggerOptions defines the trigger options
  11086. * @param target defines the object containing the state property
  11087. * @param value defines the value to store in the state field
  11088. * @param condition defines the trigger related conditions
  11089. */
  11090. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11091. /**
  11092. * Execute the action and store the value on the target state property.
  11093. */
  11094. execute(): void;
  11095. /**
  11096. * Serializes the actions and its related information.
  11097. * @param parent defines the object to serialize in
  11098. * @returns the serialized object
  11099. */
  11100. serialize(parent: any): any;
  11101. }
  11102. /**
  11103. * This defines an action responsible to set a property of the target
  11104. * to a desired value once triggered.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11106. */
  11107. export class SetValueAction extends Action {
  11108. /**
  11109. * The path of the property to set in the target.
  11110. */
  11111. propertyPath: string;
  11112. /**
  11113. * The value to set in the property
  11114. */
  11115. value: any;
  11116. private _target;
  11117. private _effectiveTarget;
  11118. private _property;
  11119. /**
  11120. * Instantiate the action
  11121. * @param triggerOptions defines the trigger options
  11122. * @param target defines the object containing the property
  11123. * @param propertyPath defines the path of the property to set in the target
  11124. * @param value defines the value to set in the property
  11125. * @param condition defines the trigger related conditions
  11126. */
  11127. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11128. /** @hidden */
  11129. _prepare(): void;
  11130. /**
  11131. * Execute the action and set the targetted property to the desired value.
  11132. */
  11133. execute(): void;
  11134. /**
  11135. * Serializes the actions and its related information.
  11136. * @param parent defines the object to serialize in
  11137. * @returns the serialized object
  11138. */
  11139. serialize(parent: any): any;
  11140. }
  11141. /**
  11142. * This defines an action responsible to increment the target value
  11143. * to a desired value once triggered.
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11145. */
  11146. export class IncrementValueAction extends Action {
  11147. /**
  11148. * The path of the property to increment in the target.
  11149. */
  11150. propertyPath: string;
  11151. /**
  11152. * The value we should increment the property by.
  11153. */
  11154. value: any;
  11155. private _target;
  11156. private _effectiveTarget;
  11157. private _property;
  11158. /**
  11159. * Instantiate the action
  11160. * @param triggerOptions defines the trigger options
  11161. * @param target defines the object containing the property
  11162. * @param propertyPath defines the path of the property to increment in the target
  11163. * @param value defines the value value we should increment the property by
  11164. * @param condition defines the trigger related conditions
  11165. */
  11166. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11167. /** @hidden */
  11168. _prepare(): void;
  11169. /**
  11170. * Execute the action and increment the target of the value amount.
  11171. */
  11172. execute(): void;
  11173. /**
  11174. * Serializes the actions and its related information.
  11175. * @param parent defines the object to serialize in
  11176. * @returns the serialized object
  11177. */
  11178. serialize(parent: any): any;
  11179. }
  11180. /**
  11181. * This defines an action responsible to start an animation once triggered.
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11183. */
  11184. export class PlayAnimationAction extends Action {
  11185. /**
  11186. * Where the animation should start (animation frame)
  11187. */
  11188. from: number;
  11189. /**
  11190. * Where the animation should stop (animation frame)
  11191. */
  11192. to: number;
  11193. /**
  11194. * Define if the animation should loop or stop after the first play.
  11195. */
  11196. loop?: boolean;
  11197. private _target;
  11198. /**
  11199. * Instantiate the action
  11200. * @param triggerOptions defines the trigger options
  11201. * @param target defines the target animation or animation name
  11202. * @param from defines from where the animation should start (animation frame)
  11203. * @param end defines where the animation should stop (animation frame)
  11204. * @param loop defines if the animation should loop or stop after the first play
  11205. * @param condition defines the trigger related conditions
  11206. */
  11207. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11208. /** @hidden */
  11209. _prepare(): void;
  11210. /**
  11211. * Execute the action and play the animation.
  11212. */
  11213. execute(): void;
  11214. /**
  11215. * Serializes the actions and its related information.
  11216. * @param parent defines the object to serialize in
  11217. * @returns the serialized object
  11218. */
  11219. serialize(parent: any): any;
  11220. }
  11221. /**
  11222. * This defines an action responsible to stop an animation once triggered.
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11224. */
  11225. export class StopAnimationAction extends Action {
  11226. private _target;
  11227. /**
  11228. * Instantiate the action
  11229. * @param triggerOptions defines the trigger options
  11230. * @param target defines the target animation or animation name
  11231. * @param condition defines the trigger related conditions
  11232. */
  11233. constructor(triggerOptions: any, target: any, condition?: Condition);
  11234. /** @hidden */
  11235. _prepare(): void;
  11236. /**
  11237. * Execute the action and stop the animation.
  11238. */
  11239. execute(): void;
  11240. /**
  11241. * Serializes the actions and its related information.
  11242. * @param parent defines the object to serialize in
  11243. * @returns the serialized object
  11244. */
  11245. serialize(parent: any): any;
  11246. }
  11247. /**
  11248. * This defines an action responsible that does nothing once triggered.
  11249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11250. */
  11251. export class DoNothingAction extends Action {
  11252. /**
  11253. * Instantiate the action
  11254. * @param triggerOptions defines the trigger options
  11255. * @param condition defines the trigger related conditions
  11256. */
  11257. constructor(triggerOptions?: any, condition?: Condition);
  11258. /**
  11259. * Execute the action and do nothing.
  11260. */
  11261. execute(): void;
  11262. /**
  11263. * Serializes the actions and its related information.
  11264. * @param parent defines the object to serialize in
  11265. * @returns the serialized object
  11266. */
  11267. serialize(parent: any): any;
  11268. }
  11269. /**
  11270. * This defines an action responsible to trigger several actions once triggered.
  11271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11272. */
  11273. export class CombineAction extends Action {
  11274. /**
  11275. * The list of aggregated animations to run.
  11276. */
  11277. children: Action[];
  11278. /**
  11279. * Instantiate the action
  11280. * @param triggerOptions defines the trigger options
  11281. * @param children defines the list of aggregated animations to run
  11282. * @param condition defines the trigger related conditions
  11283. */
  11284. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11285. /** @hidden */
  11286. _prepare(): void;
  11287. /**
  11288. * Execute the action and executes all the aggregated actions.
  11289. */
  11290. execute(evt: ActionEvent): void;
  11291. /**
  11292. * Serializes the actions and its related information.
  11293. * @param parent defines the object to serialize in
  11294. * @returns the serialized object
  11295. */
  11296. serialize(parent: any): any;
  11297. }
  11298. /**
  11299. * This defines an action responsible to run code (external event) once triggered.
  11300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11301. */
  11302. export class ExecuteCodeAction extends Action {
  11303. /**
  11304. * The callback function to run.
  11305. */
  11306. func: (evt: ActionEvent) => void;
  11307. /**
  11308. * Instantiate the action
  11309. * @param triggerOptions defines the trigger options
  11310. * @param func defines the callback function to run
  11311. * @param condition defines the trigger related conditions
  11312. */
  11313. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11314. /**
  11315. * Execute the action and run the attached code.
  11316. */
  11317. execute(evt: ActionEvent): void;
  11318. }
  11319. /**
  11320. * This defines an action responsible to set the parent property of the target once triggered.
  11321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11322. */
  11323. export class SetParentAction extends Action {
  11324. private _parent;
  11325. private _target;
  11326. /**
  11327. * Instantiate the action
  11328. * @param triggerOptions defines the trigger options
  11329. * @param target defines the target containing the parent property
  11330. * @param parent defines from where the animation should start (animation frame)
  11331. * @param condition defines the trigger related conditions
  11332. */
  11333. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11334. /** @hidden */
  11335. _prepare(): void;
  11336. /**
  11337. * Execute the action and set the parent property.
  11338. */
  11339. execute(): void;
  11340. /**
  11341. * Serializes the actions and its related information.
  11342. * @param parent defines the object to serialize in
  11343. * @returns the serialized object
  11344. */
  11345. serialize(parent: any): any;
  11346. }
  11347. }
  11348. declare module "babylonjs/Actions/actionManager" {
  11349. import { Nullable } from "babylonjs/types";
  11350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11351. import { Scene } from "babylonjs/scene";
  11352. import { IAction } from "babylonjs/Actions/action";
  11353. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11354. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11355. /**
  11356. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11357. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11359. */
  11360. export class ActionManager extends AbstractActionManager {
  11361. /**
  11362. * Nothing
  11363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11364. */
  11365. static readonly NothingTrigger: number;
  11366. /**
  11367. * On pick
  11368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11369. */
  11370. static readonly OnPickTrigger: number;
  11371. /**
  11372. * On left pick
  11373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11374. */
  11375. static readonly OnLeftPickTrigger: number;
  11376. /**
  11377. * On right pick
  11378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11379. */
  11380. static readonly OnRightPickTrigger: number;
  11381. /**
  11382. * On center pick
  11383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11384. */
  11385. static readonly OnCenterPickTrigger: number;
  11386. /**
  11387. * On pick down
  11388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11389. */
  11390. static readonly OnPickDownTrigger: number;
  11391. /**
  11392. * On double pick
  11393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11394. */
  11395. static readonly OnDoublePickTrigger: number;
  11396. /**
  11397. * On pick up
  11398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11399. */
  11400. static readonly OnPickUpTrigger: number;
  11401. /**
  11402. * On pick out.
  11403. * This trigger will only be raised if you also declared a OnPickDown
  11404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11405. */
  11406. static readonly OnPickOutTrigger: number;
  11407. /**
  11408. * On long press
  11409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11410. */
  11411. static readonly OnLongPressTrigger: number;
  11412. /**
  11413. * On pointer over
  11414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11415. */
  11416. static readonly OnPointerOverTrigger: number;
  11417. /**
  11418. * On pointer out
  11419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11420. */
  11421. static readonly OnPointerOutTrigger: number;
  11422. /**
  11423. * On every frame
  11424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11425. */
  11426. static readonly OnEveryFrameTrigger: number;
  11427. /**
  11428. * On intersection enter
  11429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11430. */
  11431. static readonly OnIntersectionEnterTrigger: number;
  11432. /**
  11433. * On intersection exit
  11434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11435. */
  11436. static readonly OnIntersectionExitTrigger: number;
  11437. /**
  11438. * On key down
  11439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11440. */
  11441. static readonly OnKeyDownTrigger: number;
  11442. /**
  11443. * On key up
  11444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11445. */
  11446. static readonly OnKeyUpTrigger: number;
  11447. private _scene;
  11448. /**
  11449. * Creates a new action manager
  11450. * @param scene defines the hosting scene
  11451. */
  11452. constructor(scene: Scene);
  11453. /**
  11454. * Releases all associated resources
  11455. */
  11456. dispose(): void;
  11457. /**
  11458. * Gets hosting scene
  11459. * @returns the hosting scene
  11460. */
  11461. getScene(): Scene;
  11462. /**
  11463. * Does this action manager handles actions of any of the given triggers
  11464. * @param triggers defines the triggers to be tested
  11465. * @return a boolean indicating whether one (or more) of the triggers is handled
  11466. */
  11467. hasSpecificTriggers(triggers: number[]): boolean;
  11468. /**
  11469. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11470. * speed.
  11471. * @param triggerA defines the trigger to be tested
  11472. * @param triggerB defines the trigger to be tested
  11473. * @return a boolean indicating whether one (or more) of the triggers is handled
  11474. */
  11475. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11476. /**
  11477. * Does this action manager handles actions of a given trigger
  11478. * @param trigger defines the trigger to be tested
  11479. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11480. * @return whether the trigger is handled
  11481. */
  11482. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11483. /**
  11484. * Does this action manager has pointer triggers
  11485. */
  11486. readonly hasPointerTriggers: boolean;
  11487. /**
  11488. * Does this action manager has pick triggers
  11489. */
  11490. readonly hasPickTriggers: boolean;
  11491. /**
  11492. * Registers an action to this action manager
  11493. * @param action defines the action to be registered
  11494. * @return the action amended (prepared) after registration
  11495. */
  11496. registerAction(action: IAction): Nullable<IAction>;
  11497. /**
  11498. * Unregisters an action to this action manager
  11499. * @param action defines the action to be unregistered
  11500. * @return a boolean indicating whether the action has been unregistered
  11501. */
  11502. unregisterAction(action: IAction): Boolean;
  11503. /**
  11504. * Process a specific trigger
  11505. * @param trigger defines the trigger to process
  11506. * @param evt defines the event details to be processed
  11507. */
  11508. processTrigger(trigger: number, evt?: IActionEvent): void;
  11509. /** @hidden */
  11510. _getEffectiveTarget(target: any, propertyPath: string): any;
  11511. /** @hidden */
  11512. _getProperty(propertyPath: string): string;
  11513. /**
  11514. * Serialize this manager to a JSON object
  11515. * @param name defines the property name to store this manager
  11516. * @returns a JSON representation of this manager
  11517. */
  11518. serialize(name: string): any;
  11519. /**
  11520. * Creates a new ActionManager from a JSON data
  11521. * @param parsedActions defines the JSON data to read from
  11522. * @param object defines the hosting mesh
  11523. * @param scene defines the hosting scene
  11524. */
  11525. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11526. /**
  11527. * Get a trigger name by index
  11528. * @param trigger defines the trigger index
  11529. * @returns a trigger name
  11530. */
  11531. static GetTriggerName(trigger: number): string;
  11532. }
  11533. }
  11534. declare module "babylonjs/Culling/ray" {
  11535. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11536. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11538. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11539. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11540. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11541. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11542. /**
  11543. * Class representing a ray with position and direction
  11544. */
  11545. export class Ray {
  11546. /** origin point */
  11547. origin: Vector3;
  11548. /** direction */
  11549. direction: Vector3;
  11550. /** length of the ray */
  11551. length: number;
  11552. private static readonly TmpVector3;
  11553. private _tmpRay;
  11554. /**
  11555. * Creates a new ray
  11556. * @param origin origin point
  11557. * @param direction direction
  11558. * @param length length of the ray
  11559. */
  11560. constructor(
  11561. /** origin point */
  11562. origin: Vector3,
  11563. /** direction */
  11564. direction: Vector3,
  11565. /** length of the ray */
  11566. length?: number);
  11567. /**
  11568. * Checks if the ray intersects a box
  11569. * @param minimum bound of the box
  11570. * @param maximum bound of the box
  11571. * @param intersectionTreshold extra extend to be added to the box in all direction
  11572. * @returns if the box was hit
  11573. */
  11574. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11575. /**
  11576. * Checks if the ray intersects a box
  11577. * @param box the bounding box to check
  11578. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11579. * @returns if the box was hit
  11580. */
  11581. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11582. /**
  11583. * If the ray hits a sphere
  11584. * @param sphere the bounding sphere to check
  11585. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11586. * @returns true if it hits the sphere
  11587. */
  11588. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11589. /**
  11590. * If the ray hits a triange
  11591. * @param vertex0 triangle vertex
  11592. * @param vertex1 triangle vertex
  11593. * @param vertex2 triangle vertex
  11594. * @returns intersection information if hit
  11595. */
  11596. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11597. /**
  11598. * Checks if ray intersects a plane
  11599. * @param plane the plane to check
  11600. * @returns the distance away it was hit
  11601. */
  11602. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11603. /**
  11604. * Checks if ray intersects a mesh
  11605. * @param mesh the mesh to check
  11606. * @param fastCheck if only the bounding box should checked
  11607. * @returns picking info of the intersecton
  11608. */
  11609. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11610. /**
  11611. * Checks if ray intersects a mesh
  11612. * @param meshes the meshes to check
  11613. * @param fastCheck if only the bounding box should checked
  11614. * @param results array to store result in
  11615. * @returns Array of picking infos
  11616. */
  11617. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11618. private _comparePickingInfo;
  11619. private static smallnum;
  11620. private static rayl;
  11621. /**
  11622. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11623. * @param sega the first point of the segment to test the intersection against
  11624. * @param segb the second point of the segment to test the intersection against
  11625. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11626. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11627. */
  11628. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11629. /**
  11630. * Update the ray from viewport position
  11631. * @param x position
  11632. * @param y y position
  11633. * @param viewportWidth viewport width
  11634. * @param viewportHeight viewport height
  11635. * @param world world matrix
  11636. * @param view view matrix
  11637. * @param projection projection matrix
  11638. * @returns this ray updated
  11639. */
  11640. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11641. /**
  11642. * Creates a ray with origin and direction of 0,0,0
  11643. * @returns the new ray
  11644. */
  11645. static Zero(): Ray;
  11646. /**
  11647. * Creates a new ray from screen space and viewport
  11648. * @param x position
  11649. * @param y y position
  11650. * @param viewportWidth viewport width
  11651. * @param viewportHeight viewport height
  11652. * @param world world matrix
  11653. * @param view view matrix
  11654. * @param projection projection matrix
  11655. * @returns new ray
  11656. */
  11657. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11658. /**
  11659. * 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
  11660. * transformed to the given world matrix.
  11661. * @param origin The origin point
  11662. * @param end The end point
  11663. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11664. * @returns the new ray
  11665. */
  11666. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11667. /**
  11668. * Transforms a ray by a matrix
  11669. * @param ray ray to transform
  11670. * @param matrix matrix to apply
  11671. * @returns the resulting new ray
  11672. */
  11673. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11674. /**
  11675. * Transforms a ray by a matrix
  11676. * @param ray ray to transform
  11677. * @param matrix matrix to apply
  11678. * @param result ray to store result in
  11679. */
  11680. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11681. /**
  11682. * Unproject a ray from screen space to object space
  11683. * @param sourceX defines the screen space x coordinate to use
  11684. * @param sourceY defines the screen space y coordinate to use
  11685. * @param viewportWidth defines the current width of the viewport
  11686. * @param viewportHeight defines the current height of the viewport
  11687. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11688. * @param view defines the view matrix to use
  11689. * @param projection defines the projection matrix to use
  11690. */
  11691. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11692. }
  11693. /**
  11694. * Type used to define predicate used to select faces when a mesh intersection is detected
  11695. */
  11696. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11697. module "babylonjs/scene" {
  11698. interface Scene {
  11699. /** @hidden */
  11700. _tempPickingRay: Nullable<Ray>;
  11701. /** @hidden */
  11702. _cachedRayForTransform: Ray;
  11703. /** @hidden */
  11704. _pickWithRayInverseMatrix: Matrix;
  11705. /** @hidden */
  11706. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11707. /** @hidden */
  11708. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11709. }
  11710. }
  11711. }
  11712. declare module "babylonjs/sceneComponent" {
  11713. import { Scene } from "babylonjs/scene";
  11714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11716. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11717. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11718. import { Nullable } from "babylonjs/types";
  11719. import { Camera } from "babylonjs/Cameras/camera";
  11720. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11721. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11722. import { AbstractScene } from "babylonjs/abstractScene";
  11723. /**
  11724. * Groups all the scene component constants in one place to ease maintenance.
  11725. * @hidden
  11726. */
  11727. export class SceneComponentConstants {
  11728. static readonly NAME_EFFECTLAYER: string;
  11729. static readonly NAME_LAYER: string;
  11730. static readonly NAME_LENSFLARESYSTEM: string;
  11731. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11732. static readonly NAME_PARTICLESYSTEM: string;
  11733. static readonly NAME_GAMEPAD: string;
  11734. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11735. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11736. static readonly NAME_DEPTHRENDERER: string;
  11737. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11738. static readonly NAME_SPRITE: string;
  11739. static readonly NAME_OUTLINERENDERER: string;
  11740. static readonly NAME_PROCEDURALTEXTURE: string;
  11741. static readonly NAME_SHADOWGENERATOR: string;
  11742. static readonly NAME_OCTREE: string;
  11743. static readonly NAME_PHYSICSENGINE: string;
  11744. static readonly NAME_AUDIO: string;
  11745. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11746. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11747. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11748. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11749. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11750. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11751. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11752. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11753. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11754. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11755. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11756. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11757. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11758. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11759. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11760. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11761. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11762. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11764. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11765. static readonly STEP_AFTERRENDER_AUDIO: number;
  11766. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11767. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11768. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11769. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11770. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11771. static readonly STEP_POINTERMOVE_SPRITE: number;
  11772. static readonly STEP_POINTERDOWN_SPRITE: number;
  11773. static readonly STEP_POINTERUP_SPRITE: number;
  11774. }
  11775. /**
  11776. * This represents a scene component.
  11777. *
  11778. * This is used to decouple the dependency the scene is having on the different workloads like
  11779. * layers, post processes...
  11780. */
  11781. export interface ISceneComponent {
  11782. /**
  11783. * The name of the component. Each component must have a unique name.
  11784. */
  11785. name: string;
  11786. /**
  11787. * The scene the component belongs to.
  11788. */
  11789. scene: Scene;
  11790. /**
  11791. * Register the component to one instance of a scene.
  11792. */
  11793. register(): void;
  11794. /**
  11795. * Rebuilds the elements related to this component in case of
  11796. * context lost for instance.
  11797. */
  11798. rebuild(): void;
  11799. /**
  11800. * Disposes the component and the associated ressources.
  11801. */
  11802. dispose(): void;
  11803. }
  11804. /**
  11805. * This represents a SERIALIZABLE scene component.
  11806. *
  11807. * This extends Scene Component to add Serialization methods on top.
  11808. */
  11809. export interface ISceneSerializableComponent extends ISceneComponent {
  11810. /**
  11811. * Adds all the element from the container to the scene
  11812. * @param container the container holding the elements
  11813. */
  11814. addFromContainer(container: AbstractScene): void;
  11815. /**
  11816. * Removes all the elements in the container from the scene
  11817. * @param container contains the elements to remove
  11818. * @param dispose if the removed element should be disposed (default: false)
  11819. */
  11820. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11821. /**
  11822. * Serializes the component data to the specified json object
  11823. * @param serializationObject The object to serialize to
  11824. */
  11825. serialize(serializationObject: any): void;
  11826. }
  11827. /**
  11828. * Strong typing of a Mesh related stage step action
  11829. */
  11830. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11831. /**
  11832. * Strong typing of a Evaluate Sub Mesh related stage step action
  11833. */
  11834. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11835. /**
  11836. * Strong typing of a Active Mesh related stage step action
  11837. */
  11838. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11839. /**
  11840. * Strong typing of a Camera related stage step action
  11841. */
  11842. export type CameraStageAction = (camera: Camera) => void;
  11843. /**
  11844. * Strong typing of a Camera Frame buffer related stage step action
  11845. */
  11846. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11847. /**
  11848. * Strong typing of a Render Target related stage step action
  11849. */
  11850. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11851. /**
  11852. * Strong typing of a RenderingGroup related stage step action
  11853. */
  11854. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11855. /**
  11856. * Strong typing of a Mesh Render related stage step action
  11857. */
  11858. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11859. /**
  11860. * Strong typing of a simple stage step action
  11861. */
  11862. export type SimpleStageAction = () => void;
  11863. /**
  11864. * Strong typing of a render target action.
  11865. */
  11866. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11867. /**
  11868. * Strong typing of a pointer move action.
  11869. */
  11870. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11871. /**
  11872. * Strong typing of a pointer up/down action.
  11873. */
  11874. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11875. /**
  11876. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11877. * @hidden
  11878. */
  11879. export class Stage<T extends Function> extends Array<{
  11880. index: number;
  11881. component: ISceneComponent;
  11882. action: T;
  11883. }> {
  11884. /**
  11885. * Hide ctor from the rest of the world.
  11886. * @param items The items to add.
  11887. */
  11888. private constructor();
  11889. /**
  11890. * Creates a new Stage.
  11891. * @returns A new instance of a Stage
  11892. */
  11893. static Create<T extends Function>(): Stage<T>;
  11894. /**
  11895. * Registers a step in an ordered way in the targeted stage.
  11896. * @param index Defines the position to register the step in
  11897. * @param component Defines the component attached to the step
  11898. * @param action Defines the action to launch during the step
  11899. */
  11900. registerStep(index: number, component: ISceneComponent, action: T): void;
  11901. /**
  11902. * Clears all the steps from the stage.
  11903. */
  11904. clear(): void;
  11905. }
  11906. }
  11907. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11908. import { Nullable } from "babylonjs/types";
  11909. import { Observable } from "babylonjs/Misc/observable";
  11910. import { Scene } from "babylonjs/scene";
  11911. import { Sprite } from "babylonjs/Sprites/sprite";
  11912. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11913. import { Ray } from "babylonjs/Culling/ray";
  11914. import { Camera } from "babylonjs/Cameras/camera";
  11915. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11916. import { ISceneComponent } from "babylonjs/sceneComponent";
  11917. module "babylonjs/scene" {
  11918. interface Scene {
  11919. /** @hidden */
  11920. _pointerOverSprite: Nullable<Sprite>;
  11921. /** @hidden */
  11922. _pickedDownSprite: Nullable<Sprite>;
  11923. /** @hidden */
  11924. _tempSpritePickingRay: Nullable<Ray>;
  11925. /**
  11926. * All of the sprite managers added to this scene
  11927. * @see http://doc.babylonjs.com/babylon101/sprites
  11928. */
  11929. spriteManagers: Array<ISpriteManager>;
  11930. /**
  11931. * An event triggered when sprites rendering is about to start
  11932. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11933. */
  11934. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11935. /**
  11936. * An event triggered when sprites rendering is done
  11937. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11938. */
  11939. onAfterSpritesRenderingObservable: Observable<Scene>;
  11940. /** @hidden */
  11941. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11942. /** Launch a ray to try to pick a sprite in the scene
  11943. * @param x position on screen
  11944. * @param y position on screen
  11945. * @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
  11946. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11948. * @returns a PickingInfo
  11949. */
  11950. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11951. /** Use the given ray to pick a sprite in the scene
  11952. * @param ray The ray (in world space) to use to pick meshes
  11953. * @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
  11954. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11955. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11956. * @returns a PickingInfo
  11957. */
  11958. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11959. /**
  11960. * Force the sprite under the pointer
  11961. * @param sprite defines the sprite to use
  11962. */
  11963. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11964. /**
  11965. * Gets the sprite under the pointer
  11966. * @returns a Sprite or null if no sprite is under the pointer
  11967. */
  11968. getPointerOverSprite(): Nullable<Sprite>;
  11969. }
  11970. }
  11971. /**
  11972. * Defines the sprite scene component responsible to manage sprites
  11973. * in a given scene.
  11974. */
  11975. export class SpriteSceneComponent implements ISceneComponent {
  11976. /**
  11977. * The component name helpfull to identify the component in the list of scene components.
  11978. */
  11979. readonly name: string;
  11980. /**
  11981. * The scene the component belongs to.
  11982. */
  11983. scene: Scene;
  11984. /** @hidden */
  11985. private _spritePredicate;
  11986. /**
  11987. * Creates a new instance of the component for the given scene
  11988. * @param scene Defines the scene to register the component in
  11989. */
  11990. constructor(scene: Scene);
  11991. /**
  11992. * Registers the component in a given scene
  11993. */
  11994. register(): void;
  11995. /**
  11996. * Rebuilds the elements related to this component in case of
  11997. * context lost for instance.
  11998. */
  11999. rebuild(): void;
  12000. /**
  12001. * Disposes the component and the associated ressources.
  12002. */
  12003. dispose(): void;
  12004. private _pickSpriteButKeepRay;
  12005. private _pointerMove;
  12006. private _pointerDown;
  12007. private _pointerUp;
  12008. }
  12009. }
  12010. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12011. /** @hidden */
  12012. export var fogFragmentDeclaration: {
  12013. name: string;
  12014. shader: string;
  12015. };
  12016. }
  12017. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12018. /** @hidden */
  12019. export var fogFragment: {
  12020. name: string;
  12021. shader: string;
  12022. };
  12023. }
  12024. declare module "babylonjs/Shaders/sprites.fragment" {
  12025. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12026. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12027. /** @hidden */
  12028. export var spritesPixelShader: {
  12029. name: string;
  12030. shader: string;
  12031. };
  12032. }
  12033. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12034. /** @hidden */
  12035. export var fogVertexDeclaration: {
  12036. name: string;
  12037. shader: string;
  12038. };
  12039. }
  12040. declare module "babylonjs/Shaders/sprites.vertex" {
  12041. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12042. /** @hidden */
  12043. export var spritesVertexShader: {
  12044. name: string;
  12045. shader: string;
  12046. };
  12047. }
  12048. declare module "babylonjs/Sprites/spriteManager" {
  12049. import { IDisposable, Scene } from "babylonjs/scene";
  12050. import { Nullable } from "babylonjs/types";
  12051. import { Observable } from "babylonjs/Misc/observable";
  12052. import { Sprite } from "babylonjs/Sprites/sprite";
  12053. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12054. import { Camera } from "babylonjs/Cameras/camera";
  12055. import { Texture } from "babylonjs/Materials/Textures/texture";
  12056. import "babylonjs/Shaders/sprites.fragment";
  12057. import "babylonjs/Shaders/sprites.vertex";
  12058. import { Ray } from "babylonjs/Culling/ray";
  12059. /**
  12060. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12061. */
  12062. export interface ISpriteManager extends IDisposable {
  12063. /**
  12064. * Restricts the camera to viewing objects with the same layerMask.
  12065. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12066. */
  12067. layerMask: number;
  12068. /**
  12069. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12070. */
  12071. isPickable: boolean;
  12072. /**
  12073. * Specifies the rendering group id for this mesh (0 by default)
  12074. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12075. */
  12076. renderingGroupId: number;
  12077. /**
  12078. * Defines the list of sprites managed by the manager.
  12079. */
  12080. sprites: Array<Sprite>;
  12081. /**
  12082. * Tests the intersection of a sprite with a specific ray.
  12083. * @param ray The ray we are sending to test the collision
  12084. * @param camera The camera space we are sending rays in
  12085. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12086. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12087. * @returns picking info or null.
  12088. */
  12089. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12090. /**
  12091. * Renders the list of sprites on screen.
  12092. */
  12093. render(): void;
  12094. }
  12095. /**
  12096. * Class used to manage multiple sprites on the same spritesheet
  12097. * @see http://doc.babylonjs.com/babylon101/sprites
  12098. */
  12099. export class SpriteManager implements ISpriteManager {
  12100. /** defines the manager's name */
  12101. name: string;
  12102. /** Gets the list of sprites */
  12103. sprites: Sprite[];
  12104. /** Gets or sets the rendering group id (0 by default) */
  12105. renderingGroupId: number;
  12106. /** Gets or sets camera layer mask */
  12107. layerMask: number;
  12108. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12109. fogEnabled: boolean;
  12110. /** Gets or sets a boolean indicating if the sprites are pickable */
  12111. isPickable: boolean;
  12112. /** Defines the default width of a cell in the spritesheet */
  12113. cellWidth: number;
  12114. /** Defines the default height of a cell in the spritesheet */
  12115. cellHeight: number;
  12116. /**
  12117. * An event triggered when the manager is disposed.
  12118. */
  12119. onDisposeObservable: Observable<SpriteManager>;
  12120. private _onDisposeObserver;
  12121. /**
  12122. * Callback called when the manager is disposed
  12123. */
  12124. onDispose: () => void;
  12125. private _capacity;
  12126. private _spriteTexture;
  12127. private _epsilon;
  12128. private _scene;
  12129. private _vertexData;
  12130. private _buffer;
  12131. private _vertexBuffers;
  12132. private _indexBuffer;
  12133. private _effectBase;
  12134. private _effectFog;
  12135. /**
  12136. * Gets or sets the spritesheet texture
  12137. */
  12138. texture: Texture;
  12139. /**
  12140. * Creates a new sprite manager
  12141. * @param name defines the manager's name
  12142. * @param imgUrl defines the sprite sheet url
  12143. * @param capacity defines the maximum allowed number of sprites
  12144. * @param cellSize defines the size of a sprite cell
  12145. * @param scene defines the hosting scene
  12146. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12147. * @param samplingMode defines the smapling mode to use with spritesheet
  12148. */
  12149. constructor(
  12150. /** defines the manager's name */
  12151. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12152. private _appendSpriteVertex;
  12153. /**
  12154. * Intersects the sprites with a ray
  12155. * @param ray defines the ray to intersect with
  12156. * @param camera defines the current active camera
  12157. * @param predicate defines a predicate used to select candidate sprites
  12158. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12159. * @returns null if no hit or a PickingInfo
  12160. */
  12161. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12162. /**
  12163. * Render all child sprites
  12164. */
  12165. render(): void;
  12166. /**
  12167. * Release associated resources
  12168. */
  12169. dispose(): void;
  12170. }
  12171. }
  12172. declare module "babylonjs/Sprites/sprite" {
  12173. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12174. import { Nullable } from "babylonjs/types";
  12175. import { ActionManager } from "babylonjs/Actions/actionManager";
  12176. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12177. /**
  12178. * Class used to represent a sprite
  12179. * @see http://doc.babylonjs.com/babylon101/sprites
  12180. */
  12181. export class Sprite {
  12182. /** defines the name */
  12183. name: string;
  12184. /** Gets or sets the current world position */
  12185. position: Vector3;
  12186. /** Gets or sets the main color */
  12187. color: Color4;
  12188. /** Gets or sets the width */
  12189. width: number;
  12190. /** Gets or sets the height */
  12191. height: number;
  12192. /** Gets or sets rotation angle */
  12193. angle: number;
  12194. /** Gets or sets the cell index in the sprite sheet */
  12195. cellIndex: number;
  12196. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12197. invertU: number;
  12198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12199. invertV: number;
  12200. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12201. disposeWhenFinishedAnimating: boolean;
  12202. /** Gets the list of attached animations */
  12203. animations: Animation[];
  12204. /** Gets or sets a boolean indicating if the sprite can be picked */
  12205. isPickable: boolean;
  12206. /**
  12207. * Gets or sets the associated action manager
  12208. */
  12209. actionManager: Nullable<ActionManager>;
  12210. private _animationStarted;
  12211. private _loopAnimation;
  12212. private _fromIndex;
  12213. private _toIndex;
  12214. private _delay;
  12215. private _direction;
  12216. private _manager;
  12217. private _time;
  12218. private _onAnimationEnd;
  12219. /**
  12220. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12221. */
  12222. isVisible: boolean;
  12223. /**
  12224. * Gets or sets the sprite size
  12225. */
  12226. size: number;
  12227. /**
  12228. * Creates a new Sprite
  12229. * @param name defines the name
  12230. * @param manager defines the manager
  12231. */
  12232. constructor(
  12233. /** defines the name */
  12234. name: string, manager: ISpriteManager);
  12235. /**
  12236. * Starts an animation
  12237. * @param from defines the initial key
  12238. * @param to defines the end key
  12239. * @param loop defines if the animation must loop
  12240. * @param delay defines the start delay (in ms)
  12241. * @param onAnimationEnd defines a callback to call when animation ends
  12242. */
  12243. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12244. /** Stops current animation (if any) */
  12245. stopAnimation(): void;
  12246. /** @hidden */
  12247. _animate(deltaTime: number): void;
  12248. /** Release associated resources */
  12249. dispose(): void;
  12250. }
  12251. }
  12252. declare module "babylonjs/Collisions/pickingInfo" {
  12253. import { Nullable } from "babylonjs/types";
  12254. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12256. import { Sprite } from "babylonjs/Sprites/sprite";
  12257. import { Ray } from "babylonjs/Culling/ray";
  12258. /**
  12259. * Information about the result of picking within a scene
  12260. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12261. */
  12262. export class PickingInfo {
  12263. /** @hidden */
  12264. _pickingUnavailable: boolean;
  12265. /**
  12266. * If the pick collided with an object
  12267. */
  12268. hit: boolean;
  12269. /**
  12270. * Distance away where the pick collided
  12271. */
  12272. distance: number;
  12273. /**
  12274. * The location of pick collision
  12275. */
  12276. pickedPoint: Nullable<Vector3>;
  12277. /**
  12278. * The mesh corresponding the the pick collision
  12279. */
  12280. pickedMesh: Nullable<AbstractMesh>;
  12281. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12282. bu: number;
  12283. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12284. bv: number;
  12285. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12286. faceId: number;
  12287. /** Id of the the submesh that was picked */
  12288. subMeshId: number;
  12289. /** If a sprite was picked, this will be the sprite the pick collided with */
  12290. pickedSprite: Nullable<Sprite>;
  12291. /**
  12292. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12293. */
  12294. originMesh: Nullable<AbstractMesh>;
  12295. /**
  12296. * The ray that was used to perform the picking.
  12297. */
  12298. ray: Nullable<Ray>;
  12299. /**
  12300. * Gets the normal correspodning to the face the pick collided with
  12301. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12302. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12303. * @returns The normal correspodning to the face the pick collided with
  12304. */
  12305. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12306. /**
  12307. * Gets the texture coordinates of where the pick occured
  12308. * @returns the vector containing the coordnates of the texture
  12309. */
  12310. getTextureCoordinates(): Nullable<Vector2>;
  12311. }
  12312. }
  12313. declare module "babylonjs/Events/pointerEvents" {
  12314. import { Nullable } from "babylonjs/types";
  12315. import { Vector2 } from "babylonjs/Maths/math";
  12316. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12317. import { Ray } from "babylonjs/Culling/ray";
  12318. /**
  12319. * Gather the list of pointer event types as constants.
  12320. */
  12321. export class PointerEventTypes {
  12322. /**
  12323. * 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.
  12324. */
  12325. static readonly POINTERDOWN: number;
  12326. /**
  12327. * The pointerup event is fired when a pointer is no longer active.
  12328. */
  12329. static readonly POINTERUP: number;
  12330. /**
  12331. * The pointermove event is fired when a pointer changes coordinates.
  12332. */
  12333. static readonly POINTERMOVE: number;
  12334. /**
  12335. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12336. */
  12337. static readonly POINTERWHEEL: number;
  12338. /**
  12339. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12340. */
  12341. static readonly POINTERPICK: number;
  12342. /**
  12343. * The pointertap event is fired when a the object has been touched and released without drag.
  12344. */
  12345. static readonly POINTERTAP: number;
  12346. /**
  12347. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12348. */
  12349. static readonly POINTERDOUBLETAP: number;
  12350. }
  12351. /**
  12352. * Base class of pointer info types.
  12353. */
  12354. export class PointerInfoBase {
  12355. /**
  12356. * Defines the type of event (PointerEventTypes)
  12357. */
  12358. type: number;
  12359. /**
  12360. * Defines the related dom event
  12361. */
  12362. event: PointerEvent | MouseWheelEvent;
  12363. /**
  12364. * Instantiates the base class of pointers info.
  12365. * @param type Defines the type of event (PointerEventTypes)
  12366. * @param event Defines the related dom event
  12367. */
  12368. constructor(
  12369. /**
  12370. * Defines the type of event (PointerEventTypes)
  12371. */
  12372. type: number,
  12373. /**
  12374. * Defines the related dom event
  12375. */
  12376. event: PointerEvent | MouseWheelEvent);
  12377. }
  12378. /**
  12379. * This class is used to store pointer related info for the onPrePointerObservable event.
  12380. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12381. */
  12382. export class PointerInfoPre extends PointerInfoBase {
  12383. /**
  12384. * Ray from a pointer if availible (eg. 6dof controller)
  12385. */
  12386. ray: Nullable<Ray>;
  12387. /**
  12388. * Defines the local position of the pointer on the canvas.
  12389. */
  12390. localPosition: Vector2;
  12391. /**
  12392. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12393. */
  12394. skipOnPointerObservable: boolean;
  12395. /**
  12396. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12397. * @param type Defines the type of event (PointerEventTypes)
  12398. * @param event Defines the related dom event
  12399. * @param localX Defines the local x coordinates of the pointer when the event occured
  12400. * @param localY Defines the local y coordinates of the pointer when the event occured
  12401. */
  12402. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12403. }
  12404. /**
  12405. * This type contains all the data related to a pointer event in Babylon.js.
  12406. * 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.
  12407. */
  12408. export class PointerInfo extends PointerInfoBase {
  12409. /**
  12410. * Defines the picking info associated to the info (if any)\
  12411. */
  12412. pickInfo: Nullable<PickingInfo>;
  12413. /**
  12414. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12415. * @param type Defines the type of event (PointerEventTypes)
  12416. * @param event Defines the related dom event
  12417. * @param pickInfo Defines the picking info associated to the info (if any)\
  12418. */
  12419. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12420. /**
  12421. * Defines the picking info associated to the info (if any)\
  12422. */
  12423. pickInfo: Nullable<PickingInfo>);
  12424. }
  12425. /**
  12426. * Data relating to a touch event on the screen.
  12427. */
  12428. export interface PointerTouch {
  12429. /**
  12430. * X coordinate of touch.
  12431. */
  12432. x: number;
  12433. /**
  12434. * Y coordinate of touch.
  12435. */
  12436. y: number;
  12437. /**
  12438. * Id of touch. Unique for each finger.
  12439. */
  12440. pointerId: number;
  12441. /**
  12442. * Event type passed from DOM.
  12443. */
  12444. type: any;
  12445. }
  12446. }
  12447. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12448. import { Observable } from "babylonjs/Misc/observable";
  12449. import { Nullable } from "babylonjs/types";
  12450. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12451. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12452. /**
  12453. * Manage the mouse inputs to control the movement of a free camera.
  12454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12455. */
  12456. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12457. /**
  12458. * Define if touch is enabled in the mouse input
  12459. */
  12460. touchEnabled: boolean;
  12461. /**
  12462. * Defines the camera the input is attached to.
  12463. */
  12464. camera: FreeCamera;
  12465. /**
  12466. * Defines the buttons associated with the input to handle camera move.
  12467. */
  12468. buttons: number[];
  12469. /**
  12470. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12471. */
  12472. angularSensibility: number;
  12473. private _pointerInput;
  12474. private _onMouseMove;
  12475. private _observer;
  12476. private previousPosition;
  12477. /**
  12478. * Observable for when a pointer move event occurs containing the move offset
  12479. */
  12480. onPointerMovedObservable: Observable<{
  12481. offsetX: number;
  12482. offsetY: number;
  12483. }>;
  12484. /**
  12485. * @hidden
  12486. * If the camera should be rotated automatically based on pointer movement
  12487. */
  12488. _allowCameraRotation: boolean;
  12489. /**
  12490. * Manage the mouse inputs to control the movement of a free camera.
  12491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12492. * @param touchEnabled Defines if touch is enabled or not
  12493. */
  12494. constructor(
  12495. /**
  12496. * Define if touch is enabled in the mouse input
  12497. */
  12498. touchEnabled?: boolean);
  12499. /**
  12500. * Attach the input controls to a specific dom element to get the input from.
  12501. * @param element Defines the element the controls should be listened from
  12502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12503. */
  12504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12505. /**
  12506. * Called on JS contextmenu event.
  12507. * Override this method to provide functionality.
  12508. */
  12509. protected onContextMenu(evt: PointerEvent): void;
  12510. /**
  12511. * Detach the current controls from the specified dom element.
  12512. * @param element Defines the element to stop listening the inputs from
  12513. */
  12514. detachControl(element: Nullable<HTMLElement>): void;
  12515. /**
  12516. * Gets the class name of the current intput.
  12517. * @returns the class name
  12518. */
  12519. getClassName(): string;
  12520. /**
  12521. * Get the friendly name associated with the input class.
  12522. * @returns the input friendly name
  12523. */
  12524. getSimpleName(): string;
  12525. }
  12526. }
  12527. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12528. import { Nullable } from "babylonjs/types";
  12529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12531. /**
  12532. * Manage the touch inputs to control the movement of a free camera.
  12533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12534. */
  12535. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12536. /**
  12537. * Defines the camera the input is attached to.
  12538. */
  12539. camera: FreeCamera;
  12540. /**
  12541. * Defines the touch sensibility for rotation.
  12542. * The higher the faster.
  12543. */
  12544. touchAngularSensibility: number;
  12545. /**
  12546. * Defines the touch sensibility for move.
  12547. * The higher the faster.
  12548. */
  12549. touchMoveSensibility: number;
  12550. private _offsetX;
  12551. private _offsetY;
  12552. private _pointerPressed;
  12553. private _pointerInput;
  12554. private _observer;
  12555. private _onLostFocus;
  12556. /**
  12557. * Attach the input controls to a specific dom element to get the input from.
  12558. * @param element Defines the element the controls should be listened from
  12559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12560. */
  12561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12562. /**
  12563. * Detach the current controls from the specified dom element.
  12564. * @param element Defines the element to stop listening the inputs from
  12565. */
  12566. detachControl(element: Nullable<HTMLElement>): void;
  12567. /**
  12568. * Update the current camera state depending on the inputs that have been used this frame.
  12569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12570. */
  12571. checkInputs(): void;
  12572. /**
  12573. * Gets the class name of the current intput.
  12574. * @returns the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Get the friendly name associated with the input class.
  12579. * @returns the input friendly name
  12580. */
  12581. getSimpleName(): string;
  12582. }
  12583. }
  12584. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12586. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12587. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12588. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12589. import { Nullable } from "babylonjs/types";
  12590. /**
  12591. * Default Inputs manager for the FreeCamera.
  12592. * It groups all the default supported inputs for ease of use.
  12593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12594. */
  12595. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12596. /**
  12597. * @hidden
  12598. */
  12599. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12600. /**
  12601. * @hidden
  12602. */
  12603. _mouseInput: Nullable<FreeCameraMouseInput>;
  12604. /**
  12605. * Instantiates a new FreeCameraInputsManager.
  12606. * @param camera Defines the camera the inputs belong to
  12607. */
  12608. constructor(camera: FreeCamera);
  12609. /**
  12610. * Add keyboard input support to the input manager.
  12611. * @returns the current input manager
  12612. */
  12613. addKeyboard(): FreeCameraInputsManager;
  12614. /**
  12615. * Add mouse input support to the input manager.
  12616. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12617. * @returns the current input manager
  12618. */
  12619. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12620. /**
  12621. * Removes the mouse input support from the manager
  12622. * @returns the current input manager
  12623. */
  12624. removeMouse(): FreeCameraInputsManager;
  12625. /**
  12626. * Add touch input support to the input manager.
  12627. * @returns the current input manager
  12628. */
  12629. addTouch(): FreeCameraInputsManager;
  12630. }
  12631. }
  12632. declare module "babylonjs/Cameras/freeCamera" {
  12633. import { Vector3 } from "babylonjs/Maths/math";
  12634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12635. import { Scene } from "babylonjs/scene";
  12636. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12637. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12638. /**
  12639. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12640. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12641. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12642. */
  12643. export class FreeCamera extends TargetCamera {
  12644. /**
  12645. * Define the collision ellipsoid of the camera.
  12646. * This is helpful to simulate a camera body like the player body around the camera
  12647. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12648. */
  12649. ellipsoid: Vector3;
  12650. /**
  12651. * Define an offset for the position of the ellipsoid around the camera.
  12652. * This can be helpful to determine the center of the body near the gravity center of the body
  12653. * instead of its head.
  12654. */
  12655. ellipsoidOffset: Vector3;
  12656. /**
  12657. * Enable or disable collisions of the camera with the rest of the scene objects.
  12658. */
  12659. checkCollisions: boolean;
  12660. /**
  12661. * Enable or disable gravity on the camera.
  12662. */
  12663. applyGravity: boolean;
  12664. /**
  12665. * Define the input manager associated to the camera.
  12666. */
  12667. inputs: FreeCameraInputsManager;
  12668. /**
  12669. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12670. * Higher values reduce sensitivity.
  12671. */
  12672. /**
  12673. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12674. * Higher values reduce sensitivity.
  12675. */
  12676. angularSensibility: number;
  12677. /**
  12678. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12679. */
  12680. keysUp: number[];
  12681. /**
  12682. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12683. */
  12684. keysDown: number[];
  12685. /**
  12686. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12687. */
  12688. keysLeft: number[];
  12689. /**
  12690. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12691. */
  12692. keysRight: number[];
  12693. /**
  12694. * Event raised when the camera collide with a mesh in the scene.
  12695. */
  12696. onCollide: (collidedMesh: AbstractMesh) => void;
  12697. private _collider;
  12698. private _needMoveForGravity;
  12699. private _oldPosition;
  12700. private _diffPosition;
  12701. private _newPosition;
  12702. /** @hidden */
  12703. _localDirection: Vector3;
  12704. /** @hidden */
  12705. _transformedDirection: Vector3;
  12706. /**
  12707. * Instantiates a Free Camera.
  12708. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12709. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12710. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12711. * @param name Define the name of the camera in the scene
  12712. * @param position Define the start position of the camera in the scene
  12713. * @param scene Define the scene the camera belongs to
  12714. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12715. */
  12716. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12717. /**
  12718. * Attached controls to the current camera.
  12719. * @param element Defines the element the controls should be listened from
  12720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12721. */
  12722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12723. /**
  12724. * Detach the current controls from the camera.
  12725. * The camera will stop reacting to inputs.
  12726. * @param element Defines the element to stop listening the inputs from
  12727. */
  12728. detachControl(element: HTMLElement): void;
  12729. private _collisionMask;
  12730. /**
  12731. * Define a collision mask to limit the list of object the camera can collide with
  12732. */
  12733. collisionMask: number;
  12734. /** @hidden */
  12735. _collideWithWorld(displacement: Vector3): void;
  12736. private _onCollisionPositionChange;
  12737. /** @hidden */
  12738. _checkInputs(): void;
  12739. /** @hidden */
  12740. _decideIfNeedsToMove(): boolean;
  12741. /** @hidden */
  12742. _updatePosition(): void;
  12743. /**
  12744. * Destroy the camera and release the current resources hold by it.
  12745. */
  12746. dispose(): void;
  12747. /**
  12748. * Gets the current object class name.
  12749. * @return the class name
  12750. */
  12751. getClassName(): string;
  12752. }
  12753. }
  12754. declare module "babylonjs/Gamepads/gamepad" {
  12755. import { Observable } from "babylonjs/Misc/observable";
  12756. /**
  12757. * Represents a gamepad control stick position
  12758. */
  12759. export class StickValues {
  12760. /**
  12761. * The x component of the control stick
  12762. */
  12763. x: number;
  12764. /**
  12765. * The y component of the control stick
  12766. */
  12767. y: number;
  12768. /**
  12769. * Initializes the gamepad x and y control stick values
  12770. * @param x The x component of the gamepad control stick value
  12771. * @param y The y component of the gamepad control stick value
  12772. */
  12773. constructor(
  12774. /**
  12775. * The x component of the control stick
  12776. */
  12777. x: number,
  12778. /**
  12779. * The y component of the control stick
  12780. */
  12781. y: number);
  12782. }
  12783. /**
  12784. * An interface which manages callbacks for gamepad button changes
  12785. */
  12786. export interface GamepadButtonChanges {
  12787. /**
  12788. * Called when a gamepad has been changed
  12789. */
  12790. changed: boolean;
  12791. /**
  12792. * Called when a gamepad press event has been triggered
  12793. */
  12794. pressChanged: boolean;
  12795. /**
  12796. * Called when a touch event has been triggered
  12797. */
  12798. touchChanged: boolean;
  12799. /**
  12800. * Called when a value has changed
  12801. */
  12802. valueChanged: boolean;
  12803. }
  12804. /**
  12805. * Represents a gamepad
  12806. */
  12807. export class Gamepad {
  12808. /**
  12809. * The id of the gamepad
  12810. */
  12811. id: string;
  12812. /**
  12813. * The index of the gamepad
  12814. */
  12815. index: number;
  12816. /**
  12817. * The browser gamepad
  12818. */
  12819. browserGamepad: any;
  12820. /**
  12821. * Specifies what type of gamepad this represents
  12822. */
  12823. type: number;
  12824. private _leftStick;
  12825. private _rightStick;
  12826. /** @hidden */
  12827. _isConnected: boolean;
  12828. private _leftStickAxisX;
  12829. private _leftStickAxisY;
  12830. private _rightStickAxisX;
  12831. private _rightStickAxisY;
  12832. /**
  12833. * Triggered when the left control stick has been changed
  12834. */
  12835. private _onleftstickchanged;
  12836. /**
  12837. * Triggered when the right control stick has been changed
  12838. */
  12839. private _onrightstickchanged;
  12840. /**
  12841. * Represents a gamepad controller
  12842. */
  12843. static GAMEPAD: number;
  12844. /**
  12845. * Represents a generic controller
  12846. */
  12847. static GENERIC: number;
  12848. /**
  12849. * Represents an XBox controller
  12850. */
  12851. static XBOX: number;
  12852. /**
  12853. * Represents a pose-enabled controller
  12854. */
  12855. static POSE_ENABLED: number;
  12856. /**
  12857. * Specifies whether the left control stick should be Y-inverted
  12858. */
  12859. protected _invertLeftStickY: boolean;
  12860. /**
  12861. * Specifies if the gamepad has been connected
  12862. */
  12863. readonly isConnected: boolean;
  12864. /**
  12865. * Initializes the gamepad
  12866. * @param id The id of the gamepad
  12867. * @param index The index of the gamepad
  12868. * @param browserGamepad The browser gamepad
  12869. * @param leftStickX The x component of the left joystick
  12870. * @param leftStickY The y component of the left joystick
  12871. * @param rightStickX The x component of the right joystick
  12872. * @param rightStickY The y component of the right joystick
  12873. */
  12874. constructor(
  12875. /**
  12876. * The id of the gamepad
  12877. */
  12878. id: string,
  12879. /**
  12880. * The index of the gamepad
  12881. */
  12882. index: number,
  12883. /**
  12884. * The browser gamepad
  12885. */
  12886. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12887. /**
  12888. * Callback triggered when the left joystick has changed
  12889. * @param callback
  12890. */
  12891. onleftstickchanged(callback: (values: StickValues) => void): void;
  12892. /**
  12893. * Callback triggered when the right joystick has changed
  12894. * @param callback
  12895. */
  12896. onrightstickchanged(callback: (values: StickValues) => void): void;
  12897. /**
  12898. * Gets the left joystick
  12899. */
  12900. /**
  12901. * Sets the left joystick values
  12902. */
  12903. leftStick: StickValues;
  12904. /**
  12905. * Gets the right joystick
  12906. */
  12907. /**
  12908. * Sets the right joystick value
  12909. */
  12910. rightStick: StickValues;
  12911. /**
  12912. * Updates the gamepad joystick positions
  12913. */
  12914. update(): void;
  12915. /**
  12916. * Disposes the gamepad
  12917. */
  12918. dispose(): void;
  12919. }
  12920. /**
  12921. * Represents a generic gamepad
  12922. */
  12923. export class GenericPad extends Gamepad {
  12924. private _buttons;
  12925. private _onbuttondown;
  12926. private _onbuttonup;
  12927. /**
  12928. * Observable triggered when a button has been pressed
  12929. */
  12930. onButtonDownObservable: Observable<number>;
  12931. /**
  12932. * Observable triggered when a button has been released
  12933. */
  12934. onButtonUpObservable: Observable<number>;
  12935. /**
  12936. * Callback triggered when a button has been pressed
  12937. * @param callback Called when a button has been pressed
  12938. */
  12939. onbuttondown(callback: (buttonPressed: number) => void): void;
  12940. /**
  12941. * Callback triggered when a button has been released
  12942. * @param callback Called when a button has been released
  12943. */
  12944. onbuttonup(callback: (buttonReleased: number) => void): void;
  12945. /**
  12946. * Initializes the generic gamepad
  12947. * @param id The id of the generic gamepad
  12948. * @param index The index of the generic gamepad
  12949. * @param browserGamepad The browser gamepad
  12950. */
  12951. constructor(id: string, index: number, browserGamepad: any);
  12952. private _setButtonValue;
  12953. /**
  12954. * Updates the generic gamepad
  12955. */
  12956. update(): void;
  12957. /**
  12958. * Disposes the generic gamepad
  12959. */
  12960. dispose(): void;
  12961. }
  12962. }
  12963. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12964. import { Observable } from "babylonjs/Misc/observable";
  12965. import { Nullable } from "babylonjs/types";
  12966. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12967. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12969. import { Ray } from "babylonjs/Culling/ray";
  12970. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12971. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12972. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12973. /**
  12974. * Defines the types of pose enabled controllers that are supported
  12975. */
  12976. export enum PoseEnabledControllerType {
  12977. /**
  12978. * HTC Vive
  12979. */
  12980. VIVE = 0,
  12981. /**
  12982. * Oculus Rift
  12983. */
  12984. OCULUS = 1,
  12985. /**
  12986. * Windows mixed reality
  12987. */
  12988. WINDOWS = 2,
  12989. /**
  12990. * Samsung gear VR
  12991. */
  12992. GEAR_VR = 3,
  12993. /**
  12994. * Google Daydream
  12995. */
  12996. DAYDREAM = 4,
  12997. /**
  12998. * Generic
  12999. */
  13000. GENERIC = 5
  13001. }
  13002. /**
  13003. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13004. */
  13005. export interface MutableGamepadButton {
  13006. /**
  13007. * Value of the button/trigger
  13008. */
  13009. value: number;
  13010. /**
  13011. * If the button/trigger is currently touched
  13012. */
  13013. touched: boolean;
  13014. /**
  13015. * If the button/trigger is currently pressed
  13016. */
  13017. pressed: boolean;
  13018. }
  13019. /**
  13020. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13021. * @hidden
  13022. */
  13023. export interface ExtendedGamepadButton extends GamepadButton {
  13024. /**
  13025. * If the button/trigger is currently pressed
  13026. */
  13027. readonly pressed: boolean;
  13028. /**
  13029. * If the button/trigger is currently touched
  13030. */
  13031. readonly touched: boolean;
  13032. /**
  13033. * Value of the button/trigger
  13034. */
  13035. readonly value: number;
  13036. }
  13037. /** @hidden */
  13038. export interface _GamePadFactory {
  13039. /**
  13040. * Returns wether or not the current gamepad can be created for this type of controller.
  13041. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13042. * @returns true if it can be created, otherwise false
  13043. */
  13044. canCreate(gamepadInfo: any): boolean;
  13045. /**
  13046. * Creates a new instance of the Gamepad.
  13047. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13048. * @returns the new gamepad instance
  13049. */
  13050. create(gamepadInfo: any): Gamepad;
  13051. }
  13052. /**
  13053. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13054. */
  13055. export class PoseEnabledControllerHelper {
  13056. /** @hidden */
  13057. static _ControllerFactories: _GamePadFactory[];
  13058. /** @hidden */
  13059. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13060. /**
  13061. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13062. * @param vrGamepad the gamepad to initialized
  13063. * @returns a vr controller of the type the gamepad identified as
  13064. */
  13065. static InitiateController(vrGamepad: any): Gamepad;
  13066. }
  13067. /**
  13068. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13069. */
  13070. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13071. private _deviceRoomPosition;
  13072. private _deviceRoomRotationQuaternion;
  13073. /**
  13074. * The device position in babylon space
  13075. */
  13076. devicePosition: Vector3;
  13077. /**
  13078. * The device rotation in babylon space
  13079. */
  13080. deviceRotationQuaternion: Quaternion;
  13081. /**
  13082. * The scale factor of the device in babylon space
  13083. */
  13084. deviceScaleFactor: number;
  13085. /**
  13086. * (Likely devicePosition should be used instead) The device position in its room space
  13087. */
  13088. position: Vector3;
  13089. /**
  13090. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13091. */
  13092. rotationQuaternion: Quaternion;
  13093. /**
  13094. * The type of controller (Eg. Windows mixed reality)
  13095. */
  13096. controllerType: PoseEnabledControllerType;
  13097. protected _calculatedPosition: Vector3;
  13098. private _calculatedRotation;
  13099. /**
  13100. * The raw pose from the device
  13101. */
  13102. rawPose: DevicePose;
  13103. private _trackPosition;
  13104. private _maxRotationDistFromHeadset;
  13105. private _draggedRoomRotation;
  13106. /**
  13107. * @hidden
  13108. */
  13109. _disableTrackPosition(fixedPosition: Vector3): void;
  13110. /**
  13111. * Internal, the mesh attached to the controller
  13112. * @hidden
  13113. */
  13114. _mesh: Nullable<AbstractMesh>;
  13115. private _poseControlledCamera;
  13116. private _leftHandSystemQuaternion;
  13117. /**
  13118. * Internal, matrix used to convert room space to babylon space
  13119. * @hidden
  13120. */
  13121. _deviceToWorld: Matrix;
  13122. /**
  13123. * Node to be used when casting a ray from the controller
  13124. * @hidden
  13125. */
  13126. _pointingPoseNode: Nullable<TransformNode>;
  13127. /**
  13128. * Name of the child mesh that can be used to cast a ray from the controller
  13129. */
  13130. static readonly POINTING_POSE: string;
  13131. /**
  13132. * Creates a new PoseEnabledController from a gamepad
  13133. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13134. */
  13135. constructor(browserGamepad: any);
  13136. private _workingMatrix;
  13137. /**
  13138. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13139. */
  13140. update(): void;
  13141. /**
  13142. * Updates only the pose device and mesh without doing any button event checking
  13143. */
  13144. protected _updatePoseAndMesh(): void;
  13145. /**
  13146. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13147. * @param poseData raw pose fromthe device
  13148. */
  13149. updateFromDevice(poseData: DevicePose): void;
  13150. /**
  13151. * @hidden
  13152. */
  13153. _meshAttachedObservable: Observable<AbstractMesh>;
  13154. /**
  13155. * Attaches a mesh to the controller
  13156. * @param mesh the mesh to be attached
  13157. */
  13158. attachToMesh(mesh: AbstractMesh): void;
  13159. /**
  13160. * Attaches the controllers mesh to a camera
  13161. * @param camera the camera the mesh should be attached to
  13162. */
  13163. attachToPoseControlledCamera(camera: TargetCamera): void;
  13164. /**
  13165. * Disposes of the controller
  13166. */
  13167. dispose(): void;
  13168. /**
  13169. * The mesh that is attached to the controller
  13170. */
  13171. readonly mesh: Nullable<AbstractMesh>;
  13172. /**
  13173. * Gets the ray of the controller in the direction the controller is pointing
  13174. * @param length the length the resulting ray should be
  13175. * @returns a ray in the direction the controller is pointing
  13176. */
  13177. getForwardRay(length?: number): Ray;
  13178. }
  13179. }
  13180. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13181. import { Observable } from "babylonjs/Misc/observable";
  13182. import { Scene } from "babylonjs/scene";
  13183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13184. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13185. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13186. /**
  13187. * Defines the WebVRController object that represents controllers tracked in 3D space
  13188. */
  13189. export abstract class WebVRController extends PoseEnabledController {
  13190. /**
  13191. * Internal, the default controller model for the controller
  13192. */
  13193. protected _defaultModel: AbstractMesh;
  13194. /**
  13195. * Fired when the trigger state has changed
  13196. */
  13197. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13198. /**
  13199. * Fired when the main button state has changed
  13200. */
  13201. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13202. /**
  13203. * Fired when the secondary button state has changed
  13204. */
  13205. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13206. /**
  13207. * Fired when the pad state has changed
  13208. */
  13209. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13210. /**
  13211. * Fired when controllers stick values have changed
  13212. */
  13213. onPadValuesChangedObservable: Observable<StickValues>;
  13214. /**
  13215. * Array of button availible on the controller
  13216. */
  13217. protected _buttons: Array<MutableGamepadButton>;
  13218. private _onButtonStateChange;
  13219. /**
  13220. * Fired when a controller button's state has changed
  13221. * @param callback the callback containing the button that was modified
  13222. */
  13223. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13224. /**
  13225. * X and Y axis corrisponding to the controllers joystick
  13226. */
  13227. pad: StickValues;
  13228. /**
  13229. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13230. */
  13231. hand: string;
  13232. /**
  13233. * The default controller model for the controller
  13234. */
  13235. readonly defaultModel: AbstractMesh;
  13236. /**
  13237. * Creates a new WebVRController from a gamepad
  13238. * @param vrGamepad the gamepad that the WebVRController should be created from
  13239. */
  13240. constructor(vrGamepad: any);
  13241. /**
  13242. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13243. */
  13244. update(): void;
  13245. /**
  13246. * Function to be called when a button is modified
  13247. */
  13248. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13249. /**
  13250. * Loads a mesh and attaches it to the controller
  13251. * @param scene the scene the mesh should be added to
  13252. * @param meshLoaded callback for when the mesh has been loaded
  13253. */
  13254. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13255. private _setButtonValue;
  13256. private _changes;
  13257. private _checkChanges;
  13258. /**
  13259. * Disposes of th webVRCOntroller
  13260. */
  13261. dispose(): void;
  13262. }
  13263. }
  13264. declare module "babylonjs/Lights/hemisphericLight" {
  13265. import { Nullable } from "babylonjs/types";
  13266. import { Scene } from "babylonjs/scene";
  13267. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13268. import { Effect } from "babylonjs/Materials/effect";
  13269. import { Light } from "babylonjs/Lights/light";
  13270. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13271. /**
  13272. * The HemisphericLight simulates the ambient environment light,
  13273. * so the passed direction is the light reflection direction, not the incoming direction.
  13274. */
  13275. export class HemisphericLight extends Light {
  13276. /**
  13277. * The groundColor is the light in the opposite direction to the one specified during creation.
  13278. * 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.
  13279. */
  13280. groundColor: Color3;
  13281. /**
  13282. * The light reflection direction, not the incoming direction.
  13283. */
  13284. direction: Vector3;
  13285. /**
  13286. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13287. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13288. * The HemisphericLight can't cast shadows.
  13289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13290. * @param name The friendly name of the light
  13291. * @param direction The direction of the light reflection
  13292. * @param scene The scene the light belongs to
  13293. */
  13294. constructor(name: string, direction: Vector3, scene: Scene);
  13295. protected _buildUniformLayout(): void;
  13296. /**
  13297. * Returns the string "HemisphericLight".
  13298. * @return The class name
  13299. */
  13300. getClassName(): string;
  13301. /**
  13302. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13303. * Returns the updated direction.
  13304. * @param target The target the direction should point to
  13305. * @return The computed direction
  13306. */
  13307. setDirectionToTarget(target: Vector3): Vector3;
  13308. /**
  13309. * Returns the shadow generator associated to the light.
  13310. * @returns Always null for hemispheric lights because it does not support shadows.
  13311. */
  13312. getShadowGenerator(): Nullable<IShadowGenerator>;
  13313. /**
  13314. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13315. * @param effect The effect to update
  13316. * @param lightIndex The index of the light in the effect to update
  13317. * @returns The hemispheric light
  13318. */
  13319. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13320. /**
  13321. * Computes the world matrix of the node
  13322. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13323. * @param useWasUpdatedFlag defines a reserved property
  13324. * @returns the world matrix
  13325. */
  13326. computeWorldMatrix(): Matrix;
  13327. /**
  13328. * Returns the integer 3.
  13329. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13330. */
  13331. getTypeID(): number;
  13332. /**
  13333. * Prepares the list of defines specific to the light type.
  13334. * @param defines the list of defines
  13335. * @param lightIndex defines the index of the light for the effect
  13336. */
  13337. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13338. }
  13339. }
  13340. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13341. /** @hidden */
  13342. export var vrMultiviewToSingleviewPixelShader: {
  13343. name: string;
  13344. shader: string;
  13345. };
  13346. }
  13347. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13349. import { Scene } from "babylonjs/scene";
  13350. /**
  13351. * Renders to multiple views with a single draw call
  13352. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13353. */
  13354. export class MultiviewRenderTarget extends RenderTargetTexture {
  13355. /**
  13356. * Creates a multiview render target
  13357. * @param scene scene used with the render target
  13358. * @param size the size of the render target (used for each view)
  13359. */
  13360. constructor(scene: Scene, size?: number | {
  13361. width: number;
  13362. height: number;
  13363. } | {
  13364. ratio: number;
  13365. });
  13366. /**
  13367. * @hidden
  13368. * @param faceIndex the face index, if its a cube texture
  13369. */
  13370. _bindFrameBuffer(faceIndex?: number): void;
  13371. /**
  13372. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13373. * @returns the view count
  13374. */
  13375. getViewCount(): number;
  13376. }
  13377. }
  13378. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13379. import { Camera } from "babylonjs/Cameras/camera";
  13380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13381. import { Nullable } from "babylonjs/types";
  13382. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13383. import { Matrix } from "babylonjs/Maths/math";
  13384. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13385. module "babylonjs/Engines/engine" {
  13386. interface Engine {
  13387. /**
  13388. * Creates a new multiview render target
  13389. * @param width defines the width of the texture
  13390. * @param height defines the height of the texture
  13391. * @returns the created multiview texture
  13392. */
  13393. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13394. /**
  13395. * Binds a multiview framebuffer to be drawn to
  13396. * @param multiviewTexture texture to bind
  13397. */
  13398. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13399. }
  13400. }
  13401. module "babylonjs/Cameras/camera" {
  13402. interface Camera {
  13403. /**
  13404. * @hidden
  13405. * 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)
  13406. */
  13407. _useMultiviewToSingleView: boolean;
  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. _multiviewTexture: Nullable<RenderTargetTexture>;
  13413. /**
  13414. * @hidden
  13415. * ensures the multiview texture of the camera exists and has the specified width/height
  13416. * @param width height to set on the multiview texture
  13417. * @param height width to set on the multiview texture
  13418. */
  13419. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13420. }
  13421. }
  13422. module "babylonjs/scene" {
  13423. interface Scene {
  13424. /** @hidden */
  13425. _transformMatrixR: Matrix;
  13426. /** @hidden */
  13427. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13428. /** @hidden */
  13429. _createMultiviewUbo(): void;
  13430. /** @hidden */
  13431. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13432. /** @hidden */
  13433. _renderMultiviewToSingleView(camera: Camera): void;
  13434. }
  13435. }
  13436. }
  13437. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13438. import { Camera } from "babylonjs/Cameras/camera";
  13439. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13440. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13441. import "babylonjs/Engines/Extensions/engine.multiview";
  13442. /**
  13443. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13444. * This will not be used for webXR as it supports displaying texture arrays directly
  13445. */
  13446. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13447. /**
  13448. * Initializes a VRMultiviewToSingleview
  13449. * @param name name of the post process
  13450. * @param camera camera to be applied to
  13451. * @param scaleFactor scaling factor to the size of the output texture
  13452. */
  13453. constructor(name: string, camera: Camera, scaleFactor: number);
  13454. }
  13455. }
  13456. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13457. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13458. import { Nullable } from "babylonjs/types";
  13459. import { Size } from "babylonjs/Maths/math";
  13460. import { Observable } from "babylonjs/Misc/observable";
  13461. module "babylonjs/Engines/engine" {
  13462. /**
  13463. * Defines the interface used by display changed events
  13464. */
  13465. interface IDisplayChangedEventArgs {
  13466. /** Gets the vrDisplay object (if any) */
  13467. vrDisplay: Nullable<any>;
  13468. /** Gets a boolean indicating if webVR is supported */
  13469. vrSupported: boolean;
  13470. }
  13471. interface Engine {
  13472. /** @hidden */
  13473. _vrDisplay: any;
  13474. /** @hidden */
  13475. _vrSupported: boolean;
  13476. /** @hidden */
  13477. _oldSize: Size;
  13478. /** @hidden */
  13479. _oldHardwareScaleFactor: number;
  13480. /** @hidden */
  13481. _vrExclusivePointerMode: boolean;
  13482. /** @hidden */
  13483. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13484. /** @hidden */
  13485. _onVRDisplayPointerRestricted: () => void;
  13486. /** @hidden */
  13487. _onVRDisplayPointerUnrestricted: () => void;
  13488. /** @hidden */
  13489. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13490. /** @hidden */
  13491. _onVrDisplayDisconnect: Nullable<() => void>;
  13492. /** @hidden */
  13493. _onVrDisplayPresentChange: Nullable<() => void>;
  13494. /**
  13495. * Observable signaled when VR display mode changes
  13496. */
  13497. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13498. /**
  13499. * Observable signaled when VR request present is complete
  13500. */
  13501. onVRRequestPresentComplete: Observable<boolean>;
  13502. /**
  13503. * Observable signaled when VR request present starts
  13504. */
  13505. onVRRequestPresentStart: Observable<Engine>;
  13506. /**
  13507. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13508. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13509. */
  13510. isInVRExclusivePointerMode: boolean;
  13511. /**
  13512. * Gets a boolean indicating if a webVR device was detected
  13513. * @returns true if a webVR device was detected
  13514. */
  13515. isVRDevicePresent(): boolean;
  13516. /**
  13517. * Gets the current webVR device
  13518. * @returns the current webVR device (or null)
  13519. */
  13520. getVRDevice(): any;
  13521. /**
  13522. * Initializes a webVR display and starts listening to display change events
  13523. * The onVRDisplayChangedObservable will be notified upon these changes
  13524. * @returns A promise containing a VRDisplay and if vr is supported
  13525. */
  13526. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13527. /** @hidden */
  13528. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13529. /**
  13530. * Call this function to switch to webVR mode
  13531. * Will do nothing if webVR is not supported or if there is no webVR device
  13532. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13533. */
  13534. enableVR(): void;
  13535. /** @hidden */
  13536. _onVRFullScreenTriggered(): void;
  13537. }
  13538. }
  13539. }
  13540. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13541. import { Nullable } from "babylonjs/types";
  13542. import { Observable } from "babylonjs/Misc/observable";
  13543. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13544. import { Scene } from "babylonjs/scene";
  13545. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13547. import { Node } from "babylonjs/node";
  13548. import { Ray } from "babylonjs/Culling/ray";
  13549. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13550. import "babylonjs/Engines/Extensions/engine.webVR";
  13551. /**
  13552. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13553. * IMPORTANT!! The data is right-hand data.
  13554. * @export
  13555. * @interface DevicePose
  13556. */
  13557. export interface DevicePose {
  13558. /**
  13559. * The position of the device, values in array are [x,y,z].
  13560. */
  13561. readonly position: Nullable<Float32Array>;
  13562. /**
  13563. * The linearVelocity of the device, values in array are [x,y,z].
  13564. */
  13565. readonly linearVelocity: Nullable<Float32Array>;
  13566. /**
  13567. * The linearAcceleration of the device, values in array are [x,y,z].
  13568. */
  13569. readonly linearAcceleration: Nullable<Float32Array>;
  13570. /**
  13571. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13572. */
  13573. readonly orientation: Nullable<Float32Array>;
  13574. /**
  13575. * The angularVelocity of the device, values in array are [x,y,z].
  13576. */
  13577. readonly angularVelocity: Nullable<Float32Array>;
  13578. /**
  13579. * The angularAcceleration of the device, values in array are [x,y,z].
  13580. */
  13581. readonly angularAcceleration: Nullable<Float32Array>;
  13582. }
  13583. /**
  13584. * Interface representing a pose controlled object in Babylon.
  13585. * A pose controlled object has both regular pose values as well as pose values
  13586. * from an external device such as a VR head mounted display
  13587. */
  13588. export interface PoseControlled {
  13589. /**
  13590. * The position of the object in babylon space.
  13591. */
  13592. position: Vector3;
  13593. /**
  13594. * The rotation quaternion of the object in babylon space.
  13595. */
  13596. rotationQuaternion: Quaternion;
  13597. /**
  13598. * The position of the device in babylon space.
  13599. */
  13600. devicePosition?: Vector3;
  13601. /**
  13602. * The rotation quaternion of the device in babylon space.
  13603. */
  13604. deviceRotationQuaternion: Quaternion;
  13605. /**
  13606. * The raw pose coming from the device.
  13607. */
  13608. rawPose: Nullable<DevicePose>;
  13609. /**
  13610. * The scale of the device to be used when translating from device space to babylon space.
  13611. */
  13612. deviceScaleFactor: number;
  13613. /**
  13614. * Updates the poseControlled values based on the input device pose.
  13615. * @param poseData the pose data to update the object with
  13616. */
  13617. updateFromDevice(poseData: DevicePose): void;
  13618. }
  13619. /**
  13620. * Set of options to customize the webVRCamera
  13621. */
  13622. export interface WebVROptions {
  13623. /**
  13624. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13625. */
  13626. trackPosition?: boolean;
  13627. /**
  13628. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13629. */
  13630. positionScale?: number;
  13631. /**
  13632. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13633. */
  13634. displayName?: string;
  13635. /**
  13636. * Should the native controller meshes be initialized. (default: true)
  13637. */
  13638. controllerMeshes?: boolean;
  13639. /**
  13640. * Creating a default HemiLight only on controllers. (default: true)
  13641. */
  13642. defaultLightingOnControllers?: boolean;
  13643. /**
  13644. * If you don't want to use the default VR button of the helper. (default: false)
  13645. */
  13646. useCustomVRButton?: boolean;
  13647. /**
  13648. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13649. */
  13650. customVRButton?: HTMLButtonElement;
  13651. /**
  13652. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13653. */
  13654. rayLength?: number;
  13655. /**
  13656. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13657. */
  13658. defaultHeight?: number;
  13659. /**
  13660. * If multiview should be used if availible (default: false)
  13661. */
  13662. useMultiview?: boolean;
  13663. }
  13664. /**
  13665. * This represents a WebVR camera.
  13666. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13667. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13668. */
  13669. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13670. private webVROptions;
  13671. /**
  13672. * @hidden
  13673. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13674. */
  13675. _vrDevice: any;
  13676. /**
  13677. * The rawPose of the vrDevice.
  13678. */
  13679. rawPose: Nullable<DevicePose>;
  13680. private _onVREnabled;
  13681. private _specsVersion;
  13682. private _attached;
  13683. private _frameData;
  13684. protected _descendants: Array<Node>;
  13685. private _deviceRoomPosition;
  13686. /** @hidden */
  13687. _deviceRoomRotationQuaternion: Quaternion;
  13688. private _standingMatrix;
  13689. /**
  13690. * Represents device position in babylon space.
  13691. */
  13692. devicePosition: Vector3;
  13693. /**
  13694. * Represents device rotation in babylon space.
  13695. */
  13696. deviceRotationQuaternion: Quaternion;
  13697. /**
  13698. * The scale of the device to be used when translating from device space to babylon space.
  13699. */
  13700. deviceScaleFactor: number;
  13701. private _deviceToWorld;
  13702. private _worldToDevice;
  13703. /**
  13704. * References to the webVR controllers for the vrDevice.
  13705. */
  13706. controllers: Array<WebVRController>;
  13707. /**
  13708. * Emits an event when a controller is attached.
  13709. */
  13710. onControllersAttachedObservable: Observable<WebVRController[]>;
  13711. /**
  13712. * Emits an event when a controller's mesh has been loaded;
  13713. */
  13714. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13715. /**
  13716. * Emits an event when the HMD's pose has been updated.
  13717. */
  13718. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13719. private _poseSet;
  13720. /**
  13721. * If the rig cameras be used as parent instead of this camera.
  13722. */
  13723. rigParenting: boolean;
  13724. private _lightOnControllers;
  13725. private _defaultHeight?;
  13726. /**
  13727. * Instantiates a WebVRFreeCamera.
  13728. * @param name The name of the WebVRFreeCamera
  13729. * @param position The starting anchor position for the camera
  13730. * @param scene The scene the camera belongs to
  13731. * @param webVROptions a set of customizable options for the webVRCamera
  13732. */
  13733. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13734. /**
  13735. * Gets the device distance from the ground in meters.
  13736. * @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.
  13737. */
  13738. deviceDistanceToRoomGround(): number;
  13739. /**
  13740. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13741. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13742. */
  13743. useStandingMatrix(callback?: (bool: boolean) => void): void;
  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. * @returns A promise with a boolean set to if the standing matrix is supported.
  13747. */
  13748. useStandingMatrixAsync(): Promise<boolean>;
  13749. /**
  13750. * Disposes the camera
  13751. */
  13752. dispose(): void;
  13753. /**
  13754. * Gets a vrController by name.
  13755. * @param name The name of the controller to retreive
  13756. * @returns the controller matching the name specified or null if not found
  13757. */
  13758. getControllerByName(name: string): Nullable<WebVRController>;
  13759. private _leftController;
  13760. /**
  13761. * The controller corrisponding to the users left hand.
  13762. */
  13763. readonly leftController: Nullable<WebVRController>;
  13764. private _rightController;
  13765. /**
  13766. * The controller corrisponding to the users right hand.
  13767. */
  13768. readonly rightController: Nullable<WebVRController>;
  13769. /**
  13770. * Casts a ray forward from the vrCamera's gaze.
  13771. * @param length Length of the ray (default: 100)
  13772. * @returns the ray corrisponding to the gaze
  13773. */
  13774. getForwardRay(length?: number): Ray;
  13775. /**
  13776. * @hidden
  13777. * Updates the camera based on device's frame data
  13778. */
  13779. _checkInputs(): void;
  13780. /**
  13781. * Updates the poseControlled values based on the input device pose.
  13782. * @param poseData Pose coming from the device
  13783. */
  13784. updateFromDevice(poseData: DevicePose): void;
  13785. private _htmlElementAttached;
  13786. private _detachIfAttached;
  13787. /**
  13788. * WebVR's attach control will start broadcasting frames to the device.
  13789. * Note that in certain browsers (chrome for example) this function must be called
  13790. * within a user-interaction callback. Example:
  13791. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13792. *
  13793. * @param element html element to attach the vrDevice to
  13794. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13795. */
  13796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13797. /**
  13798. * Detaches the camera from the html element and disables VR
  13799. *
  13800. * @param element html element to detach from
  13801. */
  13802. detachControl(element: HTMLElement): void;
  13803. /**
  13804. * @returns the name of this class
  13805. */
  13806. getClassName(): string;
  13807. /**
  13808. * Calls resetPose on the vrDisplay
  13809. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13810. */
  13811. resetToCurrentRotation(): void;
  13812. /**
  13813. * @hidden
  13814. * Updates the rig cameras (left and right eye)
  13815. */
  13816. _updateRigCameras(): void;
  13817. private _workingVector;
  13818. private _oneVector;
  13819. private _workingMatrix;
  13820. private updateCacheCalled;
  13821. private _correctPositionIfNotTrackPosition;
  13822. /**
  13823. * @hidden
  13824. * Updates the cached values of the camera
  13825. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13826. */
  13827. _updateCache(ignoreParentClass?: boolean): void;
  13828. /**
  13829. * @hidden
  13830. * Get current device position in babylon world
  13831. */
  13832. _computeDevicePosition(): void;
  13833. /**
  13834. * Updates the current device position and rotation in the babylon world
  13835. */
  13836. update(): void;
  13837. /**
  13838. * @hidden
  13839. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13840. * @returns an identity matrix
  13841. */
  13842. _getViewMatrix(): Matrix;
  13843. private _tmpMatrix;
  13844. /**
  13845. * This function is called by the two RIG cameras.
  13846. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13847. * @hidden
  13848. */
  13849. _getWebVRViewMatrix(): Matrix;
  13850. /** @hidden */
  13851. _getWebVRProjectionMatrix(): Matrix;
  13852. private _onGamepadConnectedObserver;
  13853. private _onGamepadDisconnectedObserver;
  13854. private _updateCacheWhenTrackingDisabledObserver;
  13855. /**
  13856. * Initializes the controllers and their meshes
  13857. */
  13858. initControllers(): void;
  13859. }
  13860. }
  13861. declare module "babylonjs/PostProcesses/postProcess" {
  13862. import { Nullable } from "babylonjs/types";
  13863. import { SmartArray } from "babylonjs/Misc/smartArray";
  13864. import { Observable } from "babylonjs/Misc/observable";
  13865. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13866. import { Camera } from "babylonjs/Cameras/camera";
  13867. import { Effect } from "babylonjs/Materials/effect";
  13868. import "babylonjs/Shaders/postprocess.vertex";
  13869. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13871. import { Engine } from "babylonjs/Engines/engine";
  13872. /**
  13873. * Size options for a post process
  13874. */
  13875. export type PostProcessOptions = {
  13876. width: number;
  13877. height: number;
  13878. };
  13879. /**
  13880. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13881. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13882. */
  13883. export class PostProcess {
  13884. /** Name of the PostProcess. */
  13885. name: string;
  13886. /**
  13887. * Gets or sets the unique id of the post process
  13888. */
  13889. uniqueId: number;
  13890. /**
  13891. * Width of the texture to apply the post process on
  13892. */
  13893. width: number;
  13894. /**
  13895. * Height of the texture to apply the post process on
  13896. */
  13897. height: number;
  13898. /**
  13899. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13900. * @hidden
  13901. */
  13902. _outputTexture: Nullable<InternalTexture>;
  13903. /**
  13904. * Sampling mode used by the shader
  13905. * See https://doc.babylonjs.com/classes/3.1/texture
  13906. */
  13907. renderTargetSamplingMode: number;
  13908. /**
  13909. * Clear color to use when screen clearing
  13910. */
  13911. clearColor: Color4;
  13912. /**
  13913. * If the buffer needs to be cleared before applying the post process. (default: true)
  13914. * Should be set to false if shader will overwrite all previous pixels.
  13915. */
  13916. autoClear: boolean;
  13917. /**
  13918. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13919. */
  13920. alphaMode: number;
  13921. /**
  13922. * Sets the setAlphaBlendConstants of the babylon engine
  13923. */
  13924. alphaConstants: Color4;
  13925. /**
  13926. * Animations to be used for the post processing
  13927. */
  13928. animations: import("babylonjs/Animations/animation").Animation[];
  13929. /**
  13930. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13931. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13932. */
  13933. enablePixelPerfectMode: boolean;
  13934. /**
  13935. * Force the postprocess to be applied without taking in account viewport
  13936. */
  13937. forceFullscreenViewport: boolean;
  13938. /**
  13939. * List of inspectable custom properties (used by the Inspector)
  13940. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13941. */
  13942. inspectableCustomProperties: IInspectable[];
  13943. /**
  13944. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13945. *
  13946. * | Value | Type | Description |
  13947. * | ----- | ----------------------------------- | ----------- |
  13948. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13949. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13950. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13951. *
  13952. */
  13953. scaleMode: number;
  13954. /**
  13955. * Force textures to be a power of two (default: false)
  13956. */
  13957. alwaysForcePOT: boolean;
  13958. private _samples;
  13959. /**
  13960. * Number of sample textures (default: 1)
  13961. */
  13962. samples: number;
  13963. /**
  13964. * Modify the scale of the post process to be the same as the viewport (default: false)
  13965. */
  13966. adaptScaleToCurrentViewport: boolean;
  13967. private _camera;
  13968. private _scene;
  13969. private _engine;
  13970. private _options;
  13971. private _reusable;
  13972. private _textureType;
  13973. /**
  13974. * Smart array of input and output textures for the post process.
  13975. * @hidden
  13976. */
  13977. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13978. /**
  13979. * The index in _textures that corresponds to the output texture.
  13980. * @hidden
  13981. */
  13982. _currentRenderTextureInd: number;
  13983. private _effect;
  13984. private _samplers;
  13985. private _fragmentUrl;
  13986. private _vertexUrl;
  13987. private _parameters;
  13988. private _scaleRatio;
  13989. protected _indexParameters: any;
  13990. private _shareOutputWithPostProcess;
  13991. private _texelSize;
  13992. private _forcedOutputTexture;
  13993. /**
  13994. * Returns the fragment url or shader name used in the post process.
  13995. * @returns the fragment url or name in the shader store.
  13996. */
  13997. getEffectName(): string;
  13998. /**
  13999. * An event triggered when the postprocess is activated.
  14000. */
  14001. onActivateObservable: Observable<Camera>;
  14002. private _onActivateObserver;
  14003. /**
  14004. * A function that is added to the onActivateObservable
  14005. */
  14006. onActivate: Nullable<(camera: Camera) => void>;
  14007. /**
  14008. * An event triggered when the postprocess changes its size.
  14009. */
  14010. onSizeChangedObservable: Observable<PostProcess>;
  14011. private _onSizeChangedObserver;
  14012. /**
  14013. * A function that is added to the onSizeChangedObservable
  14014. */
  14015. onSizeChanged: (postProcess: PostProcess) => void;
  14016. /**
  14017. * An event triggered when the postprocess applies its effect.
  14018. */
  14019. onApplyObservable: Observable<Effect>;
  14020. private _onApplyObserver;
  14021. /**
  14022. * A function that is added to the onApplyObservable
  14023. */
  14024. onApply: (effect: Effect) => void;
  14025. /**
  14026. * An event triggered before rendering the postprocess
  14027. */
  14028. onBeforeRenderObservable: Observable<Effect>;
  14029. private _onBeforeRenderObserver;
  14030. /**
  14031. * A function that is added to the onBeforeRenderObservable
  14032. */
  14033. onBeforeRender: (effect: Effect) => void;
  14034. /**
  14035. * An event triggered after rendering the postprocess
  14036. */
  14037. onAfterRenderObservable: Observable<Effect>;
  14038. private _onAfterRenderObserver;
  14039. /**
  14040. * A function that is added to the onAfterRenderObservable
  14041. */
  14042. onAfterRender: (efect: Effect) => void;
  14043. /**
  14044. * 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
  14045. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14046. */
  14047. inputTexture: InternalTexture;
  14048. /**
  14049. * Gets the camera which post process is applied to.
  14050. * @returns The camera the post process is applied to.
  14051. */
  14052. getCamera(): Camera;
  14053. /**
  14054. * Gets the texel size of the postprocess.
  14055. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14056. */
  14057. readonly texelSize: Vector2;
  14058. /**
  14059. * Creates a new instance PostProcess
  14060. * @param name The name of the PostProcess.
  14061. * @param fragmentUrl The url of the fragment shader to be used.
  14062. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14063. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14064. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14065. * @param camera The camera to apply the render pass to.
  14066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14067. * @param engine The engine which the post process will be applied. (default: current engine)
  14068. * @param reusable If the post process can be reused on the same frame. (default: false)
  14069. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14070. * @param textureType Type of textures used when performing the post process. (default: 0)
  14071. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14072. * @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
  14073. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14074. */
  14075. constructor(
  14076. /** Name of the PostProcess. */
  14077. 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);
  14078. /**
  14079. * Gets a string idenfifying the name of the class
  14080. * @returns "PostProcess" string
  14081. */
  14082. getClassName(): string;
  14083. /**
  14084. * Gets the engine which this post process belongs to.
  14085. * @returns The engine the post process was enabled with.
  14086. */
  14087. getEngine(): Engine;
  14088. /**
  14089. * The effect that is created when initializing the post process.
  14090. * @returns The created effect corrisponding the the postprocess.
  14091. */
  14092. getEffect(): Effect;
  14093. /**
  14094. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14095. * @param postProcess The post process to share the output with.
  14096. * @returns This post process.
  14097. */
  14098. shareOutputWith(postProcess: PostProcess): PostProcess;
  14099. /**
  14100. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14101. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14102. */
  14103. useOwnOutput(): void;
  14104. /**
  14105. * Updates the effect with the current post process compile time values and recompiles the shader.
  14106. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14107. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14108. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14109. * @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
  14110. * @param onCompiled Called when the shader has been compiled.
  14111. * @param onError Called if there is an error when compiling a shader.
  14112. */
  14113. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14114. /**
  14115. * The post process is reusable if it can be used multiple times within one frame.
  14116. * @returns If the post process is reusable
  14117. */
  14118. isReusable(): boolean;
  14119. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14120. markTextureDirty(): void;
  14121. /**
  14122. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14123. * 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.
  14124. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14125. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14126. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14127. * @returns The target texture that was bound to be written to.
  14128. */
  14129. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14130. /**
  14131. * If the post process is supported.
  14132. */
  14133. readonly isSupported: boolean;
  14134. /**
  14135. * The aspect ratio of the output texture.
  14136. */
  14137. readonly aspectRatio: number;
  14138. /**
  14139. * Get a value indicating if the post-process is ready to be used
  14140. * @returns true if the post-process is ready (shader is compiled)
  14141. */
  14142. isReady(): boolean;
  14143. /**
  14144. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14145. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14146. */
  14147. apply(): Nullable<Effect>;
  14148. private _disposeTextures;
  14149. /**
  14150. * Disposes the post process.
  14151. * @param camera The camera to dispose the post process on.
  14152. */
  14153. dispose(camera?: Camera): void;
  14154. }
  14155. }
  14156. declare module "babylonjs/PostProcesses/postProcessManager" {
  14157. import { Nullable } from "babylonjs/types";
  14158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14159. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14160. import { Scene } from "babylonjs/scene";
  14161. /**
  14162. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14163. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14164. */
  14165. export class PostProcessManager {
  14166. private _scene;
  14167. private _indexBuffer;
  14168. private _vertexBuffers;
  14169. /**
  14170. * Creates a new instance PostProcess
  14171. * @param scene The scene that the post process is associated with.
  14172. */
  14173. constructor(scene: Scene);
  14174. private _prepareBuffers;
  14175. private _buildIndexBuffer;
  14176. /**
  14177. * Rebuilds the vertex buffers of the manager.
  14178. * @hidden
  14179. */
  14180. _rebuild(): void;
  14181. /**
  14182. * Prepares a frame to be run through a post process.
  14183. * @param sourceTexture The input texture to the post procesess. (default: null)
  14184. * @param postProcesses An array of post processes to be run. (default: null)
  14185. * @returns True if the post processes were able to be run.
  14186. * @hidden
  14187. */
  14188. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14189. /**
  14190. * Manually render a set of post processes to a texture.
  14191. * @param postProcesses An array of post processes to be run.
  14192. * @param targetTexture The target texture to render to.
  14193. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14194. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14195. * @param lodLevel defines which lod of the texture to render to
  14196. */
  14197. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14198. /**
  14199. * Finalize the result of the output of the postprocesses.
  14200. * @param doNotPresent If true the result will not be displayed to the screen.
  14201. * @param targetTexture The target texture to render to.
  14202. * @param faceIndex The index of the face to bind the target texture to.
  14203. * @param postProcesses The array of post processes to render.
  14204. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14205. * @hidden
  14206. */
  14207. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14208. /**
  14209. * Disposes of the post process manager.
  14210. */
  14211. dispose(): void;
  14212. }
  14213. }
  14214. declare module "babylonjs/Layers/layerSceneComponent" {
  14215. import { Scene } from "babylonjs/scene";
  14216. import { ISceneComponent } from "babylonjs/sceneComponent";
  14217. import { Layer } from "babylonjs/Layers/layer";
  14218. module "babylonjs/abstractScene" {
  14219. interface AbstractScene {
  14220. /**
  14221. * The list of layers (background and foreground) of the scene
  14222. */
  14223. layers: Array<Layer>;
  14224. }
  14225. }
  14226. /**
  14227. * Defines the layer scene component responsible to manage any layers
  14228. * in a given scene.
  14229. */
  14230. export class LayerSceneComponent implements ISceneComponent {
  14231. /**
  14232. * The component name helpfull to identify the component in the list of scene components.
  14233. */
  14234. readonly name: string;
  14235. /**
  14236. * The scene the component belongs to.
  14237. */
  14238. scene: Scene;
  14239. private _engine;
  14240. /**
  14241. * Creates a new instance of the component for the given scene
  14242. * @param scene Defines the scene to register the component in
  14243. */
  14244. constructor(scene: Scene);
  14245. /**
  14246. * Registers the component in a given scene
  14247. */
  14248. register(): void;
  14249. /**
  14250. * Rebuilds the elements related to this component in case of
  14251. * context lost for instance.
  14252. */
  14253. rebuild(): void;
  14254. /**
  14255. * Disposes the component and the associated ressources.
  14256. */
  14257. dispose(): void;
  14258. private _draw;
  14259. private _drawCameraPredicate;
  14260. private _drawCameraBackground;
  14261. private _drawCameraForeground;
  14262. private _drawRenderTargetPredicate;
  14263. private _drawRenderTargetBackground;
  14264. private _drawRenderTargetForeground;
  14265. }
  14266. }
  14267. declare module "babylonjs/Shaders/layer.fragment" {
  14268. /** @hidden */
  14269. export var layerPixelShader: {
  14270. name: string;
  14271. shader: string;
  14272. };
  14273. }
  14274. declare module "babylonjs/Shaders/layer.vertex" {
  14275. /** @hidden */
  14276. export var layerVertexShader: {
  14277. name: string;
  14278. shader: string;
  14279. };
  14280. }
  14281. declare module "babylonjs/Layers/layer" {
  14282. import { Observable } from "babylonjs/Misc/observable";
  14283. import { Nullable } from "babylonjs/types";
  14284. import { Scene } from "babylonjs/scene";
  14285. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14286. import { Texture } from "babylonjs/Materials/Textures/texture";
  14287. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14288. import "babylonjs/Shaders/layer.fragment";
  14289. import "babylonjs/Shaders/layer.vertex";
  14290. /**
  14291. * This represents a full screen 2d layer.
  14292. * This can be useful to display a picture in the background of your scene for instance.
  14293. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14294. */
  14295. export class Layer {
  14296. /**
  14297. * Define the name of the layer.
  14298. */
  14299. name: string;
  14300. /**
  14301. * Define the texture the layer should display.
  14302. */
  14303. texture: Nullable<Texture>;
  14304. /**
  14305. * Is the layer in background or foreground.
  14306. */
  14307. isBackground: boolean;
  14308. /**
  14309. * Define the color of the layer (instead of texture).
  14310. */
  14311. color: Color4;
  14312. /**
  14313. * Define the scale of the layer in order to zoom in out of the texture.
  14314. */
  14315. scale: Vector2;
  14316. /**
  14317. * Define an offset for the layer in order to shift the texture.
  14318. */
  14319. offset: Vector2;
  14320. /**
  14321. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14322. */
  14323. alphaBlendingMode: number;
  14324. /**
  14325. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14326. * Alpha test will not mix with the background color in case of transparency.
  14327. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14328. */
  14329. alphaTest: boolean;
  14330. /**
  14331. * Define a mask to restrict the layer to only some of the scene cameras.
  14332. */
  14333. layerMask: number;
  14334. /**
  14335. * Define the list of render target the layer is visible into.
  14336. */
  14337. renderTargetTextures: RenderTargetTexture[];
  14338. /**
  14339. * Define if the layer is only used in renderTarget or if it also
  14340. * renders in the main frame buffer of the canvas.
  14341. */
  14342. renderOnlyInRenderTargetTextures: boolean;
  14343. private _scene;
  14344. private _vertexBuffers;
  14345. private _indexBuffer;
  14346. private _effect;
  14347. private _alphaTestEffect;
  14348. /**
  14349. * An event triggered when the layer is disposed.
  14350. */
  14351. onDisposeObservable: Observable<Layer>;
  14352. private _onDisposeObserver;
  14353. /**
  14354. * Back compatibility with callback before the onDisposeObservable existed.
  14355. * The set callback will be triggered when the layer has been disposed.
  14356. */
  14357. onDispose: () => void;
  14358. /**
  14359. * An event triggered before rendering the scene
  14360. */
  14361. onBeforeRenderObservable: Observable<Layer>;
  14362. private _onBeforeRenderObserver;
  14363. /**
  14364. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14365. * The set callback will be triggered just before rendering the layer.
  14366. */
  14367. onBeforeRender: () => void;
  14368. /**
  14369. * An event triggered after rendering the scene
  14370. */
  14371. onAfterRenderObservable: Observable<Layer>;
  14372. private _onAfterRenderObserver;
  14373. /**
  14374. * Back compatibility with callback before the onAfterRenderObservable existed.
  14375. * The set callback will be triggered just after rendering the layer.
  14376. */
  14377. onAfterRender: () => void;
  14378. /**
  14379. * Instantiates a new layer.
  14380. * This represents a full screen 2d layer.
  14381. * This can be useful to display a picture in the background of your scene for instance.
  14382. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14383. * @param name Define the name of the layer in the scene
  14384. * @param imgUrl Define the url of the texture to display in the layer
  14385. * @param scene Define the scene the layer belongs to
  14386. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14387. * @param color Defines a color for the layer
  14388. */
  14389. constructor(
  14390. /**
  14391. * Define the name of the layer.
  14392. */
  14393. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14394. private _createIndexBuffer;
  14395. /** @hidden */
  14396. _rebuild(): void;
  14397. /**
  14398. * Renders the layer in the scene.
  14399. */
  14400. render(): void;
  14401. /**
  14402. * Disposes and releases the associated ressources.
  14403. */
  14404. dispose(): void;
  14405. }
  14406. }
  14407. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14408. import { Scene } from "babylonjs/scene";
  14409. import { ISceneComponent } from "babylonjs/sceneComponent";
  14410. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14411. module "babylonjs/abstractScene" {
  14412. interface AbstractScene {
  14413. /**
  14414. * The list of procedural textures added to the scene
  14415. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14416. */
  14417. proceduralTextures: Array<ProceduralTexture>;
  14418. }
  14419. }
  14420. /**
  14421. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14422. * in a given scene.
  14423. */
  14424. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14425. /**
  14426. * The component name helpfull to identify the component in the list of scene components.
  14427. */
  14428. readonly name: string;
  14429. /**
  14430. * The scene the component belongs to.
  14431. */
  14432. scene: Scene;
  14433. /**
  14434. * Creates a new instance of the component for the given scene
  14435. * @param scene Defines the scene to register the component in
  14436. */
  14437. constructor(scene: Scene);
  14438. /**
  14439. * Registers the component in a given scene
  14440. */
  14441. register(): void;
  14442. /**
  14443. * Rebuilds the elements related to this component in case of
  14444. * context lost for instance.
  14445. */
  14446. rebuild(): void;
  14447. /**
  14448. * Disposes the component and the associated ressources.
  14449. */
  14450. dispose(): void;
  14451. private _beforeClear;
  14452. }
  14453. }
  14454. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14456. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14457. module "babylonjs/Engines/engine" {
  14458. interface Engine {
  14459. /**
  14460. * Creates a new render target cube texture
  14461. * @param size defines the size of the texture
  14462. * @param options defines the options used to create the texture
  14463. * @returns a new render target cube texture stored in an InternalTexture
  14464. */
  14465. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14466. }
  14467. }
  14468. }
  14469. declare module "babylonjs/Shaders/procedural.vertex" {
  14470. /** @hidden */
  14471. export var proceduralVertexShader: {
  14472. name: string;
  14473. shader: string;
  14474. };
  14475. }
  14476. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14477. import { Observable } from "babylonjs/Misc/observable";
  14478. import { Nullable } from "babylonjs/types";
  14479. import { Scene } from "babylonjs/scene";
  14480. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14481. import { Effect } from "babylonjs/Materials/effect";
  14482. import { Texture } from "babylonjs/Materials/Textures/texture";
  14483. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14484. import "babylonjs/Shaders/procedural.vertex";
  14485. /**
  14486. * 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.
  14487. * This is the base class of any Procedural texture and contains most of the shareable code.
  14488. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14489. */
  14490. export class ProceduralTexture extends Texture {
  14491. isCube: boolean;
  14492. /**
  14493. * Define if the texture is enabled or not (disabled texture will not render)
  14494. */
  14495. isEnabled: boolean;
  14496. /**
  14497. * Define if the texture must be cleared before rendering (default is true)
  14498. */
  14499. autoClear: boolean;
  14500. /**
  14501. * Callback called when the texture is generated
  14502. */
  14503. onGenerated: () => void;
  14504. /**
  14505. * Event raised when the texture is generated
  14506. */
  14507. onGeneratedObservable: Observable<ProceduralTexture>;
  14508. /** @hidden */
  14509. _generateMipMaps: boolean;
  14510. /** @hidden **/
  14511. _effect: Effect;
  14512. /** @hidden */
  14513. _textures: {
  14514. [key: string]: Texture;
  14515. };
  14516. private _size;
  14517. private _currentRefreshId;
  14518. private _refreshRate;
  14519. private _vertexBuffers;
  14520. private _indexBuffer;
  14521. private _uniforms;
  14522. private _samplers;
  14523. private _fragment;
  14524. private _floats;
  14525. private _ints;
  14526. private _floatsArrays;
  14527. private _colors3;
  14528. private _colors4;
  14529. private _vectors2;
  14530. private _vectors3;
  14531. private _matrices;
  14532. private _fallbackTexture;
  14533. private _fallbackTextureUsed;
  14534. private _engine;
  14535. private _cachedDefines;
  14536. private _contentUpdateId;
  14537. private _contentData;
  14538. /**
  14539. * Instantiates a new procedural texture.
  14540. * 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.
  14541. * This is the base class of any Procedural texture and contains most of the shareable code.
  14542. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14543. * @param name Define the name of the texture
  14544. * @param size Define the size of the texture to create
  14545. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14546. * @param scene Define the scene the texture belongs to
  14547. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14548. * @param generateMipMaps Define if the texture should creates mip maps or not
  14549. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14550. */
  14551. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14552. /**
  14553. * The effect that is created when initializing the post process.
  14554. * @returns The created effect corrisponding the the postprocess.
  14555. */
  14556. getEffect(): Effect;
  14557. /**
  14558. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14559. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14560. */
  14561. getContent(): Nullable<ArrayBufferView>;
  14562. private _createIndexBuffer;
  14563. /** @hidden */
  14564. _rebuild(): void;
  14565. /**
  14566. * Resets the texture in order to recreate its associated resources.
  14567. * This can be called in case of context loss
  14568. */
  14569. reset(): void;
  14570. protected _getDefines(): string;
  14571. /**
  14572. * Is the texture ready to be used ? (rendered at least once)
  14573. * @returns true if ready, otherwise, false.
  14574. */
  14575. isReady(): boolean;
  14576. /**
  14577. * Resets the refresh counter of the texture and start bak from scratch.
  14578. * Could be useful to regenerate the texture if it is setup to render only once.
  14579. */
  14580. resetRefreshCounter(): void;
  14581. /**
  14582. * Set the fragment shader to use in order to render the texture.
  14583. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14584. */
  14585. setFragment(fragment: any): void;
  14586. /**
  14587. * Define the refresh rate of the texture or the rendering frequency.
  14588. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14589. */
  14590. refreshRate: number;
  14591. /** @hidden */
  14592. _shouldRender(): boolean;
  14593. /**
  14594. * Get the size the texture is rendering at.
  14595. * @returns the size (texture is always squared)
  14596. */
  14597. getRenderSize(): number;
  14598. /**
  14599. * Resize the texture to new value.
  14600. * @param size Define the new size the texture should have
  14601. * @param generateMipMaps Define whether the new texture should create mip maps
  14602. */
  14603. resize(size: number, generateMipMaps: boolean): void;
  14604. private _checkUniform;
  14605. /**
  14606. * Set a texture in the shader program used to render.
  14607. * @param name Define the name of the uniform samplers as defined in the shader
  14608. * @param texture Define the texture to bind to this sampler
  14609. * @return the texture itself allowing "fluent" like uniform updates
  14610. */
  14611. setTexture(name: string, texture: Texture): ProceduralTexture;
  14612. /**
  14613. * Set a float in the shader.
  14614. * @param name Define the name of the uniform as defined in the shader
  14615. * @param value Define the value to give to the uniform
  14616. * @return the texture itself allowing "fluent" like uniform updates
  14617. */
  14618. setFloat(name: string, value: number): ProceduralTexture;
  14619. /**
  14620. * Set a int in the shader.
  14621. * @param name Define the name of the uniform as defined in the shader
  14622. * @param value Define the value to give to the uniform
  14623. * @return the texture itself allowing "fluent" like uniform updates
  14624. */
  14625. setInt(name: string, value: number): ProceduralTexture;
  14626. /**
  14627. * Set an array of floats in the shader.
  14628. * @param name Define the name of the uniform as defined in the shader
  14629. * @param value Define the value to give to the uniform
  14630. * @return the texture itself allowing "fluent" like uniform updates
  14631. */
  14632. setFloats(name: string, value: number[]): ProceduralTexture;
  14633. /**
  14634. * Set a vec3 in the shader from a Color3.
  14635. * @param name Define the name of the uniform as defined in the shader
  14636. * @param value Define the value to give to the uniform
  14637. * @return the texture itself allowing "fluent" like uniform updates
  14638. */
  14639. setColor3(name: string, value: Color3): ProceduralTexture;
  14640. /**
  14641. * Set a vec4 in the shader from a Color4.
  14642. * @param name Define the name of the uniform as defined in the shader
  14643. * @param value Define the value to give to the uniform
  14644. * @return the texture itself allowing "fluent" like uniform updates
  14645. */
  14646. setColor4(name: string, value: Color4): ProceduralTexture;
  14647. /**
  14648. * Set a vec2 in the shader from a Vector2.
  14649. * @param name Define the name of the uniform as defined in the shader
  14650. * @param value Define the value to give to the uniform
  14651. * @return the texture itself allowing "fluent" like uniform updates
  14652. */
  14653. setVector2(name: string, value: Vector2): ProceduralTexture;
  14654. /**
  14655. * Set a vec3 in the shader from a Vector3.
  14656. * @param name Define the name of the uniform as defined in the shader
  14657. * @param value Define the value to give to the uniform
  14658. * @return the texture itself allowing "fluent" like uniform updates
  14659. */
  14660. setVector3(name: string, value: Vector3): ProceduralTexture;
  14661. /**
  14662. * Set a mat4 in the shader from a MAtrix.
  14663. * @param name Define the name of the uniform as defined in the shader
  14664. * @param value Define the value to give to the uniform
  14665. * @return the texture itself allowing "fluent" like uniform updates
  14666. */
  14667. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14668. /**
  14669. * Render the texture to its associated render target.
  14670. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14671. */
  14672. render(useCameraPostProcess?: boolean): void;
  14673. /**
  14674. * Clone the texture.
  14675. * @returns the cloned texture
  14676. */
  14677. clone(): ProceduralTexture;
  14678. /**
  14679. * Dispose the texture and release its asoociated resources.
  14680. */
  14681. dispose(): void;
  14682. }
  14683. }
  14684. declare module "babylonjs/Particles/baseParticleSystem" {
  14685. import { Nullable } from "babylonjs/types";
  14686. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14688. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14689. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14690. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14691. import { Scene } from "babylonjs/scene";
  14692. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14693. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14694. import { Texture } from "babylonjs/Materials/Textures/texture";
  14695. import { Animation } from "babylonjs/Animations/animation";
  14696. /**
  14697. * This represents the base class for particle system in Babylon.
  14698. * 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.
  14699. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14700. * @example https://doc.babylonjs.com/babylon101/particles
  14701. */
  14702. export class BaseParticleSystem {
  14703. /**
  14704. * Source color is added to the destination color without alpha affecting the result
  14705. */
  14706. static BLENDMODE_ONEONE: number;
  14707. /**
  14708. * Blend current color and particle color using particle’s alpha
  14709. */
  14710. static BLENDMODE_STANDARD: number;
  14711. /**
  14712. * Add current color and particle color multiplied by particle’s alpha
  14713. */
  14714. static BLENDMODE_ADD: number;
  14715. /**
  14716. * Multiply current color with particle color
  14717. */
  14718. static BLENDMODE_MULTIPLY: number;
  14719. /**
  14720. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14721. */
  14722. static BLENDMODE_MULTIPLYADD: number;
  14723. /**
  14724. * List of animations used by the particle system.
  14725. */
  14726. animations: Animation[];
  14727. /**
  14728. * The id of the Particle system.
  14729. */
  14730. id: string;
  14731. /**
  14732. * The friendly name of the Particle system.
  14733. */
  14734. name: string;
  14735. /**
  14736. * The rendering group used by the Particle system to chose when to render.
  14737. */
  14738. renderingGroupId: number;
  14739. /**
  14740. * The emitter represents the Mesh or position we are attaching the particle system to.
  14741. */
  14742. emitter: Nullable<AbstractMesh | Vector3>;
  14743. /**
  14744. * The maximum number of particles to emit per frame
  14745. */
  14746. emitRate: number;
  14747. /**
  14748. * If you want to launch only a few particles at once, that can be done, as well.
  14749. */
  14750. manualEmitCount: number;
  14751. /**
  14752. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14753. */
  14754. updateSpeed: number;
  14755. /**
  14756. * The amount of time the particle system is running (depends of the overall update speed).
  14757. */
  14758. targetStopDuration: number;
  14759. /**
  14760. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14761. */
  14762. disposeOnStop: boolean;
  14763. /**
  14764. * Minimum power of emitting particles.
  14765. */
  14766. minEmitPower: number;
  14767. /**
  14768. * Maximum power of emitting particles.
  14769. */
  14770. maxEmitPower: number;
  14771. /**
  14772. * Minimum life time of emitting particles.
  14773. */
  14774. minLifeTime: number;
  14775. /**
  14776. * Maximum life time of emitting particles.
  14777. */
  14778. maxLifeTime: number;
  14779. /**
  14780. * Minimum Size of emitting particles.
  14781. */
  14782. minSize: number;
  14783. /**
  14784. * Maximum Size of emitting particles.
  14785. */
  14786. maxSize: number;
  14787. /**
  14788. * Minimum scale of emitting particles on X axis.
  14789. */
  14790. minScaleX: number;
  14791. /**
  14792. * Maximum scale of emitting particles on X axis.
  14793. */
  14794. maxScaleX: number;
  14795. /**
  14796. * Minimum scale of emitting particles on Y axis.
  14797. */
  14798. minScaleY: number;
  14799. /**
  14800. * Maximum scale of emitting particles on Y axis.
  14801. */
  14802. maxScaleY: number;
  14803. /**
  14804. * Gets or sets the minimal initial rotation in radians.
  14805. */
  14806. minInitialRotation: number;
  14807. /**
  14808. * Gets or sets the maximal initial rotation in radians.
  14809. */
  14810. maxInitialRotation: number;
  14811. /**
  14812. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14813. */
  14814. minAngularSpeed: number;
  14815. /**
  14816. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14817. */
  14818. maxAngularSpeed: number;
  14819. /**
  14820. * The texture used to render each particle. (this can be a spritesheet)
  14821. */
  14822. particleTexture: Nullable<Texture>;
  14823. /**
  14824. * The layer mask we are rendering the particles through.
  14825. */
  14826. layerMask: number;
  14827. /**
  14828. * This can help using your own shader to render the particle system.
  14829. * The according effect will be created
  14830. */
  14831. customShader: any;
  14832. /**
  14833. * By default particle system starts as soon as they are created. This prevents the
  14834. * automatic start to happen and let you decide when to start emitting particles.
  14835. */
  14836. preventAutoStart: boolean;
  14837. private _noiseTexture;
  14838. /**
  14839. * Gets or sets a texture used to add random noise to particle positions
  14840. */
  14841. noiseTexture: Nullable<ProceduralTexture>;
  14842. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14843. noiseStrength: Vector3;
  14844. /**
  14845. * Callback triggered when the particle animation is ending.
  14846. */
  14847. onAnimationEnd: Nullable<() => void>;
  14848. /**
  14849. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14850. */
  14851. blendMode: number;
  14852. /**
  14853. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14854. * to override the particles.
  14855. */
  14856. forceDepthWrite: boolean;
  14857. /** 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 */
  14858. preWarmCycles: number;
  14859. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14860. preWarmStepOffset: number;
  14861. /**
  14862. * 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)
  14863. */
  14864. spriteCellChangeSpeed: number;
  14865. /**
  14866. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14867. */
  14868. startSpriteCellID: number;
  14869. /**
  14870. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14871. */
  14872. endSpriteCellID: number;
  14873. /**
  14874. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14875. */
  14876. spriteCellWidth: number;
  14877. /**
  14878. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14879. */
  14880. spriteCellHeight: number;
  14881. /**
  14882. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14883. */
  14884. spriteRandomStartCell: boolean;
  14885. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14886. translationPivot: Vector2;
  14887. /** @hidden */
  14888. protected _isAnimationSheetEnabled: boolean;
  14889. /**
  14890. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14891. */
  14892. beginAnimationOnStart: boolean;
  14893. /**
  14894. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14895. */
  14896. beginAnimationFrom: number;
  14897. /**
  14898. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14899. */
  14900. beginAnimationTo: number;
  14901. /**
  14902. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14903. */
  14904. beginAnimationLoop: boolean;
  14905. /**
  14906. * Gets or sets a world offset applied to all particles
  14907. */
  14908. worldOffset: Vector3;
  14909. /**
  14910. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14911. */
  14912. isAnimationSheetEnabled: boolean;
  14913. /**
  14914. * Get hosting scene
  14915. * @returns the scene
  14916. */
  14917. getScene(): Scene;
  14918. /**
  14919. * You can use gravity if you want to give an orientation to your particles.
  14920. */
  14921. gravity: Vector3;
  14922. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14923. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14924. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14925. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14926. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14927. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14928. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14929. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14930. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14931. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14932. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14933. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14934. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14935. /**
  14936. * Defines the delay in milliseconds before starting the system (0 by default)
  14937. */
  14938. startDelay: number;
  14939. /**
  14940. * Gets the current list of drag gradients.
  14941. * You must use addDragGradient and removeDragGradient to udpate this list
  14942. * @returns the list of drag gradients
  14943. */
  14944. getDragGradients(): Nullable<Array<FactorGradient>>;
  14945. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14946. limitVelocityDamping: number;
  14947. /**
  14948. * Gets the current list of limit velocity gradients.
  14949. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14950. * @returns the list of limit velocity gradients
  14951. */
  14952. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14953. /**
  14954. * Gets the current list of color gradients.
  14955. * You must use addColorGradient and removeColorGradient to udpate this list
  14956. * @returns the list of color gradients
  14957. */
  14958. getColorGradients(): Nullable<Array<ColorGradient>>;
  14959. /**
  14960. * Gets the current list of size gradients.
  14961. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14962. * @returns the list of size gradients
  14963. */
  14964. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14965. /**
  14966. * Gets the current list of color remap gradients.
  14967. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14968. * @returns the list of color remap gradients
  14969. */
  14970. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Gets the current list of life time gradients.
  14979. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14980. * @returns the list of life time gradients
  14981. */
  14982. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14983. /**
  14984. * Gets the current list of angular speed gradients.
  14985. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14986. * @returns the list of angular speed gradients
  14987. */
  14988. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14989. /**
  14990. * Gets the current list of velocity gradients.
  14991. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14992. * @returns the list of velocity gradients
  14993. */
  14994. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14995. /**
  14996. * Gets the current list of start size gradients.
  14997. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14998. * @returns the list of start size gradients
  14999. */
  15000. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15001. /**
  15002. * Gets the current list of emit rate gradients.
  15003. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15004. * @returns the list of emit rate gradients
  15005. */
  15006. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15007. /**
  15008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15009. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15010. */
  15011. direction1: Vector3;
  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. direction2: Vector3;
  15017. /**
  15018. * 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.
  15019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15020. */
  15021. minEmitBox: Vector3;
  15022. /**
  15023. * 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.
  15024. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15025. */
  15026. maxEmitBox: Vector3;
  15027. /**
  15028. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15029. */
  15030. color1: Color4;
  15031. /**
  15032. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15033. */
  15034. color2: Color4;
  15035. /**
  15036. * Color the particle will have at the end of its lifetime
  15037. */
  15038. colorDead: Color4;
  15039. /**
  15040. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15041. */
  15042. textureMask: Color4;
  15043. /**
  15044. * The particle emitter type defines the emitter used by the particle system.
  15045. * It can be for example box, sphere, or cone...
  15046. */
  15047. particleEmitterType: IParticleEmitterType;
  15048. /** @hidden */
  15049. _isSubEmitter: boolean;
  15050. /**
  15051. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15052. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15053. */
  15054. billboardMode: number;
  15055. protected _isBillboardBased: boolean;
  15056. /**
  15057. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15058. */
  15059. isBillboardBased: boolean;
  15060. /**
  15061. * The scene the particle system belongs to.
  15062. */
  15063. protected _scene: Scene;
  15064. /**
  15065. * Local cache of defines for image processing.
  15066. */
  15067. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15068. /**
  15069. * Default configuration related to image processing available in the standard Material.
  15070. */
  15071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15072. /**
  15073. * Gets the image processing configuration used either in this material.
  15074. */
  15075. /**
  15076. * Sets the Default image processing configuration used either in the this material.
  15077. *
  15078. * If sets to null, the scene one is in use.
  15079. */
  15080. imageProcessingConfiguration: ImageProcessingConfiguration;
  15081. /**
  15082. * Attaches a new image processing configuration to the Standard Material.
  15083. * @param configuration
  15084. */
  15085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15086. /** @hidden */
  15087. protected _reset(): void;
  15088. /** @hidden */
  15089. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15090. /**
  15091. * Instantiates a particle system.
  15092. * 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.
  15093. * @param name The name of the particle system
  15094. */
  15095. constructor(name: string);
  15096. /**
  15097. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15098. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15099. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15100. * @returns the emitter
  15101. */
  15102. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15103. /**
  15104. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15105. * @param radius The radius of the hemisphere to emit from
  15106. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15107. * @returns the emitter
  15108. */
  15109. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15110. /**
  15111. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15112. * @param radius The radius of the sphere to emit from
  15113. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15114. * @returns the emitter
  15115. */
  15116. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15117. /**
  15118. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15119. * @param radius The radius of the sphere to emit from
  15120. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15121. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15122. * @returns the emitter
  15123. */
  15124. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15125. /**
  15126. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15127. * @param radius The radius of the emission cylinder
  15128. * @param height The height of the emission cylinder
  15129. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15130. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15131. * @returns the emitter
  15132. */
  15133. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15134. /**
  15135. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15136. * @param radius The radius of the cylinder to emit from
  15137. * @param height The height of the emission cylinder
  15138. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15141. * @returns the emitter
  15142. */
  15143. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15144. /**
  15145. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15146. * @param radius The radius of the cone to emit from
  15147. * @param angle The base angle of the cone
  15148. * @returns the emitter
  15149. */
  15150. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15151. /**
  15152. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15153. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15154. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15155. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15156. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15157. * @returns the emitter
  15158. */
  15159. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15160. }
  15161. }
  15162. declare module "babylonjs/Particles/subEmitter" {
  15163. import { Scene } from "babylonjs/scene";
  15164. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15165. /**
  15166. * Type of sub emitter
  15167. */
  15168. export enum SubEmitterType {
  15169. /**
  15170. * Attached to the particle over it's lifetime
  15171. */
  15172. ATTACHED = 0,
  15173. /**
  15174. * Created when the particle dies
  15175. */
  15176. END = 1
  15177. }
  15178. /**
  15179. * Sub emitter class used to emit particles from an existing particle
  15180. */
  15181. export class SubEmitter {
  15182. /**
  15183. * the particle system to be used by the sub emitter
  15184. */
  15185. particleSystem: ParticleSystem;
  15186. /**
  15187. * Type of the submitter (Default: END)
  15188. */
  15189. type: SubEmitterType;
  15190. /**
  15191. * 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)
  15192. * Note: This only is supported when using an emitter of type Mesh
  15193. */
  15194. inheritDirection: boolean;
  15195. /**
  15196. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15197. */
  15198. inheritedVelocityAmount: number;
  15199. /**
  15200. * Creates a sub emitter
  15201. * @param particleSystem the particle system to be used by the sub emitter
  15202. */
  15203. constructor(
  15204. /**
  15205. * the particle system to be used by the sub emitter
  15206. */
  15207. particleSystem: ParticleSystem);
  15208. /**
  15209. * Clones the sub emitter
  15210. * @returns the cloned sub emitter
  15211. */
  15212. clone(): SubEmitter;
  15213. /**
  15214. * Serialize current object to a JSON object
  15215. * @returns the serialized object
  15216. */
  15217. serialize(): any;
  15218. /** @hidden */
  15219. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15220. /**
  15221. * Creates a new SubEmitter from a serialized JSON version
  15222. * @param serializationObject defines the JSON object to read from
  15223. * @param scene defines the hosting scene
  15224. * @param rootUrl defines the rootUrl for data loading
  15225. * @returns a new SubEmitter
  15226. */
  15227. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15228. /** Release associated resources */
  15229. dispose(): void;
  15230. }
  15231. }
  15232. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15233. /** @hidden */
  15234. export var clipPlaneFragmentDeclaration: {
  15235. name: string;
  15236. shader: string;
  15237. };
  15238. }
  15239. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15240. /** @hidden */
  15241. export var imageProcessingDeclaration: {
  15242. name: string;
  15243. shader: string;
  15244. };
  15245. }
  15246. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15247. /** @hidden */
  15248. export var imageProcessingFunctions: {
  15249. name: string;
  15250. shader: string;
  15251. };
  15252. }
  15253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15254. /** @hidden */
  15255. export var clipPlaneFragment: {
  15256. name: string;
  15257. shader: string;
  15258. };
  15259. }
  15260. declare module "babylonjs/Shaders/particles.fragment" {
  15261. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15262. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15263. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15265. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15266. /** @hidden */
  15267. export var particlesPixelShader: {
  15268. name: string;
  15269. shader: string;
  15270. };
  15271. }
  15272. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15273. /** @hidden */
  15274. export var clipPlaneVertexDeclaration: {
  15275. name: string;
  15276. shader: string;
  15277. };
  15278. }
  15279. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15280. /** @hidden */
  15281. export var clipPlaneVertex: {
  15282. name: string;
  15283. shader: string;
  15284. };
  15285. }
  15286. declare module "babylonjs/Shaders/particles.vertex" {
  15287. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15288. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15289. /** @hidden */
  15290. export var particlesVertexShader: {
  15291. name: string;
  15292. shader: string;
  15293. };
  15294. }
  15295. declare module "babylonjs/Particles/particleSystem" {
  15296. import { Nullable } from "babylonjs/types";
  15297. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15298. import { Observable } from "babylonjs/Misc/observable";
  15299. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15300. import { Effect } from "babylonjs/Materials/effect";
  15301. import { Scene, IDisposable } from "babylonjs/scene";
  15302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15303. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15304. import { Particle } from "babylonjs/Particles/particle";
  15305. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15306. import "babylonjs/Shaders/particles.fragment";
  15307. import "babylonjs/Shaders/particles.vertex";
  15308. /**
  15309. * This represents a particle system in Babylon.
  15310. * 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.
  15311. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15312. * @example https://doc.babylonjs.com/babylon101/particles
  15313. */
  15314. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15315. /**
  15316. * Billboard mode will only apply to Y axis
  15317. */
  15318. static readonly BILLBOARDMODE_Y: number;
  15319. /**
  15320. * Billboard mode will apply to all axes
  15321. */
  15322. static readonly BILLBOARDMODE_ALL: number;
  15323. /**
  15324. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15325. */
  15326. static readonly BILLBOARDMODE_STRETCHED: number;
  15327. /**
  15328. * This function can be defined to provide custom update for active particles.
  15329. * This function will be called instead of regular update (age, position, color, etc.).
  15330. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15331. */
  15332. updateFunction: (particles: Particle[]) => void;
  15333. private _emitterWorldMatrix;
  15334. /**
  15335. * This function can be defined to specify initial direction for every new particle.
  15336. * It by default use the emitterType defined function
  15337. */
  15338. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15339. /**
  15340. * This function can be defined to specify initial position for every new particle.
  15341. * It by default use the emitterType defined function
  15342. */
  15343. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15344. /**
  15345. * @hidden
  15346. */
  15347. _inheritedVelocityOffset: Vector3;
  15348. /**
  15349. * An event triggered when the system is disposed
  15350. */
  15351. onDisposeObservable: Observable<ParticleSystem>;
  15352. private _onDisposeObserver;
  15353. /**
  15354. * Sets a callback that will be triggered when the system is disposed
  15355. */
  15356. onDispose: () => void;
  15357. private _particles;
  15358. private _epsilon;
  15359. private _capacity;
  15360. private _stockParticles;
  15361. private _newPartsExcess;
  15362. private _vertexData;
  15363. private _vertexBuffer;
  15364. private _vertexBuffers;
  15365. private _spriteBuffer;
  15366. private _indexBuffer;
  15367. private _effect;
  15368. private _customEffect;
  15369. private _cachedDefines;
  15370. private _scaledColorStep;
  15371. private _colorDiff;
  15372. private _scaledDirection;
  15373. private _scaledGravity;
  15374. private _currentRenderId;
  15375. private _alive;
  15376. private _useInstancing;
  15377. private _started;
  15378. private _stopped;
  15379. private _actualFrame;
  15380. private _scaledUpdateSpeed;
  15381. private _vertexBufferSize;
  15382. /** @hidden */
  15383. _currentEmitRateGradient: Nullable<FactorGradient>;
  15384. /** @hidden */
  15385. _currentEmitRate1: number;
  15386. /** @hidden */
  15387. _currentEmitRate2: number;
  15388. /** @hidden */
  15389. _currentStartSizeGradient: Nullable<FactorGradient>;
  15390. /** @hidden */
  15391. _currentStartSize1: number;
  15392. /** @hidden */
  15393. _currentStartSize2: number;
  15394. private readonly _rawTextureWidth;
  15395. private _rampGradientsTexture;
  15396. private _useRampGradients;
  15397. /** Gets or sets a boolean indicating that ramp gradients must be used
  15398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15399. */
  15400. useRampGradients: boolean;
  15401. /**
  15402. * 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.
  15403. * 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: [])
  15404. */
  15405. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15406. private _subEmitters;
  15407. /**
  15408. * @hidden
  15409. * If the particle systems emitter should be disposed when the particle system is disposed
  15410. */
  15411. _disposeEmitterOnDispose: boolean;
  15412. /**
  15413. * The current active Sub-systems, this property is used by the root particle system only.
  15414. */
  15415. activeSubSystems: Array<ParticleSystem>;
  15416. private _rootParticleSystem;
  15417. /**
  15418. * Gets the current list of active particles
  15419. */
  15420. readonly particles: Particle[];
  15421. /**
  15422. * Returns the string "ParticleSystem"
  15423. * @returns a string containing the class name
  15424. */
  15425. getClassName(): string;
  15426. /**
  15427. * Instantiates a particle system.
  15428. * 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.
  15429. * @param name The name of the particle system
  15430. * @param capacity The max number of particles alive at the same time
  15431. * @param scene The scene the particle system belongs to
  15432. * @param customEffect a custom effect used to change the way particles are rendered by default
  15433. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15434. * @param epsilon Offset used to render the particles
  15435. */
  15436. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15437. private _addFactorGradient;
  15438. private _removeFactorGradient;
  15439. /**
  15440. * Adds a new life time gradient
  15441. * @param gradient defines the gradient to use (between 0 and 1)
  15442. * @param factor defines the life time factor to affect to the specified gradient
  15443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15444. * @returns the current particle system
  15445. */
  15446. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15447. /**
  15448. * Remove a specific life time gradient
  15449. * @param gradient defines the gradient to remove
  15450. * @returns the current particle system
  15451. */
  15452. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15453. /**
  15454. * Adds a new size gradient
  15455. * @param gradient defines the gradient to use (between 0 and 1)
  15456. * @param factor defines the size factor to affect to the specified gradient
  15457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15458. * @returns the current particle system
  15459. */
  15460. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15461. /**
  15462. * Remove a specific size gradient
  15463. * @param gradient defines the gradient to remove
  15464. * @returns the current particle system
  15465. */
  15466. removeSizeGradient(gradient: number): IParticleSystem;
  15467. /**
  15468. * Adds a new color remap gradient
  15469. * @param gradient defines the gradient to use (between 0 and 1)
  15470. * @param min defines the color remap minimal range
  15471. * @param max defines the color remap maximal range
  15472. * @returns the current particle system
  15473. */
  15474. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15475. /**
  15476. * Remove a specific color remap gradient
  15477. * @param gradient defines the gradient to remove
  15478. * @returns the current particle system
  15479. */
  15480. removeColorRemapGradient(gradient: number): IParticleSystem;
  15481. /**
  15482. * Adds a new alpha remap gradient
  15483. * @param gradient defines the gradient to use (between 0 and 1)
  15484. * @param min defines the alpha remap minimal range
  15485. * @param max defines the alpha remap maximal range
  15486. * @returns the current particle system
  15487. */
  15488. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15489. /**
  15490. * Remove a specific alpha remap gradient
  15491. * @param gradient defines the gradient to remove
  15492. * @returns the current particle system
  15493. */
  15494. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15495. /**
  15496. * Adds a new angular speed gradient
  15497. * @param gradient defines the gradient to use (between 0 and 1)
  15498. * @param factor defines the angular speed to affect to the specified gradient
  15499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15500. * @returns the current particle system
  15501. */
  15502. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15503. /**
  15504. * Remove a specific angular speed gradient
  15505. * @param gradient defines the gradient to remove
  15506. * @returns the current particle system
  15507. */
  15508. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15509. /**
  15510. * Adds a new velocity gradient
  15511. * @param gradient defines the gradient to use (between 0 and 1)
  15512. * @param factor defines the velocity to affect to the specified gradient
  15513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15514. * @returns the current particle system
  15515. */
  15516. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15517. /**
  15518. * Remove a specific velocity gradient
  15519. * @param gradient defines the gradient to remove
  15520. * @returns the current particle system
  15521. */
  15522. removeVelocityGradient(gradient: number): IParticleSystem;
  15523. /**
  15524. * Adds a new limit velocity gradient
  15525. * @param gradient defines the gradient to use (between 0 and 1)
  15526. * @param factor defines the limit velocity value to affect to the specified gradient
  15527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15528. * @returns the current particle system
  15529. */
  15530. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15531. /**
  15532. * Remove a specific limit velocity gradient
  15533. * @param gradient defines the gradient to remove
  15534. * @returns the current particle system
  15535. */
  15536. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15537. /**
  15538. * Adds a new drag gradient
  15539. * @param gradient defines the gradient to use (between 0 and 1)
  15540. * @param factor defines the drag value to affect to the specified gradient
  15541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15542. * @returns the current particle system
  15543. */
  15544. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15545. /**
  15546. * Remove a specific drag gradient
  15547. * @param gradient defines the gradient to remove
  15548. * @returns the current particle system
  15549. */
  15550. removeDragGradient(gradient: number): IParticleSystem;
  15551. /**
  15552. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15553. * @param gradient defines the gradient to use (between 0 and 1)
  15554. * @param factor defines the emit rate value to affect to the specified gradient
  15555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15556. * @returns the current particle system
  15557. */
  15558. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15559. /**
  15560. * Remove a specific emit rate gradient
  15561. * @param gradient defines the gradient to remove
  15562. * @returns the current particle system
  15563. */
  15564. removeEmitRateGradient(gradient: number): IParticleSystem;
  15565. /**
  15566. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15567. * @param gradient defines the gradient to use (between 0 and 1)
  15568. * @param factor defines the start size value to affect to the specified gradient
  15569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15570. * @returns the current particle system
  15571. */
  15572. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15573. /**
  15574. * Remove a specific start size gradient
  15575. * @param gradient defines the gradient to remove
  15576. * @returns the current particle system
  15577. */
  15578. removeStartSizeGradient(gradient: number): IParticleSystem;
  15579. private _createRampGradientTexture;
  15580. /**
  15581. * Gets the current list of ramp gradients.
  15582. * You must use addRampGradient and removeRampGradient to udpate this list
  15583. * @returns the list of ramp gradients
  15584. */
  15585. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15586. /**
  15587. * Adds a new ramp gradient used to remap particle colors
  15588. * @param gradient defines the gradient to use (between 0 and 1)
  15589. * @param color defines the color to affect to the specified gradient
  15590. * @returns the current particle system
  15591. */
  15592. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15593. /**
  15594. * Remove a specific ramp gradient
  15595. * @param gradient defines the gradient to remove
  15596. * @returns the current particle system
  15597. */
  15598. removeRampGradient(gradient: number): ParticleSystem;
  15599. /**
  15600. * Adds a new color gradient
  15601. * @param gradient defines the gradient to use (between 0 and 1)
  15602. * @param color1 defines the color to affect to the specified gradient
  15603. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15604. * @returns this particle system
  15605. */
  15606. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15607. /**
  15608. * Remove a specific color gradient
  15609. * @param gradient defines the gradient to remove
  15610. * @returns this particle system
  15611. */
  15612. removeColorGradient(gradient: number): IParticleSystem;
  15613. private _fetchR;
  15614. protected _reset(): void;
  15615. private _resetEffect;
  15616. private _createVertexBuffers;
  15617. private _createIndexBuffer;
  15618. /**
  15619. * Gets the maximum number of particles active at the same time.
  15620. * @returns The max number of active particles.
  15621. */
  15622. getCapacity(): number;
  15623. /**
  15624. * Gets whether there are still active particles in the system.
  15625. * @returns True if it is alive, otherwise false.
  15626. */
  15627. isAlive(): boolean;
  15628. /**
  15629. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15630. * @returns True if it has been started, otherwise false.
  15631. */
  15632. isStarted(): boolean;
  15633. private _prepareSubEmitterInternalArray;
  15634. /**
  15635. * Starts the particle system and begins to emit
  15636. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15637. */
  15638. start(delay?: number): void;
  15639. /**
  15640. * Stops the particle system.
  15641. * @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.
  15642. */
  15643. stop(stopSubEmitters?: boolean): void;
  15644. /**
  15645. * Remove all active particles
  15646. */
  15647. reset(): void;
  15648. /**
  15649. * @hidden (for internal use only)
  15650. */
  15651. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15652. /**
  15653. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15654. * Its lifetime will start back at 0.
  15655. */
  15656. recycleParticle: (particle: Particle) => void;
  15657. private _stopSubEmitters;
  15658. private _createParticle;
  15659. private _removeFromRoot;
  15660. private _emitFromParticle;
  15661. private _update;
  15662. /** @hidden */
  15663. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15664. /** @hidden */
  15665. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15666. /** @hidden */
  15667. private _getEffect;
  15668. /**
  15669. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15670. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15671. */
  15672. animate(preWarmOnly?: boolean): void;
  15673. private _appendParticleVertices;
  15674. /**
  15675. * Rebuilds the particle system.
  15676. */
  15677. rebuild(): void;
  15678. /**
  15679. * Is this system ready to be used/rendered
  15680. * @return true if the system is ready
  15681. */
  15682. isReady(): boolean;
  15683. private _render;
  15684. /**
  15685. * Renders the particle system in its current state.
  15686. * @returns the current number of particles
  15687. */
  15688. render(): number;
  15689. /**
  15690. * Disposes the particle system and free the associated resources
  15691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15692. */
  15693. dispose(disposeTexture?: boolean): void;
  15694. /**
  15695. * Clones the particle system.
  15696. * @param name The name of the cloned object
  15697. * @param newEmitter The new emitter to use
  15698. * @returns the cloned particle system
  15699. */
  15700. clone(name: string, newEmitter: any): ParticleSystem;
  15701. /**
  15702. * Serializes the particle system to a JSON object.
  15703. * @returns the JSON object
  15704. */
  15705. serialize(): any;
  15706. /** @hidden */
  15707. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15708. /** @hidden */
  15709. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15710. /**
  15711. * Parses a JSON object to create a particle system.
  15712. * @param parsedParticleSystem The JSON object to parse
  15713. * @param scene The scene to create the particle system in
  15714. * @param rootUrl The root url to use to load external dependencies like texture
  15715. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15716. * @returns the Parsed particle system
  15717. */
  15718. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15719. }
  15720. }
  15721. declare module "babylonjs/Particles/particle" {
  15722. import { Nullable } from "babylonjs/types";
  15723. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15724. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15725. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15726. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15727. /**
  15728. * A particle represents one of the element emitted by a particle system.
  15729. * This is mainly define by its coordinates, direction, velocity and age.
  15730. */
  15731. export class Particle {
  15732. /**
  15733. * The particle system the particle belongs to.
  15734. */
  15735. particleSystem: ParticleSystem;
  15736. private static _Count;
  15737. /**
  15738. * Unique ID of the particle
  15739. */
  15740. id: number;
  15741. /**
  15742. * The world position of the particle in the scene.
  15743. */
  15744. position: Vector3;
  15745. /**
  15746. * The world direction of the particle in the scene.
  15747. */
  15748. direction: Vector3;
  15749. /**
  15750. * The color of the particle.
  15751. */
  15752. color: Color4;
  15753. /**
  15754. * The color change of the particle per step.
  15755. */
  15756. colorStep: Color4;
  15757. /**
  15758. * Defines how long will the life of the particle be.
  15759. */
  15760. lifeTime: number;
  15761. /**
  15762. * The current age of the particle.
  15763. */
  15764. age: number;
  15765. /**
  15766. * The current size of the particle.
  15767. */
  15768. size: number;
  15769. /**
  15770. * The current scale of the particle.
  15771. */
  15772. scale: Vector2;
  15773. /**
  15774. * The current angle of the particle.
  15775. */
  15776. angle: number;
  15777. /**
  15778. * Defines how fast is the angle changing.
  15779. */
  15780. angularSpeed: number;
  15781. /**
  15782. * Defines the cell index used by the particle to be rendered from a sprite.
  15783. */
  15784. cellIndex: number;
  15785. /**
  15786. * The information required to support color remapping
  15787. */
  15788. remapData: Vector4;
  15789. /** @hidden */
  15790. _randomCellOffset?: number;
  15791. /** @hidden */
  15792. _initialDirection: Nullable<Vector3>;
  15793. /** @hidden */
  15794. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15795. /** @hidden */
  15796. _initialStartSpriteCellID: number;
  15797. /** @hidden */
  15798. _initialEndSpriteCellID: number;
  15799. /** @hidden */
  15800. _currentColorGradient: Nullable<ColorGradient>;
  15801. /** @hidden */
  15802. _currentColor1: Color4;
  15803. /** @hidden */
  15804. _currentColor2: Color4;
  15805. /** @hidden */
  15806. _currentSizeGradient: Nullable<FactorGradient>;
  15807. /** @hidden */
  15808. _currentSize1: number;
  15809. /** @hidden */
  15810. _currentSize2: number;
  15811. /** @hidden */
  15812. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15813. /** @hidden */
  15814. _currentAngularSpeed1: number;
  15815. /** @hidden */
  15816. _currentAngularSpeed2: number;
  15817. /** @hidden */
  15818. _currentVelocityGradient: Nullable<FactorGradient>;
  15819. /** @hidden */
  15820. _currentVelocity1: number;
  15821. /** @hidden */
  15822. _currentVelocity2: number;
  15823. /** @hidden */
  15824. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15825. /** @hidden */
  15826. _currentLimitVelocity1: number;
  15827. /** @hidden */
  15828. _currentLimitVelocity2: number;
  15829. /** @hidden */
  15830. _currentDragGradient: Nullable<FactorGradient>;
  15831. /** @hidden */
  15832. _currentDrag1: number;
  15833. /** @hidden */
  15834. _currentDrag2: number;
  15835. /** @hidden */
  15836. _randomNoiseCoordinates1: Vector3;
  15837. /** @hidden */
  15838. _randomNoiseCoordinates2: Vector3;
  15839. /**
  15840. * Creates a new instance Particle
  15841. * @param particleSystem the particle system the particle belongs to
  15842. */
  15843. constructor(
  15844. /**
  15845. * The particle system the particle belongs to.
  15846. */
  15847. particleSystem: ParticleSystem);
  15848. private updateCellInfoFromSystem;
  15849. /**
  15850. * Defines how the sprite cell index is updated for the particle
  15851. */
  15852. updateCellIndex(): void;
  15853. /** @hidden */
  15854. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15855. /** @hidden */
  15856. _inheritParticleInfoToSubEmitters(): void;
  15857. /** @hidden */
  15858. _reset(): void;
  15859. /**
  15860. * Copy the properties of particle to another one.
  15861. * @param other the particle to copy the information to.
  15862. */
  15863. copyTo(other: Particle): void;
  15864. }
  15865. }
  15866. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15867. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15868. import { Effect } from "babylonjs/Materials/effect";
  15869. import { Particle } from "babylonjs/Particles/particle";
  15870. /**
  15871. * Particle emitter represents a volume emitting particles.
  15872. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15873. */
  15874. export interface IParticleEmitterType {
  15875. /**
  15876. * Called by the particle System when the direction is computed for the created particle.
  15877. * @param worldMatrix is the world matrix of the particle system
  15878. * @param directionToUpdate is the direction vector to update with the result
  15879. * @param particle is the particle we are computed the direction for
  15880. */
  15881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15882. /**
  15883. * Called by the particle System when the position is computed for the created particle.
  15884. * @param worldMatrix is the world matrix of the particle system
  15885. * @param positionToUpdate is the position vector to update with the result
  15886. * @param particle is the particle we are computed the position for
  15887. */
  15888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15889. /**
  15890. * Clones the current emitter and returns a copy of it
  15891. * @returns the new emitter
  15892. */
  15893. clone(): IParticleEmitterType;
  15894. /**
  15895. * Called by the GPUParticleSystem to setup the update shader
  15896. * @param effect defines the update shader
  15897. */
  15898. applyToShader(effect: Effect): void;
  15899. /**
  15900. * Returns a string to use to update the GPU particles update shader
  15901. * @returns the effect defines string
  15902. */
  15903. getEffectDefines(): string;
  15904. /**
  15905. * Returns a string representing the class name
  15906. * @returns a string containing the class name
  15907. */
  15908. getClassName(): string;
  15909. /**
  15910. * Serializes the particle system to a JSON object.
  15911. * @returns the JSON object
  15912. */
  15913. serialize(): any;
  15914. /**
  15915. * Parse properties from a JSON object
  15916. * @param serializationObject defines the JSON object
  15917. */
  15918. parse(serializationObject: any): void;
  15919. }
  15920. }
  15921. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15922. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15923. import { Effect } from "babylonjs/Materials/effect";
  15924. import { Particle } from "babylonjs/Particles/particle";
  15925. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15926. /**
  15927. * Particle emitter emitting particles from the inside of a box.
  15928. * It emits the particles randomly between 2 given directions.
  15929. */
  15930. export class BoxParticleEmitter implements IParticleEmitterType {
  15931. /**
  15932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15933. */
  15934. direction1: Vector3;
  15935. /**
  15936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15937. */
  15938. direction2: Vector3;
  15939. /**
  15940. * 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.
  15941. */
  15942. minEmitBox: Vector3;
  15943. /**
  15944. * 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.
  15945. */
  15946. maxEmitBox: Vector3;
  15947. /**
  15948. * Creates a new instance BoxParticleEmitter
  15949. */
  15950. constructor();
  15951. /**
  15952. * Called by the particle System when the direction is computed for the created particle.
  15953. * @param worldMatrix is the world matrix of the particle system
  15954. * @param directionToUpdate is the direction vector to update with the result
  15955. * @param particle is the particle we are computed the direction for
  15956. */
  15957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15958. /**
  15959. * Called by the particle System when the position is computed for the created particle.
  15960. * @param worldMatrix is the world matrix of the particle system
  15961. * @param positionToUpdate is the position vector to update with the result
  15962. * @param particle is the particle we are computed the position for
  15963. */
  15964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15965. /**
  15966. * Clones the current emitter and returns a copy of it
  15967. * @returns the new emitter
  15968. */
  15969. clone(): BoxParticleEmitter;
  15970. /**
  15971. * Called by the GPUParticleSystem to setup the update shader
  15972. * @param effect defines the update shader
  15973. */
  15974. applyToShader(effect: Effect): void;
  15975. /**
  15976. * Returns a string to use to update the GPU particles update shader
  15977. * @returns a string containng the defines string
  15978. */
  15979. getEffectDefines(): string;
  15980. /**
  15981. * Returns the string "BoxParticleEmitter"
  15982. * @returns a string containing the class name
  15983. */
  15984. getClassName(): string;
  15985. /**
  15986. * Serializes the particle system to a JSON object.
  15987. * @returns the JSON object
  15988. */
  15989. serialize(): any;
  15990. /**
  15991. * Parse properties from a JSON object
  15992. * @param serializationObject defines the JSON object
  15993. */
  15994. parse(serializationObject: any): void;
  15995. }
  15996. }
  15997. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15998. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15999. import { Effect } from "babylonjs/Materials/effect";
  16000. import { Particle } from "babylonjs/Particles/particle";
  16001. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16002. /**
  16003. * Particle emitter emitting particles from the inside of a cone.
  16004. * It emits the particles alongside the cone volume from the base to the particle.
  16005. * The emission direction might be randomized.
  16006. */
  16007. export class ConeParticleEmitter implements IParticleEmitterType {
  16008. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16009. directionRandomizer: number;
  16010. private _radius;
  16011. private _angle;
  16012. private _height;
  16013. /**
  16014. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16015. */
  16016. radiusRange: number;
  16017. /**
  16018. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16019. */
  16020. heightRange: number;
  16021. /**
  16022. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16023. */
  16024. emitFromSpawnPointOnly: boolean;
  16025. /**
  16026. * Gets or sets the radius of the emission cone
  16027. */
  16028. radius: number;
  16029. /**
  16030. * Gets or sets the angle of the emission cone
  16031. */
  16032. angle: number;
  16033. private _buildHeight;
  16034. /**
  16035. * Creates a new instance ConeParticleEmitter
  16036. * @param radius the radius of the emission cone (1 by default)
  16037. * @param angle the cone base angle (PI by default)
  16038. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16039. */
  16040. constructor(radius?: number, angle?: number,
  16041. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16042. directionRandomizer?: number);
  16043. /**
  16044. * Called by the particle System when the direction is computed for the created particle.
  16045. * @param worldMatrix is the world matrix of the particle system
  16046. * @param directionToUpdate is the direction vector to update with the result
  16047. * @param particle is the particle we are computed the direction for
  16048. */
  16049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16050. /**
  16051. * Called by the particle System when the position is computed for the created particle.
  16052. * @param worldMatrix is the world matrix of the particle system
  16053. * @param positionToUpdate is the position vector to update with the result
  16054. * @param particle is the particle we are computed the position for
  16055. */
  16056. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16057. /**
  16058. * Clones the current emitter and returns a copy of it
  16059. * @returns the new emitter
  16060. */
  16061. clone(): ConeParticleEmitter;
  16062. /**
  16063. * Called by the GPUParticleSystem to setup the update shader
  16064. * @param effect defines the update shader
  16065. */
  16066. applyToShader(effect: Effect): void;
  16067. /**
  16068. * Returns a string to use to update the GPU particles update shader
  16069. * @returns a string containng the defines string
  16070. */
  16071. getEffectDefines(): string;
  16072. /**
  16073. * Returns the string "ConeParticleEmitter"
  16074. * @returns a string containing the class name
  16075. */
  16076. getClassName(): string;
  16077. /**
  16078. * Serializes the particle system to a JSON object.
  16079. * @returns the JSON object
  16080. */
  16081. serialize(): any;
  16082. /**
  16083. * Parse properties from a JSON object
  16084. * @param serializationObject defines the JSON object
  16085. */
  16086. parse(serializationObject: any): void;
  16087. }
  16088. }
  16089. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16090. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16091. import { Effect } from "babylonjs/Materials/effect";
  16092. import { Particle } from "babylonjs/Particles/particle";
  16093. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16094. /**
  16095. * Particle emitter emitting particles from the inside of a cylinder.
  16096. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16097. */
  16098. export class CylinderParticleEmitter implements IParticleEmitterType {
  16099. /**
  16100. * The radius of the emission cylinder.
  16101. */
  16102. radius: number;
  16103. /**
  16104. * The height of the emission cylinder.
  16105. */
  16106. height: number;
  16107. /**
  16108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16109. */
  16110. radiusRange: number;
  16111. /**
  16112. * How much to randomize the particle direction [0-1].
  16113. */
  16114. directionRandomizer: number;
  16115. /**
  16116. * Creates a new instance CylinderParticleEmitter
  16117. * @param radius the radius of the emission cylinder (1 by default)
  16118. * @param height the height of the emission cylinder (1 by default)
  16119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16120. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16121. */
  16122. constructor(
  16123. /**
  16124. * The radius of the emission cylinder.
  16125. */
  16126. radius?: number,
  16127. /**
  16128. * The height of the emission cylinder.
  16129. */
  16130. height?: number,
  16131. /**
  16132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16133. */
  16134. radiusRange?: number,
  16135. /**
  16136. * How much to randomize the particle direction [0-1].
  16137. */
  16138. directionRandomizer?: number);
  16139. /**
  16140. * Called by the particle System when the direction is computed for the created particle.
  16141. * @param worldMatrix is the world matrix of the particle system
  16142. * @param directionToUpdate is the direction vector to update with the result
  16143. * @param particle is the particle we are computed the direction for
  16144. */
  16145. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16146. /**
  16147. * Called by the particle System when the position is computed for the created particle.
  16148. * @param worldMatrix is the world matrix of the particle system
  16149. * @param positionToUpdate is the position vector to update with the result
  16150. * @param particle is the particle we are computed the position for
  16151. */
  16152. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16153. /**
  16154. * Clones the current emitter and returns a copy of it
  16155. * @returns the new emitter
  16156. */
  16157. clone(): CylinderParticleEmitter;
  16158. /**
  16159. * Called by the GPUParticleSystem to setup the update shader
  16160. * @param effect defines the update shader
  16161. */
  16162. applyToShader(effect: Effect): void;
  16163. /**
  16164. * Returns a string to use to update the GPU particles update shader
  16165. * @returns a string containng the defines string
  16166. */
  16167. getEffectDefines(): string;
  16168. /**
  16169. * Returns the string "CylinderParticleEmitter"
  16170. * @returns a string containing the class name
  16171. */
  16172. getClassName(): string;
  16173. /**
  16174. * Serializes the particle system to a JSON object.
  16175. * @returns the JSON object
  16176. */
  16177. serialize(): any;
  16178. /**
  16179. * Parse properties from a JSON object
  16180. * @param serializationObject defines the JSON object
  16181. */
  16182. parse(serializationObject: any): void;
  16183. }
  16184. /**
  16185. * Particle emitter emitting particles from the inside of a cylinder.
  16186. * It emits the particles randomly between two vectors.
  16187. */
  16188. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16189. /**
  16190. * The min limit of the emission direction.
  16191. */
  16192. direction1: Vector3;
  16193. /**
  16194. * The max limit of the emission direction.
  16195. */
  16196. direction2: Vector3;
  16197. /**
  16198. * Creates a new instance CylinderDirectedParticleEmitter
  16199. * @param radius the radius of the emission cylinder (1 by default)
  16200. * @param height the height of the emission cylinder (1 by default)
  16201. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16202. * @param direction1 the min limit of the emission direction (up vector by default)
  16203. * @param direction2 the max limit of the emission direction (up vector by default)
  16204. */
  16205. constructor(radius?: number, height?: number, radiusRange?: number,
  16206. /**
  16207. * The min limit of the emission direction.
  16208. */
  16209. direction1?: Vector3,
  16210. /**
  16211. * The max limit of the emission direction.
  16212. */
  16213. direction2?: Vector3);
  16214. /**
  16215. * Called by the particle System when the direction is computed for the created particle.
  16216. * @param worldMatrix is the world matrix of the particle system
  16217. * @param directionToUpdate is the direction vector to update with the result
  16218. * @param particle is the particle we are computed the direction for
  16219. */
  16220. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16221. /**
  16222. * Clones the current emitter and returns a copy of it
  16223. * @returns the new emitter
  16224. */
  16225. clone(): CylinderDirectedParticleEmitter;
  16226. /**
  16227. * Called by the GPUParticleSystem to setup the update shader
  16228. * @param effect defines the update shader
  16229. */
  16230. applyToShader(effect: Effect): void;
  16231. /**
  16232. * Returns a string to use to update the GPU particles update shader
  16233. * @returns a string containng the defines string
  16234. */
  16235. getEffectDefines(): string;
  16236. /**
  16237. * Returns the string "CylinderDirectedParticleEmitter"
  16238. * @returns a string containing the class name
  16239. */
  16240. getClassName(): string;
  16241. /**
  16242. * Serializes the particle system to a JSON object.
  16243. * @returns the JSON object
  16244. */
  16245. serialize(): any;
  16246. /**
  16247. * Parse properties from a JSON object
  16248. * @param serializationObject defines the JSON object
  16249. */
  16250. parse(serializationObject: any): void;
  16251. }
  16252. }
  16253. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16254. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16255. import { Effect } from "babylonjs/Materials/effect";
  16256. import { Particle } from "babylonjs/Particles/particle";
  16257. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16258. /**
  16259. * Particle emitter emitting particles from the inside of a hemisphere.
  16260. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16261. */
  16262. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16263. /**
  16264. * The radius of the emission hemisphere.
  16265. */
  16266. radius: number;
  16267. /**
  16268. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16269. */
  16270. radiusRange: number;
  16271. /**
  16272. * How much to randomize the particle direction [0-1].
  16273. */
  16274. directionRandomizer: number;
  16275. /**
  16276. * Creates a new instance HemisphericParticleEmitter
  16277. * @param radius the radius of the emission hemisphere (1 by default)
  16278. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16279. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16280. */
  16281. constructor(
  16282. /**
  16283. * The radius of the emission hemisphere.
  16284. */
  16285. radius?: number,
  16286. /**
  16287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16288. */
  16289. radiusRange?: number,
  16290. /**
  16291. * How much to randomize the particle direction [0-1].
  16292. */
  16293. directionRandomizer?: number);
  16294. /**
  16295. * Called by the particle System when the direction is computed for the created particle.
  16296. * @param worldMatrix is the world matrix of the particle system
  16297. * @param directionToUpdate is the direction vector to update with the result
  16298. * @param particle is the particle we are computed the direction for
  16299. */
  16300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16301. /**
  16302. * Called by the particle System when the position is computed for the created particle.
  16303. * @param worldMatrix is the world matrix of the particle system
  16304. * @param positionToUpdate is the position vector to update with the result
  16305. * @param particle is the particle we are computed the position for
  16306. */
  16307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16308. /**
  16309. * Clones the current emitter and returns a copy of it
  16310. * @returns the new emitter
  16311. */
  16312. clone(): HemisphericParticleEmitter;
  16313. /**
  16314. * Called by the GPUParticleSystem to setup the update shader
  16315. * @param effect defines the update shader
  16316. */
  16317. applyToShader(effect: Effect): void;
  16318. /**
  16319. * Returns a string to use to update the GPU particles update shader
  16320. * @returns a string containng the defines string
  16321. */
  16322. getEffectDefines(): string;
  16323. /**
  16324. * Returns the string "HemisphericParticleEmitter"
  16325. * @returns a string containing the class name
  16326. */
  16327. getClassName(): string;
  16328. /**
  16329. * Serializes the particle system to a JSON object.
  16330. * @returns the JSON object
  16331. */
  16332. serialize(): any;
  16333. /**
  16334. * Parse properties from a JSON object
  16335. * @param serializationObject defines the JSON object
  16336. */
  16337. parse(serializationObject: any): void;
  16338. }
  16339. }
  16340. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16341. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16342. import { Effect } from "babylonjs/Materials/effect";
  16343. import { Particle } from "babylonjs/Particles/particle";
  16344. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16345. /**
  16346. * Particle emitter emitting particles from a point.
  16347. * It emits the particles randomly between 2 given directions.
  16348. */
  16349. export class PointParticleEmitter implements IParticleEmitterType {
  16350. /**
  16351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16352. */
  16353. direction1: Vector3;
  16354. /**
  16355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16356. */
  16357. direction2: Vector3;
  16358. /**
  16359. * Creates a new instance PointParticleEmitter
  16360. */
  16361. constructor();
  16362. /**
  16363. * Called by the particle System when the direction is computed for the created particle.
  16364. * @param worldMatrix is the world matrix of the particle system
  16365. * @param directionToUpdate is the direction vector to update with the result
  16366. * @param particle is the particle we are computed the direction for
  16367. */
  16368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16369. /**
  16370. * Called by the particle System when the position is computed for the created particle.
  16371. * @param worldMatrix is the world matrix of the particle system
  16372. * @param positionToUpdate is the position vector to update with the result
  16373. * @param particle is the particle we are computed the position for
  16374. */
  16375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16376. /**
  16377. * Clones the current emitter and returns a copy of it
  16378. * @returns the new emitter
  16379. */
  16380. clone(): PointParticleEmitter;
  16381. /**
  16382. * Called by the GPUParticleSystem to setup the update shader
  16383. * @param effect defines the update shader
  16384. */
  16385. applyToShader(effect: Effect): void;
  16386. /**
  16387. * Returns a string to use to update the GPU particles update shader
  16388. * @returns a string containng the defines string
  16389. */
  16390. getEffectDefines(): string;
  16391. /**
  16392. * Returns the string "PointParticleEmitter"
  16393. * @returns a string containing the class name
  16394. */
  16395. getClassName(): string;
  16396. /**
  16397. * Serializes the particle system to a JSON object.
  16398. * @returns the JSON object
  16399. */
  16400. serialize(): any;
  16401. /**
  16402. * Parse properties from a JSON object
  16403. * @param serializationObject defines the JSON object
  16404. */
  16405. parse(serializationObject: any): void;
  16406. }
  16407. }
  16408. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16409. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16410. import { Effect } from "babylonjs/Materials/effect";
  16411. import { Particle } from "babylonjs/Particles/particle";
  16412. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16413. /**
  16414. * Particle emitter emitting particles from the inside of a sphere.
  16415. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16416. */
  16417. export class SphereParticleEmitter implements IParticleEmitterType {
  16418. /**
  16419. * The radius of the emission sphere.
  16420. */
  16421. radius: number;
  16422. /**
  16423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16424. */
  16425. radiusRange: number;
  16426. /**
  16427. * How much to randomize the particle direction [0-1].
  16428. */
  16429. directionRandomizer: number;
  16430. /**
  16431. * Creates a new instance SphereParticleEmitter
  16432. * @param radius the radius of the emission sphere (1 by default)
  16433. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16434. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16435. */
  16436. constructor(
  16437. /**
  16438. * The radius of the emission sphere.
  16439. */
  16440. radius?: number,
  16441. /**
  16442. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16443. */
  16444. radiusRange?: number,
  16445. /**
  16446. * How much to randomize the particle direction [0-1].
  16447. */
  16448. directionRandomizer?: number);
  16449. /**
  16450. * Called by the particle System when the direction is computed for the created particle.
  16451. * @param worldMatrix is the world matrix of the particle system
  16452. * @param directionToUpdate is the direction vector to update with the result
  16453. * @param particle is the particle we are computed the direction for
  16454. */
  16455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16456. /**
  16457. * Called by the particle System when the position is computed for the created particle.
  16458. * @param worldMatrix is the world matrix of the particle system
  16459. * @param positionToUpdate is the position vector to update with the result
  16460. * @param particle is the particle we are computed the position for
  16461. */
  16462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16463. /**
  16464. * Clones the current emitter and returns a copy of it
  16465. * @returns the new emitter
  16466. */
  16467. clone(): SphereParticleEmitter;
  16468. /**
  16469. * Called by the GPUParticleSystem to setup the update shader
  16470. * @param effect defines the update shader
  16471. */
  16472. applyToShader(effect: Effect): void;
  16473. /**
  16474. * Returns a string to use to update the GPU particles update shader
  16475. * @returns a string containng the defines string
  16476. */
  16477. getEffectDefines(): string;
  16478. /**
  16479. * Returns the string "SphereParticleEmitter"
  16480. * @returns a string containing the class name
  16481. */
  16482. getClassName(): string;
  16483. /**
  16484. * Serializes the particle system to a JSON object.
  16485. * @returns the JSON object
  16486. */
  16487. serialize(): any;
  16488. /**
  16489. * Parse properties from a JSON object
  16490. * @param serializationObject defines the JSON object
  16491. */
  16492. parse(serializationObject: any): void;
  16493. }
  16494. /**
  16495. * Particle emitter emitting particles from the inside of a sphere.
  16496. * It emits the particles randomly between two vectors.
  16497. */
  16498. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16499. /**
  16500. * The min limit of the emission direction.
  16501. */
  16502. direction1: Vector3;
  16503. /**
  16504. * The max limit of the emission direction.
  16505. */
  16506. direction2: Vector3;
  16507. /**
  16508. * Creates a new instance SphereDirectedParticleEmitter
  16509. * @param radius the radius of the emission sphere (1 by default)
  16510. * @param direction1 the min limit of the emission direction (up vector by default)
  16511. * @param direction2 the max limit of the emission direction (up vector by default)
  16512. */
  16513. constructor(radius?: number,
  16514. /**
  16515. * The min limit of the emission direction.
  16516. */
  16517. direction1?: Vector3,
  16518. /**
  16519. * The max limit of the emission direction.
  16520. */
  16521. direction2?: Vector3);
  16522. /**
  16523. * Called by the particle System when the direction is computed for the created particle.
  16524. * @param worldMatrix is the world matrix of the particle system
  16525. * @param directionToUpdate is the direction vector to update with the result
  16526. * @param particle is the particle we are computed the direction for
  16527. */
  16528. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16529. /**
  16530. * Clones the current emitter and returns a copy of it
  16531. * @returns the new emitter
  16532. */
  16533. clone(): SphereDirectedParticleEmitter;
  16534. /**
  16535. * Called by the GPUParticleSystem to setup the update shader
  16536. * @param effect defines the update shader
  16537. */
  16538. applyToShader(effect: Effect): void;
  16539. /**
  16540. * Returns a string to use to update the GPU particles update shader
  16541. * @returns a string containng the defines string
  16542. */
  16543. getEffectDefines(): string;
  16544. /**
  16545. * Returns the string "SphereDirectedParticleEmitter"
  16546. * @returns a string containing the class name
  16547. */
  16548. getClassName(): string;
  16549. /**
  16550. * Serializes the particle system to a JSON object.
  16551. * @returns the JSON object
  16552. */
  16553. serialize(): any;
  16554. /**
  16555. * Parse properties from a JSON object
  16556. * @param serializationObject defines the JSON object
  16557. */
  16558. parse(serializationObject: any): void;
  16559. }
  16560. }
  16561. declare module "babylonjs/Particles/EmitterTypes/index" {
  16562. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16563. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16564. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16565. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16567. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16569. }
  16570. declare module "babylonjs/Particles/IParticleSystem" {
  16571. import { Nullable } from "babylonjs/types";
  16572. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16575. import { Texture } from "babylonjs/Materials/Textures/texture";
  16576. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16577. import { Scene } from "babylonjs/scene";
  16578. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16579. import { Animation } from "babylonjs/Animations/animation";
  16580. /**
  16581. * Interface representing a particle system in Babylon.js.
  16582. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16583. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16584. */
  16585. export interface IParticleSystem {
  16586. /**
  16587. * List of animations used by the particle system.
  16588. */
  16589. animations: Animation[];
  16590. /**
  16591. * The id of the Particle system.
  16592. */
  16593. id: string;
  16594. /**
  16595. * The name of the Particle system.
  16596. */
  16597. name: string;
  16598. /**
  16599. * The emitter represents the Mesh or position we are attaching the particle system to.
  16600. */
  16601. emitter: Nullable<AbstractMesh | Vector3>;
  16602. /**
  16603. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16604. */
  16605. isBillboardBased: boolean;
  16606. /**
  16607. * The rendering group used by the Particle system to chose when to render.
  16608. */
  16609. renderingGroupId: number;
  16610. /**
  16611. * The layer mask we are rendering the particles through.
  16612. */
  16613. layerMask: number;
  16614. /**
  16615. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16616. */
  16617. updateSpeed: number;
  16618. /**
  16619. * The amount of time the particle system is running (depends of the overall update speed).
  16620. */
  16621. targetStopDuration: number;
  16622. /**
  16623. * The texture used to render each particle. (this can be a spritesheet)
  16624. */
  16625. particleTexture: Nullable<Texture>;
  16626. /**
  16627. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16628. */
  16629. blendMode: number;
  16630. /**
  16631. * Minimum life time of emitting particles.
  16632. */
  16633. minLifeTime: number;
  16634. /**
  16635. * Maximum life time of emitting particles.
  16636. */
  16637. maxLifeTime: number;
  16638. /**
  16639. * Minimum Size of emitting particles.
  16640. */
  16641. minSize: number;
  16642. /**
  16643. * Maximum Size of emitting particles.
  16644. */
  16645. maxSize: number;
  16646. /**
  16647. * Minimum scale of emitting particles on X axis.
  16648. */
  16649. minScaleX: number;
  16650. /**
  16651. * Maximum scale of emitting particles on X axis.
  16652. */
  16653. maxScaleX: number;
  16654. /**
  16655. * Minimum scale of emitting particles on Y axis.
  16656. */
  16657. minScaleY: number;
  16658. /**
  16659. * Maximum scale of emitting particles on Y axis.
  16660. */
  16661. maxScaleY: number;
  16662. /**
  16663. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16664. */
  16665. color1: Color4;
  16666. /**
  16667. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16668. */
  16669. color2: Color4;
  16670. /**
  16671. * Color the particle will have at the end of its lifetime.
  16672. */
  16673. colorDead: Color4;
  16674. /**
  16675. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16676. */
  16677. emitRate: number;
  16678. /**
  16679. * You can use gravity if you want to give an orientation to your particles.
  16680. */
  16681. gravity: Vector3;
  16682. /**
  16683. * Minimum power of emitting particles.
  16684. */
  16685. minEmitPower: number;
  16686. /**
  16687. * Maximum power of emitting particles.
  16688. */
  16689. maxEmitPower: number;
  16690. /**
  16691. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16692. */
  16693. minAngularSpeed: number;
  16694. /**
  16695. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16696. */
  16697. maxAngularSpeed: number;
  16698. /**
  16699. * Gets or sets the minimal initial rotation in radians.
  16700. */
  16701. minInitialRotation: number;
  16702. /**
  16703. * Gets or sets the maximal initial rotation in radians.
  16704. */
  16705. maxInitialRotation: number;
  16706. /**
  16707. * The particle emitter type defines the emitter used by the particle system.
  16708. * It can be for example box, sphere, or cone...
  16709. */
  16710. particleEmitterType: Nullable<IParticleEmitterType>;
  16711. /**
  16712. * Defines the delay in milliseconds before starting the system (0 by default)
  16713. */
  16714. startDelay: number;
  16715. /**
  16716. * 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
  16717. */
  16718. preWarmCycles: number;
  16719. /**
  16720. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16721. */
  16722. preWarmStepOffset: number;
  16723. /**
  16724. * 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)
  16725. */
  16726. spriteCellChangeSpeed: number;
  16727. /**
  16728. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16729. */
  16730. startSpriteCellID: number;
  16731. /**
  16732. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16733. */
  16734. endSpriteCellID: number;
  16735. /**
  16736. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16737. */
  16738. spriteCellWidth: number;
  16739. /**
  16740. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16741. */
  16742. spriteCellHeight: number;
  16743. /**
  16744. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16745. */
  16746. spriteRandomStartCell: boolean;
  16747. /**
  16748. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16749. */
  16750. isAnimationSheetEnabled: boolean;
  16751. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16752. translationPivot: Vector2;
  16753. /**
  16754. * Gets or sets a texture used to add random noise to particle positions
  16755. */
  16756. noiseTexture: Nullable<BaseTexture>;
  16757. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16758. noiseStrength: Vector3;
  16759. /**
  16760. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16761. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16762. */
  16763. billboardMode: number;
  16764. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16765. limitVelocityDamping: number;
  16766. /**
  16767. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16768. */
  16769. beginAnimationOnStart: boolean;
  16770. /**
  16771. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16772. */
  16773. beginAnimationFrom: number;
  16774. /**
  16775. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16776. */
  16777. beginAnimationTo: number;
  16778. /**
  16779. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16780. */
  16781. beginAnimationLoop: boolean;
  16782. /**
  16783. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16784. */
  16785. disposeOnStop: boolean;
  16786. /**
  16787. * Gets the maximum number of particles active at the same time.
  16788. * @returns The max number of active particles.
  16789. */
  16790. getCapacity(): number;
  16791. /**
  16792. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16793. * @returns True if it has been started, otherwise false.
  16794. */
  16795. isStarted(): boolean;
  16796. /**
  16797. * Animates the particle system for this frame.
  16798. */
  16799. animate(): void;
  16800. /**
  16801. * Renders the particle system in its current state.
  16802. * @returns the current number of particles
  16803. */
  16804. render(): number;
  16805. /**
  16806. * Dispose the particle system and frees its associated resources.
  16807. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16808. */
  16809. dispose(disposeTexture?: boolean): void;
  16810. /**
  16811. * Clones the particle system.
  16812. * @param name The name of the cloned object
  16813. * @param newEmitter The new emitter to use
  16814. * @returns the cloned particle system
  16815. */
  16816. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16817. /**
  16818. * Serializes the particle system to a JSON object.
  16819. * @returns the JSON object
  16820. */
  16821. serialize(): any;
  16822. /**
  16823. * Rebuild the particle system
  16824. */
  16825. rebuild(): void;
  16826. /**
  16827. * Starts the particle system and begins to emit
  16828. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16829. */
  16830. start(delay?: number): void;
  16831. /**
  16832. * Stops the particle system.
  16833. */
  16834. stop(): void;
  16835. /**
  16836. * Remove all active particles
  16837. */
  16838. reset(): void;
  16839. /**
  16840. * Is this system ready to be used/rendered
  16841. * @return true if the system is ready
  16842. */
  16843. isReady(): boolean;
  16844. /**
  16845. * Adds a new color gradient
  16846. * @param gradient defines the gradient to use (between 0 and 1)
  16847. * @param color1 defines the color to affect to the specified gradient
  16848. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16849. * @returns the current particle system
  16850. */
  16851. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16852. /**
  16853. * Remove a specific color gradient
  16854. * @param gradient defines the gradient to remove
  16855. * @returns the current particle system
  16856. */
  16857. removeColorGradient(gradient: number): IParticleSystem;
  16858. /**
  16859. * Adds a new size gradient
  16860. * @param gradient defines the gradient to use (between 0 and 1)
  16861. * @param factor defines the size factor to affect to the specified gradient
  16862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16863. * @returns the current particle system
  16864. */
  16865. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16866. /**
  16867. * Remove a specific size gradient
  16868. * @param gradient defines the gradient to remove
  16869. * @returns the current particle system
  16870. */
  16871. removeSizeGradient(gradient: number): IParticleSystem;
  16872. /**
  16873. * Gets the current list of color gradients.
  16874. * You must use addColorGradient and removeColorGradient to udpate this list
  16875. * @returns the list of color gradients
  16876. */
  16877. getColorGradients(): Nullable<Array<ColorGradient>>;
  16878. /**
  16879. * Gets the current list of size gradients.
  16880. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16881. * @returns the list of size gradients
  16882. */
  16883. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16884. /**
  16885. * Gets the current list of angular speed gradients.
  16886. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16887. * @returns the list of angular speed gradients
  16888. */
  16889. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16890. /**
  16891. * Adds a new angular speed gradient
  16892. * @param gradient defines the gradient to use (between 0 and 1)
  16893. * @param factor defines the angular speed to affect to the specified gradient
  16894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16895. * @returns the current particle system
  16896. */
  16897. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16898. /**
  16899. * Remove a specific angular speed gradient
  16900. * @param gradient defines the gradient to remove
  16901. * @returns the current particle system
  16902. */
  16903. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16904. /**
  16905. * Gets the current list of velocity gradients.
  16906. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16907. * @returns the list of velocity gradients
  16908. */
  16909. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16910. /**
  16911. * Adds a new velocity gradient
  16912. * @param gradient defines the gradient to use (between 0 and 1)
  16913. * @param factor defines the velocity to affect to the specified gradient
  16914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16915. * @returns the current particle system
  16916. */
  16917. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16918. /**
  16919. * Remove a specific velocity gradient
  16920. * @param gradient defines the gradient to remove
  16921. * @returns the current particle system
  16922. */
  16923. removeVelocityGradient(gradient: number): IParticleSystem;
  16924. /**
  16925. * Gets the current list of limit velocity gradients.
  16926. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16927. * @returns the list of limit velocity gradients
  16928. */
  16929. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16930. /**
  16931. * Adds a new limit velocity gradient
  16932. * @param gradient defines the gradient to use (between 0 and 1)
  16933. * @param factor defines the limit velocity to affect to the specified gradient
  16934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16935. * @returns the current particle system
  16936. */
  16937. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16938. /**
  16939. * Remove a specific limit velocity gradient
  16940. * @param gradient defines the gradient to remove
  16941. * @returns the current particle system
  16942. */
  16943. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16944. /**
  16945. * Adds a new drag gradient
  16946. * @param gradient defines the gradient to use (between 0 and 1)
  16947. * @param factor defines the drag to affect to the specified gradient
  16948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16949. * @returns the current particle system
  16950. */
  16951. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16952. /**
  16953. * Remove a specific drag gradient
  16954. * @param gradient defines the gradient to remove
  16955. * @returns the current particle system
  16956. */
  16957. removeDragGradient(gradient: number): IParticleSystem;
  16958. /**
  16959. * Gets the current list of drag gradients.
  16960. * You must use addDragGradient and removeDragGradient to udpate this list
  16961. * @returns the list of drag gradients
  16962. */
  16963. getDragGradients(): Nullable<Array<FactorGradient>>;
  16964. /**
  16965. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16966. * @param gradient defines the gradient to use (between 0 and 1)
  16967. * @param factor defines the emit rate to affect to the specified gradient
  16968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16969. * @returns the current particle system
  16970. */
  16971. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16972. /**
  16973. * Remove a specific emit rate gradient
  16974. * @param gradient defines the gradient to remove
  16975. * @returns the current particle system
  16976. */
  16977. removeEmitRateGradient(gradient: number): IParticleSystem;
  16978. /**
  16979. * Gets the current list of emit rate gradients.
  16980. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16981. * @returns the list of emit rate gradients
  16982. */
  16983. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16984. /**
  16985. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16986. * @param gradient defines the gradient to use (between 0 and 1)
  16987. * @param factor defines the start size to affect to the specified gradient
  16988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16989. * @returns the current particle system
  16990. */
  16991. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16992. /**
  16993. * Remove a specific start size gradient
  16994. * @param gradient defines the gradient to remove
  16995. * @returns the current particle system
  16996. */
  16997. removeStartSizeGradient(gradient: number): IParticleSystem;
  16998. /**
  16999. * Gets the current list of start size gradients.
  17000. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17001. * @returns the list of start size gradients
  17002. */
  17003. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Adds a new life time gradient
  17006. * @param gradient defines the gradient to use (between 0 and 1)
  17007. * @param factor defines the life time factor to affect to the specified gradient
  17008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17009. * @returns the current particle system
  17010. */
  17011. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17012. /**
  17013. * Remove a specific life time gradient
  17014. * @param gradient defines the gradient to remove
  17015. * @returns the current particle system
  17016. */
  17017. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17018. /**
  17019. * Gets the current list of life time gradients.
  17020. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17021. * @returns the list of life time gradients
  17022. */
  17023. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17024. /**
  17025. * Gets the current list of color gradients.
  17026. * You must use addColorGradient and removeColorGradient to udpate this list
  17027. * @returns the list of color gradients
  17028. */
  17029. getColorGradients(): Nullable<Array<ColorGradient>>;
  17030. /**
  17031. * Adds a new ramp gradient used to remap particle colors
  17032. * @param gradient defines the gradient to use (between 0 and 1)
  17033. * @param color defines the color to affect to the specified gradient
  17034. * @returns the current particle system
  17035. */
  17036. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17037. /**
  17038. * Gets the current list of ramp gradients.
  17039. * You must use addRampGradient and removeRampGradient to udpate this list
  17040. * @returns the list of ramp gradients
  17041. */
  17042. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17043. /** Gets or sets a boolean indicating that ramp gradients must be used
  17044. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17045. */
  17046. useRampGradients: boolean;
  17047. /**
  17048. * Adds a new color remap gradient
  17049. * @param gradient defines the gradient to use (between 0 and 1)
  17050. * @param min defines the color remap minimal range
  17051. * @param max defines the color remap maximal range
  17052. * @returns the current particle system
  17053. */
  17054. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17055. /**
  17056. * Gets the current list of color remap gradients.
  17057. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17058. * @returns the list of color remap gradients
  17059. */
  17060. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17061. /**
  17062. * Adds a new alpha remap gradient
  17063. * @param gradient defines the gradient to use (between 0 and 1)
  17064. * @param min defines the alpha remap minimal range
  17065. * @param max defines the alpha remap maximal range
  17066. * @returns the current particle system
  17067. */
  17068. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17069. /**
  17070. * Gets the current list of alpha remap gradients.
  17071. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17072. * @returns the list of alpha remap gradients
  17073. */
  17074. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17075. /**
  17076. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17077. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17078. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17079. * @returns the emitter
  17080. */
  17081. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17082. /**
  17083. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17084. * @param radius The radius of the hemisphere to emit from
  17085. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17086. * @returns the emitter
  17087. */
  17088. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17089. /**
  17090. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17091. * @param radius The radius of the sphere to emit from
  17092. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17093. * @returns the emitter
  17094. */
  17095. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17096. /**
  17097. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17098. * @param radius The radius of the sphere to emit from
  17099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17101. * @returns the emitter
  17102. */
  17103. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17104. /**
  17105. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17106. * @param radius The radius of the emission cylinder
  17107. * @param height The height of the emission cylinder
  17108. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17109. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17110. * @returns the emitter
  17111. */
  17112. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17113. /**
  17114. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17115. * @param radius The radius of the cylinder to emit from
  17116. * @param height The height of the emission cylinder
  17117. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17118. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17119. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17120. * @returns the emitter
  17121. */
  17122. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17123. /**
  17124. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17125. * @param radius The radius of the cone to emit from
  17126. * @param angle The base angle of the cone
  17127. * @returns the emitter
  17128. */
  17129. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17130. /**
  17131. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17134. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17135. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17136. * @returns the emitter
  17137. */
  17138. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17139. /**
  17140. * Get hosting scene
  17141. * @returns the scene
  17142. */
  17143. getScene(): Scene;
  17144. }
  17145. }
  17146. declare module "babylonjs/Meshes/instancedMesh" {
  17147. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17148. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17149. import { Camera } from "babylonjs/Cameras/camera";
  17150. import { Node } from "babylonjs/node";
  17151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17152. import { Mesh } from "babylonjs/Meshes/mesh";
  17153. import { Material } from "babylonjs/Materials/material";
  17154. import { Skeleton } from "babylonjs/Bones/skeleton";
  17155. import { Light } from "babylonjs/Lights/light";
  17156. /**
  17157. * Creates an instance based on a source mesh.
  17158. */
  17159. export class InstancedMesh extends AbstractMesh {
  17160. private _sourceMesh;
  17161. private _currentLOD;
  17162. /** @hidden */
  17163. _indexInSourceMeshInstanceArray: number;
  17164. constructor(name: string, source: Mesh);
  17165. /**
  17166. * Returns the string "InstancedMesh".
  17167. */
  17168. getClassName(): string;
  17169. /** Gets the list of lights affecting that mesh */
  17170. readonly lightSources: Light[];
  17171. _resyncLightSources(): void;
  17172. _resyncLighSource(light: Light): void;
  17173. _removeLightSource(light: Light): void;
  17174. /**
  17175. * If the source mesh receives shadows
  17176. */
  17177. readonly receiveShadows: boolean;
  17178. /**
  17179. * The material of the source mesh
  17180. */
  17181. readonly material: Nullable<Material>;
  17182. /**
  17183. * Visibility of the source mesh
  17184. */
  17185. readonly visibility: number;
  17186. /**
  17187. * Skeleton of the source mesh
  17188. */
  17189. readonly skeleton: Nullable<Skeleton>;
  17190. /**
  17191. * Rendering ground id of the source mesh
  17192. */
  17193. renderingGroupId: number;
  17194. /**
  17195. * Returns the total number of vertices (integer).
  17196. */
  17197. getTotalVertices(): number;
  17198. /**
  17199. * Returns a positive integer : the total number of indices in this mesh geometry.
  17200. * @returns the numner of indices or zero if the mesh has no geometry.
  17201. */
  17202. getTotalIndices(): number;
  17203. /**
  17204. * The source mesh of the instance
  17205. */
  17206. readonly sourceMesh: Mesh;
  17207. /**
  17208. * Is this node ready to be used/rendered
  17209. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17210. * @return {boolean} is it ready
  17211. */
  17212. isReady(completeCheck?: boolean): boolean;
  17213. /**
  17214. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17215. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17216. * @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.
  17217. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17218. */
  17219. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17220. /**
  17221. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17222. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17223. * The `data` are either a numeric array either a Float32Array.
  17224. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17225. * 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).
  17226. * Note that a new underlying VertexBuffer object is created each call.
  17227. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17228. *
  17229. * Possible `kind` values :
  17230. * - VertexBuffer.PositionKind
  17231. * - VertexBuffer.UVKind
  17232. * - VertexBuffer.UV2Kind
  17233. * - VertexBuffer.UV3Kind
  17234. * - VertexBuffer.UV4Kind
  17235. * - VertexBuffer.UV5Kind
  17236. * - VertexBuffer.UV6Kind
  17237. * - VertexBuffer.ColorKind
  17238. * - VertexBuffer.MatricesIndicesKind
  17239. * - VertexBuffer.MatricesIndicesExtraKind
  17240. * - VertexBuffer.MatricesWeightsKind
  17241. * - VertexBuffer.MatricesWeightsExtraKind
  17242. *
  17243. * Returns the Mesh.
  17244. */
  17245. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17246. /**
  17247. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17248. * If the mesh has no geometry, it is simply returned as it is.
  17249. * The `data` are either a numeric array either a Float32Array.
  17250. * No new underlying VertexBuffer object is created.
  17251. * 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.
  17252. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17253. *
  17254. * Possible `kind` values :
  17255. * - VertexBuffer.PositionKind
  17256. * - VertexBuffer.UVKind
  17257. * - VertexBuffer.UV2Kind
  17258. * - VertexBuffer.UV3Kind
  17259. * - VertexBuffer.UV4Kind
  17260. * - VertexBuffer.UV5Kind
  17261. * - VertexBuffer.UV6Kind
  17262. * - VertexBuffer.ColorKind
  17263. * - VertexBuffer.MatricesIndicesKind
  17264. * - VertexBuffer.MatricesIndicesExtraKind
  17265. * - VertexBuffer.MatricesWeightsKind
  17266. * - VertexBuffer.MatricesWeightsExtraKind
  17267. *
  17268. * Returns the Mesh.
  17269. */
  17270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17271. /**
  17272. * Sets the mesh indices.
  17273. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17274. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17275. * This method creates a new index buffer each call.
  17276. * Returns the Mesh.
  17277. */
  17278. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17279. /**
  17280. * Boolean : True if the mesh owns the requested kind of data.
  17281. */
  17282. isVerticesDataPresent(kind: string): boolean;
  17283. /**
  17284. * Returns an array of indices (IndicesArray).
  17285. */
  17286. getIndices(): Nullable<IndicesArray>;
  17287. readonly _positions: Nullable<Vector3[]>;
  17288. /**
  17289. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17290. * This means the mesh underlying bounding box and sphere are recomputed.
  17291. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17292. * @returns the current mesh
  17293. */
  17294. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17295. /** @hidden */
  17296. _preActivate(): InstancedMesh;
  17297. /** @hidden */
  17298. _activate(renderId: number): boolean;
  17299. getWorldMatrix(): Matrix;
  17300. /**
  17301. * Returns the current associated LOD AbstractMesh.
  17302. */
  17303. getLOD(camera: Camera): AbstractMesh;
  17304. /** @hidden */
  17305. _syncSubMeshes(): InstancedMesh;
  17306. /** @hidden */
  17307. _generatePointsArray(): boolean;
  17308. /**
  17309. * Creates a new InstancedMesh from the current mesh.
  17310. * - name (string) : the cloned mesh name
  17311. * - newParent (optional Node) : the optional Node to parent the clone to.
  17312. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17313. *
  17314. * Returns the clone.
  17315. */
  17316. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17317. /**
  17318. * Disposes the InstancedMesh.
  17319. * Returns nothing.
  17320. */
  17321. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17322. }
  17323. }
  17324. declare module "babylonjs/Materials/shaderMaterial" {
  17325. import { Scene } from "babylonjs/scene";
  17326. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17328. import { Mesh } from "babylonjs/Meshes/mesh";
  17329. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17331. import { Texture } from "babylonjs/Materials/Textures/texture";
  17332. import { Material } from "babylonjs/Materials/material";
  17333. /**
  17334. * Defines the options associated with the creation of a shader material.
  17335. */
  17336. export interface IShaderMaterialOptions {
  17337. /**
  17338. * Does the material work in alpha blend mode
  17339. */
  17340. needAlphaBlending: boolean;
  17341. /**
  17342. * Does the material work in alpha test mode
  17343. */
  17344. needAlphaTesting: boolean;
  17345. /**
  17346. * The list of attribute names used in the shader
  17347. */
  17348. attributes: string[];
  17349. /**
  17350. * The list of unifrom names used in the shader
  17351. */
  17352. uniforms: string[];
  17353. /**
  17354. * The list of UBO names used in the shader
  17355. */
  17356. uniformBuffers: string[];
  17357. /**
  17358. * The list of sampler names used in the shader
  17359. */
  17360. samplers: string[];
  17361. /**
  17362. * The list of defines used in the shader
  17363. */
  17364. defines: string[];
  17365. }
  17366. /**
  17367. * 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.
  17368. *
  17369. * This returned material effects how the mesh will look based on the code in the shaders.
  17370. *
  17371. * @see http://doc.babylonjs.com/how_to/shader_material
  17372. */
  17373. export class ShaderMaterial extends Material {
  17374. private _shaderPath;
  17375. private _options;
  17376. private _textures;
  17377. private _textureArrays;
  17378. private _floats;
  17379. private _ints;
  17380. private _floatsArrays;
  17381. private _colors3;
  17382. private _colors3Arrays;
  17383. private _colors4;
  17384. private _vectors2;
  17385. private _vectors3;
  17386. private _vectors4;
  17387. private _matrices;
  17388. private _matrices3x3;
  17389. private _matrices2x2;
  17390. private _vectors2Arrays;
  17391. private _vectors3Arrays;
  17392. private _cachedWorldViewMatrix;
  17393. private _renderId;
  17394. /**
  17395. * Instantiate a new shader material.
  17396. * 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.
  17397. * This returned material effects how the mesh will look based on the code in the shaders.
  17398. * @see http://doc.babylonjs.com/how_to/shader_material
  17399. * @param name Define the name of the material in the scene
  17400. * @param scene Define the scene the material belongs to
  17401. * @param shaderPath Defines the route to the shader code in one of three ways:
  17402. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17403. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17404. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17405. * @param options Define the options used to create the shader
  17406. */
  17407. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17408. /**
  17409. * Gets the options used to compile the shader.
  17410. * They can be modified to trigger a new compilation
  17411. */
  17412. readonly options: IShaderMaterialOptions;
  17413. /**
  17414. * Gets the current class name of the material e.g. "ShaderMaterial"
  17415. * Mainly use in serialization.
  17416. * @returns the class name
  17417. */
  17418. getClassName(): string;
  17419. /**
  17420. * Specifies if the material will require alpha blending
  17421. * @returns a boolean specifying if alpha blending is needed
  17422. */
  17423. needAlphaBlending(): boolean;
  17424. /**
  17425. * Specifies if this material should be rendered in alpha test mode
  17426. * @returns a boolean specifying if an alpha test is needed.
  17427. */
  17428. needAlphaTesting(): boolean;
  17429. private _checkUniform;
  17430. /**
  17431. * Set a texture in the shader.
  17432. * @param name Define the name of the uniform samplers as defined in the shader
  17433. * @param texture Define the texture to bind to this sampler
  17434. * @return the material itself allowing "fluent" like uniform updates
  17435. */
  17436. setTexture(name: string, texture: Texture): ShaderMaterial;
  17437. /**
  17438. * Set a texture array in the shader.
  17439. * @param name Define the name of the uniform sampler array as defined in the shader
  17440. * @param textures Define the list of textures to bind to this sampler
  17441. * @return the material itself allowing "fluent" like uniform updates
  17442. */
  17443. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17444. /**
  17445. * Set a float in the shader.
  17446. * @param name Define the name of the uniform as defined in the shader
  17447. * @param value Define the value to give to the uniform
  17448. * @return the material itself allowing "fluent" like uniform updates
  17449. */
  17450. setFloat(name: string, value: number): ShaderMaterial;
  17451. /**
  17452. * Set a int in the shader.
  17453. * @param name Define the name of the uniform as defined in the shader
  17454. * @param value Define the value to give to the uniform
  17455. * @return the material itself allowing "fluent" like uniform updates
  17456. */
  17457. setInt(name: string, value: number): ShaderMaterial;
  17458. /**
  17459. * Set an array of floats in the shader.
  17460. * @param name Define the name of the uniform as defined in the shader
  17461. * @param value Define the value to give to the uniform
  17462. * @return the material itself allowing "fluent" like uniform updates
  17463. */
  17464. setFloats(name: string, value: number[]): ShaderMaterial;
  17465. /**
  17466. * Set a vec3 in the shader from a Color3.
  17467. * @param name Define the name of the uniform as defined in the shader
  17468. * @param value Define the value to give to the uniform
  17469. * @return the material itself allowing "fluent" like uniform updates
  17470. */
  17471. setColor3(name: string, value: Color3): ShaderMaterial;
  17472. /**
  17473. * Set a vec3 array in the shader from a Color3 array.
  17474. * @param name Define the name of the uniform as defined in the shader
  17475. * @param value Define the value to give to the uniform
  17476. * @return the material itself allowing "fluent" like uniform updates
  17477. */
  17478. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17479. /**
  17480. * Set a vec4 in the shader from a Color4.
  17481. * @param name Define the name of the uniform as defined in the shader
  17482. * @param value Define the value to give to the uniform
  17483. * @return the material itself allowing "fluent" like uniform updates
  17484. */
  17485. setColor4(name: string, value: Color4): ShaderMaterial;
  17486. /**
  17487. * Set a vec2 in the shader from a Vector2.
  17488. * @param name Define the name of the uniform as defined in the shader
  17489. * @param value Define the value to give to the uniform
  17490. * @return the material itself allowing "fluent" like uniform updates
  17491. */
  17492. setVector2(name: string, value: Vector2): ShaderMaterial;
  17493. /**
  17494. * Set a vec3 in the shader from a Vector3.
  17495. * @param name Define the name of the uniform as defined in the shader
  17496. * @param value Define the value to give to the uniform
  17497. * @return the material itself allowing "fluent" like uniform updates
  17498. */
  17499. setVector3(name: string, value: Vector3): ShaderMaterial;
  17500. /**
  17501. * Set a vec4 in the shader from a Vector4.
  17502. * @param name Define the name of the uniform as defined in the shader
  17503. * @param value Define the value to give to the uniform
  17504. * @return the material itself allowing "fluent" like uniform updates
  17505. */
  17506. setVector4(name: string, value: Vector4): ShaderMaterial;
  17507. /**
  17508. * Set a mat4 in the shader from a Matrix.
  17509. * @param name Define the name of the uniform as defined in the shader
  17510. * @param value Define the value to give to the uniform
  17511. * @return the material itself allowing "fluent" like uniform updates
  17512. */
  17513. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17514. /**
  17515. * Set a mat3 in the shader from a Float32Array.
  17516. * @param name Define the name of the uniform as defined in the shader
  17517. * @param value Define the value to give to the uniform
  17518. * @return the material itself allowing "fluent" like uniform updates
  17519. */
  17520. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17521. /**
  17522. * Set a mat2 in the shader from a Float32Array.
  17523. * @param name Define the name of the uniform as defined in the shader
  17524. * @param value Define the value to give to the uniform
  17525. * @return the material itself allowing "fluent" like uniform updates
  17526. */
  17527. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17528. /**
  17529. * Set a vec2 array in the shader from a number array.
  17530. * @param name Define the name of the uniform as defined in the shader
  17531. * @param value Define the value to give to the uniform
  17532. * @return the material itself allowing "fluent" like uniform updates
  17533. */
  17534. setArray2(name: string, value: number[]): ShaderMaterial;
  17535. /**
  17536. * Set a vec3 array in the shader from a number array.
  17537. * @param name Define the name of the uniform as defined in the shader
  17538. * @param value Define the value to give to the uniform
  17539. * @return the material itself allowing "fluent" like uniform updates
  17540. */
  17541. setArray3(name: string, value: number[]): ShaderMaterial;
  17542. private _checkCache;
  17543. /**
  17544. * Specifies that the submesh is ready to be used
  17545. * @param mesh defines the mesh to check
  17546. * @param subMesh defines which submesh to check
  17547. * @param useInstances specifies that instances should be used
  17548. * @returns a boolean indicating that the submesh is ready or not
  17549. */
  17550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17551. /**
  17552. * Checks if the material is ready to render the requested mesh
  17553. * @param mesh Define the mesh to render
  17554. * @param useInstances Define whether or not the material is used with instances
  17555. * @returns true if ready, otherwise false
  17556. */
  17557. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17558. /**
  17559. * Binds the world matrix to the material
  17560. * @param world defines the world transformation matrix
  17561. */
  17562. bindOnlyWorldMatrix(world: Matrix): void;
  17563. /**
  17564. * Binds the material to the mesh
  17565. * @param world defines the world transformation matrix
  17566. * @param mesh defines the mesh to bind the material to
  17567. */
  17568. bind(world: Matrix, mesh?: Mesh): void;
  17569. /**
  17570. * Gets the active textures from the material
  17571. * @returns an array of textures
  17572. */
  17573. getActiveTextures(): BaseTexture[];
  17574. /**
  17575. * Specifies if the material uses a texture
  17576. * @param texture defines the texture to check against the material
  17577. * @returns a boolean specifying if the material uses the texture
  17578. */
  17579. hasTexture(texture: BaseTexture): boolean;
  17580. /**
  17581. * Makes a duplicate of the material, and gives it a new name
  17582. * @param name defines the new name for the duplicated material
  17583. * @returns the cloned material
  17584. */
  17585. clone(name: string): ShaderMaterial;
  17586. /**
  17587. * Disposes the material
  17588. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17589. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17590. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17591. */
  17592. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17593. /**
  17594. * Serializes this material in a JSON representation
  17595. * @returns the serialized material object
  17596. */
  17597. serialize(): any;
  17598. /**
  17599. * Creates a shader material from parsed shader material data
  17600. * @param source defines the JSON represnetation of the material
  17601. * @param scene defines the hosting scene
  17602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17603. * @returns a new material
  17604. */
  17605. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17606. }
  17607. }
  17608. declare module "babylonjs/Shaders/color.fragment" {
  17609. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17611. /** @hidden */
  17612. export var colorPixelShader: {
  17613. name: string;
  17614. shader: string;
  17615. };
  17616. }
  17617. declare module "babylonjs/Shaders/color.vertex" {
  17618. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17619. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17620. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17621. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17622. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17623. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17624. /** @hidden */
  17625. export var colorVertexShader: {
  17626. name: string;
  17627. shader: string;
  17628. };
  17629. }
  17630. declare module "babylonjs/Meshes/linesMesh" {
  17631. import { Nullable } from "babylonjs/types";
  17632. import { Scene } from "babylonjs/scene";
  17633. import { Color3 } from "babylonjs/Maths/math";
  17634. import { Node } from "babylonjs/node";
  17635. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17636. import { Mesh } from "babylonjs/Meshes/mesh";
  17637. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17638. import { Effect } from "babylonjs/Materials/effect";
  17639. import { Material } from "babylonjs/Materials/material";
  17640. import "babylonjs/Shaders/color.fragment";
  17641. import "babylonjs/Shaders/color.vertex";
  17642. /**
  17643. * Line mesh
  17644. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17645. */
  17646. export class LinesMesh extends Mesh {
  17647. /**
  17648. * If vertex color should be applied to the mesh
  17649. */
  17650. useVertexColor?: boolean | undefined;
  17651. /**
  17652. * If vertex alpha should be applied to the mesh
  17653. */
  17654. useVertexAlpha?: boolean | undefined;
  17655. /**
  17656. * Color of the line (Default: White)
  17657. */
  17658. color: Color3;
  17659. /**
  17660. * Alpha of the line (Default: 1)
  17661. */
  17662. alpha: number;
  17663. /**
  17664. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17665. * This margin is expressed in world space coordinates, so its value may vary.
  17666. * Default value is 0.1
  17667. */
  17668. intersectionThreshold: number;
  17669. private _colorShader;
  17670. /**
  17671. * Creates a new LinesMesh
  17672. * @param name defines the name
  17673. * @param scene defines the hosting scene
  17674. * @param parent defines the parent mesh if any
  17675. * @param source defines the optional source LinesMesh used to clone data from
  17676. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17677. * When false, achieved by calling a clone(), also passing False.
  17678. * This will make creation of children, recursive.
  17679. * @param useVertexColor defines if this LinesMesh supports vertex color
  17680. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17681. */
  17682. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17683. /**
  17684. * If vertex color should be applied to the mesh
  17685. */
  17686. useVertexColor?: boolean | undefined,
  17687. /**
  17688. * If vertex alpha should be applied to the mesh
  17689. */
  17690. useVertexAlpha?: boolean | undefined);
  17691. private _addClipPlaneDefine;
  17692. private _removeClipPlaneDefine;
  17693. isReady(): boolean;
  17694. /**
  17695. * Returns the string "LineMesh"
  17696. */
  17697. getClassName(): string;
  17698. /**
  17699. * @hidden
  17700. */
  17701. /**
  17702. * @hidden
  17703. */
  17704. material: Material;
  17705. /**
  17706. * @hidden
  17707. */
  17708. readonly checkCollisions: boolean;
  17709. /** @hidden */
  17710. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17711. /** @hidden */
  17712. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17713. /**
  17714. * Disposes of the line mesh
  17715. * @param doNotRecurse If children should be disposed
  17716. */
  17717. dispose(doNotRecurse?: boolean): void;
  17718. /**
  17719. * Returns a new LineMesh object cloned from the current one.
  17720. */
  17721. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17722. /**
  17723. * Creates a new InstancedLinesMesh object from the mesh model.
  17724. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17725. * @param name defines the name of the new instance
  17726. * @returns a new InstancedLinesMesh
  17727. */
  17728. createInstance(name: string): InstancedLinesMesh;
  17729. }
  17730. /**
  17731. * Creates an instance based on a source LinesMesh
  17732. */
  17733. export class InstancedLinesMesh extends InstancedMesh {
  17734. /**
  17735. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17736. * This margin is expressed in world space coordinates, so its value may vary.
  17737. * Initilized with the intersectionThreshold value of the source LinesMesh
  17738. */
  17739. intersectionThreshold: number;
  17740. constructor(name: string, source: LinesMesh);
  17741. /**
  17742. * Returns the string "InstancedLinesMesh".
  17743. */
  17744. getClassName(): string;
  17745. }
  17746. }
  17747. declare module "babylonjs/Shaders/line.fragment" {
  17748. /** @hidden */
  17749. export var linePixelShader: {
  17750. name: string;
  17751. shader: string;
  17752. };
  17753. }
  17754. declare module "babylonjs/Shaders/line.vertex" {
  17755. /** @hidden */
  17756. export var lineVertexShader: {
  17757. name: string;
  17758. shader: string;
  17759. };
  17760. }
  17761. declare module "babylonjs/Rendering/edgesRenderer" {
  17762. import { Nullable } from "babylonjs/types";
  17763. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17765. import { Vector3 } from "babylonjs/Maths/math";
  17766. import { IDisposable } from "babylonjs/scene";
  17767. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17768. import "babylonjs/Shaders/line.fragment";
  17769. import "babylonjs/Shaders/line.vertex";
  17770. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17771. module "babylonjs/Meshes/abstractMesh" {
  17772. interface AbstractMesh {
  17773. /**
  17774. * Disables the mesh edge rendering mode
  17775. * @returns the currentAbstractMesh
  17776. */
  17777. disableEdgesRendering(): AbstractMesh;
  17778. /**
  17779. * Enables the edge rendering mode on the mesh.
  17780. * This mode makes the mesh edges visible
  17781. * @param epsilon defines the maximal distance between two angles to detect a face
  17782. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17783. * @returns the currentAbstractMesh
  17784. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17785. */
  17786. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17787. /**
  17788. * Gets the edgesRenderer associated with the mesh
  17789. */
  17790. edgesRenderer: Nullable<EdgesRenderer>;
  17791. }
  17792. }
  17793. module "babylonjs/Meshes/linesMesh" {
  17794. interface LinesMesh {
  17795. /**
  17796. * Enables the edge rendering mode on the mesh.
  17797. * This mode makes the mesh edges visible
  17798. * @param epsilon defines the maximal distance between two angles to detect a face
  17799. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17800. * @returns the currentAbstractMesh
  17801. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17802. */
  17803. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17804. }
  17805. }
  17806. module "babylonjs/Meshes/linesMesh" {
  17807. interface InstancedLinesMesh {
  17808. /**
  17809. * Enables the edge rendering mode on the mesh.
  17810. * This mode makes the mesh edges visible
  17811. * @param epsilon defines the maximal distance between two angles to detect a face
  17812. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17813. * @returns the current InstancedLinesMesh
  17814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17815. */
  17816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17817. }
  17818. }
  17819. /**
  17820. * Defines the minimum contract an Edges renderer should follow.
  17821. */
  17822. export interface IEdgesRenderer extends IDisposable {
  17823. /**
  17824. * Gets or sets a boolean indicating if the edgesRenderer is active
  17825. */
  17826. isEnabled: boolean;
  17827. /**
  17828. * Renders the edges of the attached mesh,
  17829. */
  17830. render(): void;
  17831. /**
  17832. * Checks wether or not the edges renderer is ready to render.
  17833. * @return true if ready, otherwise false.
  17834. */
  17835. isReady(): boolean;
  17836. }
  17837. /**
  17838. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17839. */
  17840. export class EdgesRenderer implements IEdgesRenderer {
  17841. /**
  17842. * Define the size of the edges with an orthographic camera
  17843. */
  17844. edgesWidthScalerForOrthographic: number;
  17845. /**
  17846. * Define the size of the edges with a perspective camera
  17847. */
  17848. edgesWidthScalerForPerspective: number;
  17849. protected _source: AbstractMesh;
  17850. protected _linesPositions: number[];
  17851. protected _linesNormals: number[];
  17852. protected _linesIndices: number[];
  17853. protected _epsilon: number;
  17854. protected _indicesCount: number;
  17855. protected _lineShader: ShaderMaterial;
  17856. protected _ib: DataBuffer;
  17857. protected _buffers: {
  17858. [key: string]: Nullable<VertexBuffer>;
  17859. };
  17860. protected _checkVerticesInsteadOfIndices: boolean;
  17861. private _meshRebuildObserver;
  17862. private _meshDisposeObserver;
  17863. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17864. isEnabled: boolean;
  17865. /**
  17866. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17867. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17868. * @param source Mesh used to create edges
  17869. * @param epsilon sum of angles in adjacency to check for edge
  17870. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17871. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17872. */
  17873. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17874. protected _prepareRessources(): void;
  17875. /** @hidden */
  17876. _rebuild(): void;
  17877. /**
  17878. * Releases the required resources for the edges renderer
  17879. */
  17880. dispose(): void;
  17881. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17882. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17883. /**
  17884. * Checks if the pair of p0 and p1 is en edge
  17885. * @param faceIndex
  17886. * @param edge
  17887. * @param faceNormals
  17888. * @param p0
  17889. * @param p1
  17890. * @private
  17891. */
  17892. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17893. /**
  17894. * push line into the position, normal and index buffer
  17895. * @protected
  17896. */
  17897. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17898. /**
  17899. * Generates lines edges from adjacencjes
  17900. * @private
  17901. */
  17902. _generateEdgesLines(): void;
  17903. /**
  17904. * Checks wether or not the edges renderer is ready to render.
  17905. * @return true if ready, otherwise false.
  17906. */
  17907. isReady(): boolean;
  17908. /**
  17909. * Renders the edges of the attached mesh,
  17910. */
  17911. render(): void;
  17912. }
  17913. /**
  17914. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17915. */
  17916. export class LineEdgesRenderer extends EdgesRenderer {
  17917. /**
  17918. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17919. * @param source LineMesh used to generate edges
  17920. * @param epsilon not important (specified angle for edge detection)
  17921. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17922. */
  17923. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17924. /**
  17925. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17926. */
  17927. _generateEdgesLines(): void;
  17928. }
  17929. }
  17930. declare module "babylonjs/Rendering/renderingGroup" {
  17931. import { SmartArray } from "babylonjs/Misc/smartArray";
  17932. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17934. import { Nullable } from "babylonjs/types";
  17935. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17936. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17937. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17938. import { Material } from "babylonjs/Materials/material";
  17939. import { Scene } from "babylonjs/scene";
  17940. /**
  17941. * This represents the object necessary to create a rendering group.
  17942. * This is exclusively used and created by the rendering manager.
  17943. * To modify the behavior, you use the available helpers in your scene or meshes.
  17944. * @hidden
  17945. */
  17946. export class RenderingGroup {
  17947. index: number;
  17948. private _scene;
  17949. private _opaqueSubMeshes;
  17950. private _transparentSubMeshes;
  17951. private _alphaTestSubMeshes;
  17952. private _depthOnlySubMeshes;
  17953. private _particleSystems;
  17954. private _spriteManagers;
  17955. private _opaqueSortCompareFn;
  17956. private _alphaTestSortCompareFn;
  17957. private _transparentSortCompareFn;
  17958. private _renderOpaque;
  17959. private _renderAlphaTest;
  17960. private _renderTransparent;
  17961. /** @hidden */
  17962. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17963. onBeforeTransparentRendering: () => void;
  17964. /**
  17965. * Set the opaque sort comparison function.
  17966. * If null the sub meshes will be render in the order they were created
  17967. */
  17968. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17969. /**
  17970. * Set the alpha test sort comparison function.
  17971. * If null the sub meshes will be render in the order they were created
  17972. */
  17973. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17974. /**
  17975. * Set the transparent sort comparison function.
  17976. * If null the sub meshes will be render in the order they were created
  17977. */
  17978. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17979. /**
  17980. * Creates a new rendering group.
  17981. * @param index The rendering group index
  17982. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17983. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17984. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17985. */
  17986. 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>);
  17987. /**
  17988. * Render all the sub meshes contained in the group.
  17989. * @param customRenderFunction Used to override the default render behaviour of the group.
  17990. * @returns true if rendered some submeshes.
  17991. */
  17992. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17993. /**
  17994. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17995. * @param subMeshes The submeshes to render
  17996. */
  17997. private renderOpaqueSorted;
  17998. /**
  17999. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18000. * @param subMeshes The submeshes to render
  18001. */
  18002. private renderAlphaTestSorted;
  18003. /**
  18004. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18005. * @param subMeshes The submeshes to render
  18006. */
  18007. private renderTransparentSorted;
  18008. /**
  18009. * Renders the submeshes in a specified order.
  18010. * @param subMeshes The submeshes to sort before render
  18011. * @param sortCompareFn The comparison function use to sort
  18012. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18013. * @param transparent Specifies to activate blending if true
  18014. */
  18015. private static renderSorted;
  18016. /**
  18017. * Renders the submeshes in the order they were dispatched (no sort applied).
  18018. * @param subMeshes The submeshes to render
  18019. */
  18020. private static renderUnsorted;
  18021. /**
  18022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18023. * are rendered back to front if in the same alpha index.
  18024. *
  18025. * @param a The first submesh
  18026. * @param b The second submesh
  18027. * @returns The result of the comparison
  18028. */
  18029. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18030. /**
  18031. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18032. * are rendered back to front.
  18033. *
  18034. * @param a The first submesh
  18035. * @param b The second submesh
  18036. * @returns The result of the comparison
  18037. */
  18038. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18039. /**
  18040. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18041. * are rendered front to back (prevent overdraw).
  18042. *
  18043. * @param a The first submesh
  18044. * @param b The second submesh
  18045. * @returns The result of the comparison
  18046. */
  18047. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18048. /**
  18049. * Resets the different lists of submeshes to prepare a new frame.
  18050. */
  18051. prepare(): void;
  18052. dispose(): void;
  18053. /**
  18054. * Inserts the submesh in its correct queue depending on its material.
  18055. * @param subMesh The submesh to dispatch
  18056. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18057. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18058. */
  18059. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18060. dispatchSprites(spriteManager: ISpriteManager): void;
  18061. dispatchParticles(particleSystem: IParticleSystem): void;
  18062. private _renderParticles;
  18063. private _renderSprites;
  18064. }
  18065. }
  18066. declare module "babylonjs/Rendering/renderingManager" {
  18067. import { Nullable } from "babylonjs/types";
  18068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18070. import { SmartArray } from "babylonjs/Misc/smartArray";
  18071. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18073. import { Material } from "babylonjs/Materials/material";
  18074. import { Scene } from "babylonjs/scene";
  18075. import { Camera } from "babylonjs/Cameras/camera";
  18076. /**
  18077. * Interface describing the different options available in the rendering manager
  18078. * regarding Auto Clear between groups.
  18079. */
  18080. export interface IRenderingManagerAutoClearSetup {
  18081. /**
  18082. * Defines whether or not autoclear is enable.
  18083. */
  18084. autoClear: boolean;
  18085. /**
  18086. * Defines whether or not to autoclear the depth buffer.
  18087. */
  18088. depth: boolean;
  18089. /**
  18090. * Defines whether or not to autoclear the stencil buffer.
  18091. */
  18092. stencil: boolean;
  18093. }
  18094. /**
  18095. * This class is used by the onRenderingGroupObservable
  18096. */
  18097. export class RenderingGroupInfo {
  18098. /**
  18099. * The Scene that being rendered
  18100. */
  18101. scene: Scene;
  18102. /**
  18103. * The camera currently used for the rendering pass
  18104. */
  18105. camera: Nullable<Camera>;
  18106. /**
  18107. * The ID of the renderingGroup being processed
  18108. */
  18109. renderingGroupId: number;
  18110. }
  18111. /**
  18112. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18113. * It is enable to manage the different groups as well as the different necessary sort functions.
  18114. * This should not be used directly aside of the few static configurations
  18115. */
  18116. export class RenderingManager {
  18117. /**
  18118. * The max id used for rendering groups (not included)
  18119. */
  18120. static MAX_RENDERINGGROUPS: number;
  18121. /**
  18122. * The min id used for rendering groups (included)
  18123. */
  18124. static MIN_RENDERINGGROUPS: number;
  18125. /**
  18126. * Used to globally prevent autoclearing scenes.
  18127. */
  18128. static AUTOCLEAR: boolean;
  18129. /**
  18130. * @hidden
  18131. */
  18132. _useSceneAutoClearSetup: boolean;
  18133. private _scene;
  18134. private _renderingGroups;
  18135. private _depthStencilBufferAlreadyCleaned;
  18136. private _autoClearDepthStencil;
  18137. private _customOpaqueSortCompareFn;
  18138. private _customAlphaTestSortCompareFn;
  18139. private _customTransparentSortCompareFn;
  18140. private _renderingGroupInfo;
  18141. /**
  18142. * Instantiates a new rendering group for a particular scene
  18143. * @param scene Defines the scene the groups belongs to
  18144. */
  18145. constructor(scene: Scene);
  18146. private _clearDepthStencilBuffer;
  18147. /**
  18148. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18149. * @hidden
  18150. */
  18151. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18152. /**
  18153. * Resets the different information of the group to prepare a new frame
  18154. * @hidden
  18155. */
  18156. reset(): void;
  18157. /**
  18158. * Dispose and release the group and its associated resources.
  18159. * @hidden
  18160. */
  18161. dispose(): void;
  18162. /**
  18163. * Clear the info related to rendering groups preventing retention points during dispose.
  18164. */
  18165. freeRenderingGroups(): void;
  18166. private _prepareRenderingGroup;
  18167. /**
  18168. * Add a sprite manager to the rendering manager in order to render it this frame.
  18169. * @param spriteManager Define the sprite manager to render
  18170. */
  18171. dispatchSprites(spriteManager: ISpriteManager): void;
  18172. /**
  18173. * Add a particle system to the rendering manager in order to render it this frame.
  18174. * @param particleSystem Define the particle system to render
  18175. */
  18176. dispatchParticles(particleSystem: IParticleSystem): void;
  18177. /**
  18178. * Add a submesh to the manager in order to render it this frame
  18179. * @param subMesh The submesh to dispatch
  18180. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18181. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18182. */
  18183. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18184. /**
  18185. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18186. * This allowed control for front to back rendering or reversly depending of the special needs.
  18187. *
  18188. * @param renderingGroupId The rendering group id corresponding to its index
  18189. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18190. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18191. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18192. */
  18193. 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;
  18194. /**
  18195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18196. *
  18197. * @param renderingGroupId The rendering group id corresponding to its index
  18198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18199. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18200. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18201. */
  18202. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18203. /**
  18204. * Gets the current auto clear configuration for one rendering group of the rendering
  18205. * manager.
  18206. * @param index the rendering group index to get the information for
  18207. * @returns The auto clear setup for the requested rendering group
  18208. */
  18209. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18210. }
  18211. }
  18212. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18213. import { Observable } from "babylonjs/Misc/observable";
  18214. import { SmartArray } from "babylonjs/Misc/smartArray";
  18215. import { Nullable } from "babylonjs/types";
  18216. import { Camera } from "babylonjs/Cameras/camera";
  18217. import { Scene } from "babylonjs/scene";
  18218. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18219. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18222. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18223. import { Texture } from "babylonjs/Materials/Textures/texture";
  18224. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18225. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18226. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18227. import { Engine } from "babylonjs/Engines/engine";
  18228. /**
  18229. * This Helps creating a texture that will be created from a camera in your scene.
  18230. * It is basically a dynamic texture that could be used to create special effects for instance.
  18231. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18232. */
  18233. export class RenderTargetTexture extends Texture {
  18234. isCube: boolean;
  18235. /**
  18236. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18237. */
  18238. static readonly REFRESHRATE_RENDER_ONCE: number;
  18239. /**
  18240. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18241. */
  18242. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18243. /**
  18244. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18245. * the central point of your effect and can save a lot of performances.
  18246. */
  18247. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18248. /**
  18249. * Use this predicate to dynamically define the list of mesh you want to render.
  18250. * If set, the renderList property will be overwritten.
  18251. */
  18252. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18253. private _renderList;
  18254. /**
  18255. * Use this list to define the list of mesh you want to render.
  18256. */
  18257. renderList: Nullable<Array<AbstractMesh>>;
  18258. private _hookArray;
  18259. /**
  18260. * Define if particles should be rendered in your texture.
  18261. */
  18262. renderParticles: boolean;
  18263. /**
  18264. * Define if sprites should be rendered in your texture.
  18265. */
  18266. renderSprites: boolean;
  18267. /**
  18268. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18269. */
  18270. coordinatesMode: number;
  18271. /**
  18272. * Define the camera used to render the texture.
  18273. */
  18274. activeCamera: Nullable<Camera>;
  18275. /**
  18276. * Override the render function of the texture with your own one.
  18277. */
  18278. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18279. /**
  18280. * Define if camera post processes should be use while rendering the texture.
  18281. */
  18282. useCameraPostProcesses: boolean;
  18283. /**
  18284. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18285. */
  18286. ignoreCameraViewport: boolean;
  18287. private _postProcessManager;
  18288. private _postProcesses;
  18289. private _resizeObserver;
  18290. /**
  18291. * An event triggered when the texture is unbind.
  18292. */
  18293. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18294. /**
  18295. * An event triggered when the texture is unbind.
  18296. */
  18297. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18298. private _onAfterUnbindObserver;
  18299. /**
  18300. * Set a after unbind callback in the texture.
  18301. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18302. */
  18303. onAfterUnbind: () => void;
  18304. /**
  18305. * An event triggered before rendering the texture
  18306. */
  18307. onBeforeRenderObservable: Observable<number>;
  18308. private _onBeforeRenderObserver;
  18309. /**
  18310. * Set a before render callback in the texture.
  18311. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18312. */
  18313. onBeforeRender: (faceIndex: number) => void;
  18314. /**
  18315. * An event triggered after rendering the texture
  18316. */
  18317. onAfterRenderObservable: Observable<number>;
  18318. private _onAfterRenderObserver;
  18319. /**
  18320. * Set a after render callback in the texture.
  18321. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18322. */
  18323. onAfterRender: (faceIndex: number) => void;
  18324. /**
  18325. * An event triggered after the texture clear
  18326. */
  18327. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18328. private _onClearObserver;
  18329. /**
  18330. * Set a clear callback in the texture.
  18331. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18332. */
  18333. onClear: (Engine: Engine) => void;
  18334. /**
  18335. * Define the clear color of the Render Target if it should be different from the scene.
  18336. */
  18337. clearColor: Color4;
  18338. protected _size: number | {
  18339. width: number;
  18340. height: number;
  18341. };
  18342. protected _initialSizeParameter: number | {
  18343. width: number;
  18344. height: number;
  18345. } | {
  18346. ratio: number;
  18347. };
  18348. protected _sizeRatio: Nullable<number>;
  18349. /** @hidden */
  18350. _generateMipMaps: boolean;
  18351. protected _renderingManager: RenderingManager;
  18352. /** @hidden */
  18353. _waitingRenderList: string[];
  18354. protected _doNotChangeAspectRatio: boolean;
  18355. protected _currentRefreshId: number;
  18356. protected _refreshRate: number;
  18357. protected _textureMatrix: Matrix;
  18358. protected _samples: number;
  18359. protected _renderTargetOptions: RenderTargetCreationOptions;
  18360. /**
  18361. * Gets render target creation options that were used.
  18362. */
  18363. readonly renderTargetOptions: RenderTargetCreationOptions;
  18364. protected _engine: Engine;
  18365. protected _onRatioRescale(): void;
  18366. /**
  18367. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18368. * It must define where the camera used to render the texture is set
  18369. */
  18370. boundingBoxPosition: Vector3;
  18371. private _boundingBoxSize;
  18372. /**
  18373. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18374. * When defined, the cubemap will switch to local mode
  18375. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18376. * @example https://www.babylonjs-playground.com/#RNASML
  18377. */
  18378. boundingBoxSize: Vector3;
  18379. /**
  18380. * In case the RTT has been created with a depth texture, get the associated
  18381. * depth texture.
  18382. * Otherwise, return null.
  18383. */
  18384. depthStencilTexture: Nullable<InternalTexture>;
  18385. /**
  18386. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18387. * or used a shadow, depth texture...
  18388. * @param name The friendly name of the texture
  18389. * @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)
  18390. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18391. * @param generateMipMaps True if mip maps need to be generated after render.
  18392. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18393. * @param type The type of the buffer in the RTT (int, half float, float...)
  18394. * @param isCube True if a cube texture needs to be created
  18395. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18396. * @param generateDepthBuffer True to generate a depth buffer
  18397. * @param generateStencilBuffer True to generate a stencil buffer
  18398. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18399. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18400. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18401. */
  18402. constructor(name: string, size: number | {
  18403. width: number;
  18404. height: number;
  18405. } | {
  18406. ratio: number;
  18407. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18408. /**
  18409. * Creates a depth stencil texture.
  18410. * This is only available in WebGL 2 or with the depth texture extension available.
  18411. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18412. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18413. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18414. */
  18415. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18416. private _processSizeParameter;
  18417. /**
  18418. * Define the number of samples to use in case of MSAA.
  18419. * It defaults to one meaning no MSAA has been enabled.
  18420. */
  18421. samples: number;
  18422. /**
  18423. * Resets the refresh counter of the texture and start bak from scratch.
  18424. * Could be useful to regenerate the texture if it is setup to render only once.
  18425. */
  18426. resetRefreshCounter(): void;
  18427. /**
  18428. * Define the refresh rate of the texture or the rendering frequency.
  18429. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18430. */
  18431. refreshRate: number;
  18432. /**
  18433. * Adds a post process to the render target rendering passes.
  18434. * @param postProcess define the post process to add
  18435. */
  18436. addPostProcess(postProcess: PostProcess): void;
  18437. /**
  18438. * Clear all the post processes attached to the render target
  18439. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18440. */
  18441. clearPostProcesses(dispose?: boolean): void;
  18442. /**
  18443. * Remove one of the post process from the list of attached post processes to the texture
  18444. * @param postProcess define the post process to remove from the list
  18445. */
  18446. removePostProcess(postProcess: PostProcess): void;
  18447. /** @hidden */
  18448. _shouldRender(): boolean;
  18449. /**
  18450. * Gets the actual render size of the texture.
  18451. * @returns the width of the render size
  18452. */
  18453. getRenderSize(): number;
  18454. /**
  18455. * Gets the actual render width of the texture.
  18456. * @returns the width of the render size
  18457. */
  18458. getRenderWidth(): number;
  18459. /**
  18460. * Gets the actual render height of the texture.
  18461. * @returns the height of the render size
  18462. */
  18463. getRenderHeight(): number;
  18464. /**
  18465. * Get if the texture can be rescaled or not.
  18466. */
  18467. readonly canRescale: boolean;
  18468. /**
  18469. * Resize the texture using a ratio.
  18470. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18471. */
  18472. scale(ratio: number): void;
  18473. /**
  18474. * Get the texture reflection matrix used to rotate/transform the reflection.
  18475. * @returns the reflection matrix
  18476. */
  18477. getReflectionTextureMatrix(): Matrix;
  18478. /**
  18479. * Resize the texture to a new desired size.
  18480. * Be carrefull as it will recreate all the data in the new texture.
  18481. * @param size Define the new size. It can be:
  18482. * - a number for squared texture,
  18483. * - an object containing { width: number, height: number }
  18484. * - or an object containing a ratio { ratio: number }
  18485. */
  18486. resize(size: number | {
  18487. width: number;
  18488. height: number;
  18489. } | {
  18490. ratio: number;
  18491. }): void;
  18492. /**
  18493. * Renders all the objects from the render list into the texture.
  18494. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18495. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18496. */
  18497. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18498. private _bestReflectionRenderTargetDimension;
  18499. /**
  18500. * @hidden
  18501. * @param faceIndex face index to bind to if this is a cubetexture
  18502. */
  18503. _bindFrameBuffer(faceIndex?: number): void;
  18504. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18505. private renderToTarget;
  18506. /**
  18507. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18508. * This allowed control for front to back rendering or reversly depending of the special needs.
  18509. *
  18510. * @param renderingGroupId The rendering group id corresponding to its index
  18511. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18512. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18513. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18514. */
  18515. 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;
  18516. /**
  18517. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18518. *
  18519. * @param renderingGroupId The rendering group id corresponding to its index
  18520. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18521. */
  18522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18523. /**
  18524. * Clones the texture.
  18525. * @returns the cloned texture
  18526. */
  18527. clone(): RenderTargetTexture;
  18528. /**
  18529. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18530. * @returns The JSON representation of the texture
  18531. */
  18532. serialize(): any;
  18533. /**
  18534. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18535. */
  18536. disposeFramebufferObjects(): void;
  18537. /**
  18538. * Dispose the texture and release its associated resources.
  18539. */
  18540. dispose(): void;
  18541. /** @hidden */
  18542. _rebuild(): void;
  18543. /**
  18544. * Clear the info related to rendering groups preventing retention point in material dispose.
  18545. */
  18546. freeRenderingGroups(): void;
  18547. /**
  18548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18549. * @returns the view count
  18550. */
  18551. getViewCount(): number;
  18552. }
  18553. }
  18554. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18555. import { Scene } from "babylonjs/scene";
  18556. import { Plane } from "babylonjs/Maths/math";
  18557. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18558. /**
  18559. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18560. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18561. * You can then easily use it as a reflectionTexture on a flat surface.
  18562. * In case the surface is not a plane, please consider relying on reflection probes.
  18563. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18564. */
  18565. export class MirrorTexture extends RenderTargetTexture {
  18566. private scene;
  18567. /**
  18568. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18569. * 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.
  18570. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18571. */
  18572. mirrorPlane: Plane;
  18573. /**
  18574. * Define the blur ratio used to blur the reflection if needed.
  18575. */
  18576. blurRatio: number;
  18577. /**
  18578. * Define the adaptive blur kernel used to blur the reflection if needed.
  18579. * This will autocompute the closest best match for the `blurKernel`
  18580. */
  18581. adaptiveBlurKernel: number;
  18582. /**
  18583. * Define the blur kernel used to blur the reflection if needed.
  18584. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18585. */
  18586. blurKernel: number;
  18587. /**
  18588. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18589. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18590. */
  18591. blurKernelX: number;
  18592. /**
  18593. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18594. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18595. */
  18596. blurKernelY: number;
  18597. private _autoComputeBlurKernel;
  18598. protected _onRatioRescale(): void;
  18599. private _updateGammaSpace;
  18600. private _imageProcessingConfigChangeObserver;
  18601. private _transformMatrix;
  18602. private _mirrorMatrix;
  18603. private _savedViewMatrix;
  18604. private _blurX;
  18605. private _blurY;
  18606. private _adaptiveBlurKernel;
  18607. private _blurKernelX;
  18608. private _blurKernelY;
  18609. private _blurRatio;
  18610. /**
  18611. * Instantiates a Mirror Texture.
  18612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18614. * You can then easily use it as a reflectionTexture on a flat surface.
  18615. * In case the surface is not a plane, please consider relying on reflection probes.
  18616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18617. * @param name
  18618. * @param size
  18619. * @param scene
  18620. * @param generateMipMaps
  18621. * @param type
  18622. * @param samplingMode
  18623. * @param generateDepthBuffer
  18624. */
  18625. constructor(name: string, size: number | {
  18626. width: number;
  18627. height: number;
  18628. } | {
  18629. ratio: number;
  18630. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18631. private _preparePostProcesses;
  18632. /**
  18633. * Clone the mirror texture.
  18634. * @returns the cloned texture
  18635. */
  18636. clone(): MirrorTexture;
  18637. /**
  18638. * Serialize the texture to a JSON representation you could use in Parse later on
  18639. * @returns the serialized JSON representation
  18640. */
  18641. serialize(): any;
  18642. /**
  18643. * Dispose the texture and release its associated resources.
  18644. */
  18645. dispose(): void;
  18646. }
  18647. }
  18648. declare module "babylonjs/Materials/Textures/texture" {
  18649. import { Observable } from "babylonjs/Misc/observable";
  18650. import { Nullable } from "babylonjs/types";
  18651. import { Scene } from "babylonjs/scene";
  18652. import { Matrix } from "babylonjs/Maths/math";
  18653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18654. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18655. /**
  18656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18657. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18658. */
  18659. export class Texture extends BaseTexture {
  18660. /** @hidden */
  18661. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18662. /** @hidden */
  18663. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18664. /** @hidden */
  18665. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18666. /** nearest is mag = nearest and min = nearest and mip = linear */
  18667. static readonly NEAREST_SAMPLINGMODE: number;
  18668. /** nearest is mag = nearest and min = nearest and mip = linear */
  18669. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18670. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18671. static readonly BILINEAR_SAMPLINGMODE: number;
  18672. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18673. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18674. /** Trilinear is mag = linear and min = linear and mip = linear */
  18675. static readonly TRILINEAR_SAMPLINGMODE: number;
  18676. /** Trilinear is mag = linear and min = linear and mip = linear */
  18677. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18678. /** mag = nearest and min = nearest and mip = nearest */
  18679. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18680. /** mag = nearest and min = linear and mip = nearest */
  18681. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18682. /** mag = nearest and min = linear and mip = linear */
  18683. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18684. /** mag = nearest and min = linear and mip = none */
  18685. static readonly NEAREST_LINEAR: number;
  18686. /** mag = nearest and min = nearest and mip = none */
  18687. static readonly NEAREST_NEAREST: number;
  18688. /** mag = linear and min = nearest and mip = nearest */
  18689. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18690. /** mag = linear and min = nearest and mip = linear */
  18691. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18692. /** mag = linear and min = linear and mip = none */
  18693. static readonly LINEAR_LINEAR: number;
  18694. /** mag = linear and min = nearest and mip = none */
  18695. static readonly LINEAR_NEAREST: number;
  18696. /** Explicit coordinates mode */
  18697. static readonly EXPLICIT_MODE: number;
  18698. /** Spherical coordinates mode */
  18699. static readonly SPHERICAL_MODE: number;
  18700. /** Planar coordinates mode */
  18701. static readonly PLANAR_MODE: number;
  18702. /** Cubic coordinates mode */
  18703. static readonly CUBIC_MODE: number;
  18704. /** Projection coordinates mode */
  18705. static readonly PROJECTION_MODE: number;
  18706. /** Inverse Cubic coordinates mode */
  18707. static readonly SKYBOX_MODE: number;
  18708. /** Inverse Cubic coordinates mode */
  18709. static readonly INVCUBIC_MODE: number;
  18710. /** Equirectangular coordinates mode */
  18711. static readonly EQUIRECTANGULAR_MODE: number;
  18712. /** Equirectangular Fixed coordinates mode */
  18713. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18714. /** Equirectangular Fixed Mirrored coordinates mode */
  18715. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18716. /** Texture is not repeating outside of 0..1 UVs */
  18717. static readonly CLAMP_ADDRESSMODE: number;
  18718. /** Texture is repeating outside of 0..1 UVs */
  18719. static readonly WRAP_ADDRESSMODE: number;
  18720. /** Texture is repeating and mirrored */
  18721. static readonly MIRROR_ADDRESSMODE: number;
  18722. /**
  18723. * 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
  18724. */
  18725. static UseSerializedUrlIfAny: boolean;
  18726. /**
  18727. * Define the url of the texture.
  18728. */
  18729. url: Nullable<string>;
  18730. /**
  18731. * Define an offset on the texture to offset the u coordinates of the UVs
  18732. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18733. */
  18734. uOffset: number;
  18735. /**
  18736. * Define an offset on the texture to offset the v coordinates of the UVs
  18737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18738. */
  18739. vOffset: number;
  18740. /**
  18741. * Define an offset on the texture to scale the u coordinates of the UVs
  18742. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18743. */
  18744. uScale: number;
  18745. /**
  18746. * Define an offset on the texture to scale the v coordinates of the UVs
  18747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18748. */
  18749. vScale: number;
  18750. /**
  18751. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18752. * @see http://doc.babylonjs.com/how_to/more_materials
  18753. */
  18754. uAng: number;
  18755. /**
  18756. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18757. * @see http://doc.babylonjs.com/how_to/more_materials
  18758. */
  18759. vAng: number;
  18760. /**
  18761. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18762. * @see http://doc.babylonjs.com/how_to/more_materials
  18763. */
  18764. wAng: number;
  18765. /**
  18766. * Defines the center of rotation (U)
  18767. */
  18768. uRotationCenter: number;
  18769. /**
  18770. * Defines the center of rotation (V)
  18771. */
  18772. vRotationCenter: number;
  18773. /**
  18774. * Defines the center of rotation (W)
  18775. */
  18776. wRotationCenter: number;
  18777. /**
  18778. * Are mip maps generated for this texture or not.
  18779. */
  18780. readonly noMipmap: boolean;
  18781. /**
  18782. * List of inspectable custom properties (used by the Inspector)
  18783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18784. */
  18785. inspectableCustomProperties: Nullable<IInspectable[]>;
  18786. private _noMipmap;
  18787. /** @hidden */
  18788. _invertY: boolean;
  18789. private _rowGenerationMatrix;
  18790. private _cachedTextureMatrix;
  18791. private _projectionModeMatrix;
  18792. private _t0;
  18793. private _t1;
  18794. private _t2;
  18795. private _cachedUOffset;
  18796. private _cachedVOffset;
  18797. private _cachedUScale;
  18798. private _cachedVScale;
  18799. private _cachedUAng;
  18800. private _cachedVAng;
  18801. private _cachedWAng;
  18802. private _cachedProjectionMatrixId;
  18803. private _cachedCoordinatesMode;
  18804. /** @hidden */
  18805. protected _initialSamplingMode: number;
  18806. /** @hidden */
  18807. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18808. private _deleteBuffer;
  18809. protected _format: Nullable<number>;
  18810. private _delayedOnLoad;
  18811. private _delayedOnError;
  18812. /**
  18813. * Observable triggered once the texture has been loaded.
  18814. */
  18815. onLoadObservable: Observable<Texture>;
  18816. protected _isBlocking: boolean;
  18817. /**
  18818. * Is the texture preventing material to render while loading.
  18819. * If false, a default texture will be used instead of the loading one during the preparation step.
  18820. */
  18821. isBlocking: boolean;
  18822. /**
  18823. * Get the current sampling mode associated with the texture.
  18824. */
  18825. readonly samplingMode: number;
  18826. /**
  18827. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18828. */
  18829. readonly invertY: boolean;
  18830. /**
  18831. * Instantiates a new texture.
  18832. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18833. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18834. * @param url define the url of the picture to load as a texture
  18835. * @param scene define the scene the texture will belong to
  18836. * @param noMipmap define if the texture will require mip maps or not
  18837. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18838. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18839. * @param onLoad define a callback triggered when the texture has been loaded
  18840. * @param onError define a callback triggered when an error occurred during the loading session
  18841. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18842. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18843. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18844. */
  18845. 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);
  18846. /**
  18847. * Update the url (and optional buffer) of this texture if url was null during construction.
  18848. * @param url the url of the texture
  18849. * @param buffer the buffer of the texture (defaults to null)
  18850. * @param onLoad callback called when the texture is loaded (defaults to null)
  18851. */
  18852. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18853. /**
  18854. * Finish the loading sequence of a texture flagged as delayed load.
  18855. * @hidden
  18856. */
  18857. delayLoad(): void;
  18858. private _prepareRowForTextureGeneration;
  18859. /**
  18860. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18861. * @returns the transform matrix of the texture.
  18862. */
  18863. getTextureMatrix(): Matrix;
  18864. /**
  18865. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18866. * @returns The reflection texture transform
  18867. */
  18868. getReflectionTextureMatrix(): Matrix;
  18869. /**
  18870. * Clones the texture.
  18871. * @returns the cloned texture
  18872. */
  18873. clone(): Texture;
  18874. /**
  18875. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18876. * @returns The JSON representation of the texture
  18877. */
  18878. serialize(): any;
  18879. /**
  18880. * Get the current class name of the texture useful for serialization or dynamic coding.
  18881. * @returns "Texture"
  18882. */
  18883. getClassName(): string;
  18884. /**
  18885. * Dispose the texture and release its associated resources.
  18886. */
  18887. dispose(): void;
  18888. /**
  18889. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18890. * @param parsedTexture Define the JSON representation of the texture
  18891. * @param scene Define the scene the parsed texture should be instantiated in
  18892. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18893. * @returns The parsed texture if successful
  18894. */
  18895. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18896. /**
  18897. * Creates a texture from its base 64 representation.
  18898. * @param data Define the base64 payload without the data: prefix
  18899. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18900. * @param scene Define the scene the texture should belong to
  18901. * @param noMipmap Forces the texture to not create mip map information if true
  18902. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18903. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18904. * @param onLoad define a callback triggered when the texture has been loaded
  18905. * @param onError define a callback triggered when an error occurred during the loading session
  18906. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18907. * @returns the created texture
  18908. */
  18909. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18910. /**
  18911. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18912. * @param data Define the base64 payload without the data: prefix
  18913. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18914. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18915. * @param scene Define the scene the texture should belong to
  18916. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18917. * @param noMipmap Forces the texture to not create mip map information if true
  18918. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18919. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18920. * @param onLoad define a callback triggered when the texture has been loaded
  18921. * @param onError define a callback triggered when an error occurred during the loading session
  18922. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18923. * @returns the created texture
  18924. */
  18925. 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;
  18926. }
  18927. }
  18928. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18929. import { Nullable } from "babylonjs/types";
  18930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18931. import { Scene } from "babylonjs/scene";
  18932. module "babylonjs/Engines/engine" {
  18933. interface Engine {
  18934. /**
  18935. * Creates a raw texture
  18936. * @param data defines the data to store in the texture
  18937. * @param width defines the width of the texture
  18938. * @param height defines the height of the texture
  18939. * @param format defines the format of the data
  18940. * @param generateMipMaps defines if the engine should generate the mip levels
  18941. * @param invertY defines if data must be stored with Y axis inverted
  18942. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18943. * @param compression defines the compression used (null by default)
  18944. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18945. * @returns the raw texture inside an InternalTexture
  18946. */
  18947. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18948. /**
  18949. * Update a raw texture
  18950. * @param texture defines the texture to update
  18951. * @param data defines the data to store in the texture
  18952. * @param format defines the format of the data
  18953. * @param invertY defines if data must be stored with Y axis inverted
  18954. */
  18955. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18956. /**
  18957. * Update a raw texture
  18958. * @param texture defines the texture to update
  18959. * @param data defines the data to store in the texture
  18960. * @param format defines the format of the data
  18961. * @param invertY defines if data must be stored with Y axis inverted
  18962. * @param compression defines the compression used (null by default)
  18963. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18964. */
  18965. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18966. /**
  18967. * Creates a new raw cube texture
  18968. * @param data defines the array of data to use to create each face
  18969. * @param size defines the size of the textures
  18970. * @param format defines the format of the data
  18971. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18972. * @param generateMipMaps defines if the engine should generate the mip levels
  18973. * @param invertY defines if data must be stored with Y axis inverted
  18974. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18975. * @param compression defines the compression used (null by default)
  18976. * @returns the cube texture as an InternalTexture
  18977. */
  18978. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18979. /**
  18980. * Update a raw cube texture
  18981. * @param texture defines the texture to udpdate
  18982. * @param data defines the data to store
  18983. * @param format defines the data format
  18984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18985. * @param invertY defines if data must be stored with Y axis inverted
  18986. */
  18987. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18988. /**
  18989. * Update a raw cube texture
  18990. * @param texture defines the texture to udpdate
  18991. * @param data defines the data to store
  18992. * @param format defines the data format
  18993. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18994. * @param invertY defines if data must be stored with Y axis inverted
  18995. * @param compression defines the compression used (null by default)
  18996. */
  18997. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18998. /**
  18999. * Update a raw cube texture
  19000. * @param texture defines the texture to udpdate
  19001. * @param data defines the data to store
  19002. * @param format defines the data format
  19003. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19004. * @param invertY defines if data must be stored with Y axis inverted
  19005. * @param compression defines the compression used (null by default)
  19006. * @param level defines which level of the texture to update
  19007. */
  19008. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19009. /**
  19010. * Creates a new raw cube texture from a specified url
  19011. * @param url defines the url where the data is located
  19012. * @param scene defines the current scene
  19013. * @param size defines the size of the textures
  19014. * @param format defines the format of the data
  19015. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19016. * @param noMipmap defines if the engine should avoid generating the mip levels
  19017. * @param callback defines a callback used to extract texture data from loaded data
  19018. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19019. * @param onLoad defines a callback called when texture is loaded
  19020. * @param onError defines a callback called if there is an error
  19021. * @returns the cube texture as an InternalTexture
  19022. */
  19023. 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;
  19024. /**
  19025. * Creates a new raw cube texture from a specified url
  19026. * @param url defines the url where the data is located
  19027. * @param scene defines the current scene
  19028. * @param size defines the size of the textures
  19029. * @param format defines the format of the data
  19030. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19031. * @param noMipmap defines if the engine should avoid generating the mip levels
  19032. * @param callback defines a callback used to extract texture data from loaded data
  19033. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19034. * @param onLoad defines a callback called when texture is loaded
  19035. * @param onError defines a callback called if there is an error
  19036. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19037. * @param invertY defines if data must be stored with Y axis inverted
  19038. * @returns the cube texture as an InternalTexture
  19039. */
  19040. 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;
  19041. /**
  19042. * Creates a new raw 3D texture
  19043. * @param data defines the data used to create the texture
  19044. * @param width defines the width of the texture
  19045. * @param height defines the height of the texture
  19046. * @param depth defines the depth of the texture
  19047. * @param format defines the format of the texture
  19048. * @param generateMipMaps defines if the engine must generate mip levels
  19049. * @param invertY defines if data must be stored with Y axis inverted
  19050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19051. * @param compression defines the compressed used (can be null)
  19052. * @param textureType defines the compressed used (can be null)
  19053. * @returns a new raw 3D texture (stored in an InternalTexture)
  19054. */
  19055. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19056. /**
  19057. * Update a raw 3D texture
  19058. * @param texture defines the texture to update
  19059. * @param data defines the data to store
  19060. * @param format defines the data format
  19061. * @param invertY defines if data must be stored with Y axis inverted
  19062. */
  19063. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19064. /**
  19065. * Update a raw 3D texture
  19066. * @param texture defines the texture to update
  19067. * @param data defines the data to store
  19068. * @param format defines the data format
  19069. * @param invertY defines if data must be stored with Y axis inverted
  19070. * @param compression defines the used compression (can be null)
  19071. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19072. */
  19073. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19074. }
  19075. }
  19076. }
  19077. declare module "babylonjs/Materials/Textures/rawTexture" {
  19078. import { Scene } from "babylonjs/scene";
  19079. import { Texture } from "babylonjs/Materials/Textures/texture";
  19080. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19081. /**
  19082. * Raw texture can help creating a texture directly from an array of data.
  19083. * This can be super useful if you either get the data from an uncompressed source or
  19084. * if you wish to create your texture pixel by pixel.
  19085. */
  19086. export class RawTexture extends Texture {
  19087. /**
  19088. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19089. */
  19090. format: number;
  19091. private _engine;
  19092. /**
  19093. * Instantiates a new RawTexture.
  19094. * Raw texture can help creating a texture directly from an array of data.
  19095. * This can be super useful if you either get the data from an uncompressed source or
  19096. * if you wish to create your texture pixel by pixel.
  19097. * @param data define the array of data to use to create the texture
  19098. * @param width define the width of the texture
  19099. * @param height define the height of the texture
  19100. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19101. * @param scene define the scene the texture belongs to
  19102. * @param generateMipMaps define whether mip maps should be generated or not
  19103. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19104. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19105. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19106. */
  19107. constructor(data: ArrayBufferView, width: number, height: number,
  19108. /**
  19109. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19110. */
  19111. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19112. /**
  19113. * Updates the texture underlying data.
  19114. * @param data Define the new data of the texture
  19115. */
  19116. update(data: ArrayBufferView): void;
  19117. /**
  19118. * Creates a luminance texture from some data.
  19119. * @param data Define the texture data
  19120. * @param width Define the width of the texture
  19121. * @param height Define the height of the texture
  19122. * @param scene Define the scene the texture belongs to
  19123. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19124. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19125. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19126. * @returns the luminance texture
  19127. */
  19128. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19129. /**
  19130. * Creates a luminance alpha texture from some data.
  19131. * @param data Define the texture data
  19132. * @param width Define the width of the texture
  19133. * @param height Define the height of the texture
  19134. * @param scene Define the scene the texture belongs to
  19135. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19136. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19137. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19138. * @returns the luminance alpha texture
  19139. */
  19140. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19141. /**
  19142. * Creates an alpha texture from some data.
  19143. * @param data Define the texture data
  19144. * @param width Define the width of the texture
  19145. * @param height Define the height of the texture
  19146. * @param scene Define the scene the texture belongs to
  19147. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19148. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19149. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19150. * @returns the alpha texture
  19151. */
  19152. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19153. /**
  19154. * Creates a RGB texture from some data.
  19155. * @param data Define the texture data
  19156. * @param width Define the width of the texture
  19157. * @param height Define the height of the texture
  19158. * @param scene Define the scene the texture belongs to
  19159. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19160. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19161. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19162. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19163. * @returns the RGB alpha texture
  19164. */
  19165. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19166. /**
  19167. * Creates a RGBA texture from some data.
  19168. * @param data Define the texture data
  19169. * @param width Define the width of the texture
  19170. * @param height Define the height of the texture
  19171. * @param scene Define the scene the texture belongs to
  19172. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19173. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19174. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19175. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19176. * @returns the RGBA texture
  19177. */
  19178. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19179. /**
  19180. * Creates a R texture from some data.
  19181. * @param data Define the texture data
  19182. * @param width Define the width of the texture
  19183. * @param height Define the height of the texture
  19184. * @param scene Define the scene the texture belongs to
  19185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19188. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19189. * @returns the R texture
  19190. */
  19191. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19192. }
  19193. }
  19194. declare module "babylonjs/Animations/runtimeAnimation" {
  19195. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19196. import { Animatable } from "babylonjs/Animations/animatable";
  19197. import { Scene } from "babylonjs/scene";
  19198. /**
  19199. * Defines a runtime animation
  19200. */
  19201. export class RuntimeAnimation {
  19202. private _events;
  19203. /**
  19204. * The current frame of the runtime animation
  19205. */
  19206. private _currentFrame;
  19207. /**
  19208. * The animation used by the runtime animation
  19209. */
  19210. private _animation;
  19211. /**
  19212. * The target of the runtime animation
  19213. */
  19214. private _target;
  19215. /**
  19216. * The initiating animatable
  19217. */
  19218. private _host;
  19219. /**
  19220. * The original value of the runtime animation
  19221. */
  19222. private _originalValue;
  19223. /**
  19224. * The original blend value of the runtime animation
  19225. */
  19226. private _originalBlendValue;
  19227. /**
  19228. * The offsets cache of the runtime animation
  19229. */
  19230. private _offsetsCache;
  19231. /**
  19232. * The high limits cache of the runtime animation
  19233. */
  19234. private _highLimitsCache;
  19235. /**
  19236. * Specifies if the runtime animation has been stopped
  19237. */
  19238. private _stopped;
  19239. /**
  19240. * The blending factor of the runtime animation
  19241. */
  19242. private _blendingFactor;
  19243. /**
  19244. * The BabylonJS scene
  19245. */
  19246. private _scene;
  19247. /**
  19248. * The current value of the runtime animation
  19249. */
  19250. private _currentValue;
  19251. /** @hidden */
  19252. _animationState: _IAnimationState;
  19253. /**
  19254. * The active target of the runtime animation
  19255. */
  19256. private _activeTargets;
  19257. private _currentActiveTarget;
  19258. private _directTarget;
  19259. /**
  19260. * The target path of the runtime animation
  19261. */
  19262. private _targetPath;
  19263. /**
  19264. * The weight of the runtime animation
  19265. */
  19266. private _weight;
  19267. /**
  19268. * The ratio offset of the runtime animation
  19269. */
  19270. private _ratioOffset;
  19271. /**
  19272. * The previous delay of the runtime animation
  19273. */
  19274. private _previousDelay;
  19275. /**
  19276. * The previous ratio of the runtime animation
  19277. */
  19278. private _previousRatio;
  19279. private _enableBlending;
  19280. private _keys;
  19281. private _minFrame;
  19282. private _maxFrame;
  19283. private _minValue;
  19284. private _maxValue;
  19285. private _targetIsArray;
  19286. /**
  19287. * Gets the current frame of the runtime animation
  19288. */
  19289. readonly currentFrame: number;
  19290. /**
  19291. * Gets the weight of the runtime animation
  19292. */
  19293. readonly weight: number;
  19294. /**
  19295. * Gets the current value of the runtime animation
  19296. */
  19297. readonly currentValue: any;
  19298. /**
  19299. * Gets the target path of the runtime animation
  19300. */
  19301. readonly targetPath: string;
  19302. /**
  19303. * Gets the actual target of the runtime animation
  19304. */
  19305. readonly target: any;
  19306. /** @hidden */
  19307. _onLoop: () => void;
  19308. /**
  19309. * Create a new RuntimeAnimation object
  19310. * @param target defines the target of the animation
  19311. * @param animation defines the source animation object
  19312. * @param scene defines the hosting scene
  19313. * @param host defines the initiating Animatable
  19314. */
  19315. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19316. private _preparePath;
  19317. /**
  19318. * Gets the animation from the runtime animation
  19319. */
  19320. readonly animation: Animation;
  19321. /**
  19322. * Resets the runtime animation to the beginning
  19323. * @param restoreOriginal defines whether to restore the target property to the original value
  19324. */
  19325. reset(restoreOriginal?: boolean): void;
  19326. /**
  19327. * Specifies if the runtime animation is stopped
  19328. * @returns Boolean specifying if the runtime animation is stopped
  19329. */
  19330. isStopped(): boolean;
  19331. /**
  19332. * Disposes of the runtime animation
  19333. */
  19334. dispose(): void;
  19335. /**
  19336. * Apply the interpolated value to the target
  19337. * @param currentValue defines the value computed by the animation
  19338. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19339. */
  19340. setValue(currentValue: any, weight: number): void;
  19341. private _getOriginalValues;
  19342. private _setValue;
  19343. /**
  19344. * Gets the loop pmode of the runtime animation
  19345. * @returns Loop Mode
  19346. */
  19347. private _getCorrectLoopMode;
  19348. /**
  19349. * Move the current animation to a given frame
  19350. * @param frame defines the frame to move to
  19351. */
  19352. goToFrame(frame: number): void;
  19353. /**
  19354. * @hidden Internal use only
  19355. */
  19356. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19357. /**
  19358. * Execute the current animation
  19359. * @param delay defines the delay to add to the current frame
  19360. * @param from defines the lower bound of the animation range
  19361. * @param to defines the upper bound of the animation range
  19362. * @param loop defines if the current animation must loop
  19363. * @param speedRatio defines the current speed ratio
  19364. * @param weight defines the weight of the animation (default is -1 so no weight)
  19365. * @param onLoop optional callback called when animation loops
  19366. * @returns a boolean indicating if the animation is running
  19367. */
  19368. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19369. }
  19370. }
  19371. declare module "babylonjs/Animations/animatable" {
  19372. import { Animation } from "babylonjs/Animations/animation";
  19373. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19374. import { Nullable } from "babylonjs/types";
  19375. import { Observable } from "babylonjs/Misc/observable";
  19376. import { Scene } from "babylonjs/scene";
  19377. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19378. import { Node } from "babylonjs/node";
  19379. /**
  19380. * Class used to store an actual running animation
  19381. */
  19382. export class Animatable {
  19383. /** defines the target object */
  19384. target: any;
  19385. /** defines the starting frame number (default is 0) */
  19386. fromFrame: number;
  19387. /** defines the ending frame number (default is 100) */
  19388. toFrame: number;
  19389. /** defines if the animation must loop (default is false) */
  19390. loopAnimation: boolean;
  19391. /** defines a callback to call when animation ends if it is not looping */
  19392. onAnimationEnd?: (() => void) | null | undefined;
  19393. /** defines a callback to call when animation loops */
  19394. onAnimationLoop?: (() => void) | null | undefined;
  19395. private _localDelayOffset;
  19396. private _pausedDelay;
  19397. private _runtimeAnimations;
  19398. private _paused;
  19399. private _scene;
  19400. private _speedRatio;
  19401. private _weight;
  19402. private _syncRoot;
  19403. /**
  19404. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19405. * This will only apply for non looping animation (default is true)
  19406. */
  19407. disposeOnEnd: boolean;
  19408. /**
  19409. * Gets a boolean indicating if the animation has started
  19410. */
  19411. animationStarted: boolean;
  19412. /**
  19413. * Observer raised when the animation ends
  19414. */
  19415. onAnimationEndObservable: Observable<Animatable>;
  19416. /**
  19417. * Observer raised when the animation loops
  19418. */
  19419. onAnimationLoopObservable: Observable<Animatable>;
  19420. /**
  19421. * Gets the root Animatable used to synchronize and normalize animations
  19422. */
  19423. readonly syncRoot: Nullable<Animatable>;
  19424. /**
  19425. * Gets the current frame of the first RuntimeAnimation
  19426. * Used to synchronize Animatables
  19427. */
  19428. readonly masterFrame: number;
  19429. /**
  19430. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19431. */
  19432. weight: number;
  19433. /**
  19434. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19435. */
  19436. speedRatio: number;
  19437. /**
  19438. * Creates a new Animatable
  19439. * @param scene defines the hosting scene
  19440. * @param target defines the target object
  19441. * @param fromFrame defines the starting frame number (default is 0)
  19442. * @param toFrame defines the ending frame number (default is 100)
  19443. * @param loopAnimation defines if the animation must loop (default is false)
  19444. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19445. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19446. * @param animations defines a group of animation to add to the new Animatable
  19447. * @param onAnimationLoop defines a callback to call when animation loops
  19448. */
  19449. constructor(scene: Scene,
  19450. /** defines the target object */
  19451. target: any,
  19452. /** defines the starting frame number (default is 0) */
  19453. fromFrame?: number,
  19454. /** defines the ending frame number (default is 100) */
  19455. toFrame?: number,
  19456. /** defines if the animation must loop (default is false) */
  19457. loopAnimation?: boolean, speedRatio?: number,
  19458. /** defines a callback to call when animation ends if it is not looping */
  19459. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19460. /** defines a callback to call when animation loops */
  19461. onAnimationLoop?: (() => void) | null | undefined);
  19462. /**
  19463. * Synchronize and normalize current Animatable with a source Animatable
  19464. * This is useful when using animation weights and when animations are not of the same length
  19465. * @param root defines the root Animatable to synchronize with
  19466. * @returns the current Animatable
  19467. */
  19468. syncWith(root: Animatable): Animatable;
  19469. /**
  19470. * Gets the list of runtime animations
  19471. * @returns an array of RuntimeAnimation
  19472. */
  19473. getAnimations(): RuntimeAnimation[];
  19474. /**
  19475. * Adds more animations to the current animatable
  19476. * @param target defines the target of the animations
  19477. * @param animations defines the new animations to add
  19478. */
  19479. appendAnimations(target: any, animations: Animation[]): void;
  19480. /**
  19481. * Gets the source animation for a specific property
  19482. * @param property defines the propertyu to look for
  19483. * @returns null or the source animation for the given property
  19484. */
  19485. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19486. /**
  19487. * Gets the runtime animation for a specific property
  19488. * @param property defines the propertyu to look for
  19489. * @returns null or the runtime animation for the given property
  19490. */
  19491. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19492. /**
  19493. * Resets the animatable to its original state
  19494. */
  19495. reset(): void;
  19496. /**
  19497. * Allows the animatable to blend with current running animations
  19498. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19499. * @param blendingSpeed defines the blending speed to use
  19500. */
  19501. enableBlending(blendingSpeed: number): void;
  19502. /**
  19503. * Disable animation blending
  19504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19505. */
  19506. disableBlending(): void;
  19507. /**
  19508. * Jump directly to a given frame
  19509. * @param frame defines the frame to jump to
  19510. */
  19511. goToFrame(frame: number): void;
  19512. /**
  19513. * Pause the animation
  19514. */
  19515. pause(): void;
  19516. /**
  19517. * Restart the animation
  19518. */
  19519. restart(): void;
  19520. private _raiseOnAnimationEnd;
  19521. /**
  19522. * Stop and delete the current animation
  19523. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19524. * @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)
  19525. */
  19526. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19527. /**
  19528. * Wait asynchronously for the animation to end
  19529. * @returns a promise which will be fullfilled when the animation ends
  19530. */
  19531. waitAsync(): Promise<Animatable>;
  19532. /** @hidden */
  19533. _animate(delay: number): boolean;
  19534. }
  19535. module "babylonjs/scene" {
  19536. interface Scene {
  19537. /** @hidden */
  19538. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19539. /** @hidden */
  19540. _processLateAnimationBindingsForMatrices(holder: {
  19541. totalWeight: number;
  19542. animations: RuntimeAnimation[];
  19543. originalValue: Matrix;
  19544. }): any;
  19545. /** @hidden */
  19546. _processLateAnimationBindingsForQuaternions(holder: {
  19547. totalWeight: number;
  19548. animations: RuntimeAnimation[];
  19549. originalValue: Quaternion;
  19550. }, refQuaternion: Quaternion): Quaternion;
  19551. /** @hidden */
  19552. _processLateAnimationBindings(): void;
  19553. /**
  19554. * Will start the animation sequence of a given target
  19555. * @param target defines the target
  19556. * @param from defines from which frame should animation start
  19557. * @param to defines until which frame should animation run.
  19558. * @param weight defines the weight to apply to the animation (1.0 by default)
  19559. * @param loop defines if the animation loops
  19560. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19561. * @param onAnimationEnd defines the function to be executed when the animation ends
  19562. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19563. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19564. * @param onAnimationLoop defines the callback to call when an animation loops
  19565. * @returns the animatable object created for this animation
  19566. */
  19567. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19568. /**
  19569. * Will start the animation sequence of a given target
  19570. * @param target defines the target
  19571. * @param from defines from which frame should animation start
  19572. * @param to defines until which frame should animation run.
  19573. * @param loop defines if the animation loops
  19574. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19575. * @param onAnimationEnd defines the function to be executed when the animation ends
  19576. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19577. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19578. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19579. * @param onAnimationLoop defines the callback to call when an animation loops
  19580. * @returns the animatable object created for this animation
  19581. */
  19582. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19583. /**
  19584. * Will start the animation sequence of a given target and its hierarchy
  19585. * @param target defines the target
  19586. * @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.
  19587. * @param from defines from which frame should animation start
  19588. * @param to defines until which frame should animation run.
  19589. * @param loop defines if the animation loops
  19590. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19591. * @param onAnimationEnd defines the function to be executed when the animation ends
  19592. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19593. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19594. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19595. * @param onAnimationLoop defines the callback to call when an animation loops
  19596. * @returns the list of created animatables
  19597. */
  19598. 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[];
  19599. /**
  19600. * Begin a new animation on a given node
  19601. * @param target defines the target where the animation will take place
  19602. * @param animations defines the list of animations to start
  19603. * @param from defines the initial value
  19604. * @param to defines the final value
  19605. * @param loop defines if you want animation to loop (off by default)
  19606. * @param speedRatio defines the speed ratio to apply to all animations
  19607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19608. * @param onAnimationLoop defines the callback to call when an animation loops
  19609. * @returns the list of created animatables
  19610. */
  19611. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19612. /**
  19613. * Begin a new animation on a given node and its hierarchy
  19614. * @param target defines the root node where the animation will take place
  19615. * @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.
  19616. * @param animations defines the list of animations to start
  19617. * @param from defines the initial value
  19618. * @param to defines the final value
  19619. * @param loop defines if you want animation to loop (off by default)
  19620. * @param speedRatio defines the speed ratio to apply to all animations
  19621. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19622. * @param onAnimationLoop defines the callback to call when an animation loops
  19623. * @returns the list of animatables created for all nodes
  19624. */
  19625. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19626. /**
  19627. * Gets the animatable associated with a specific target
  19628. * @param target defines the target of the animatable
  19629. * @returns the required animatable if found
  19630. */
  19631. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19632. /**
  19633. * Gets all animatables associated with a given target
  19634. * @param target defines the target to look animatables for
  19635. * @returns an array of Animatables
  19636. */
  19637. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19638. /**
  19639. * Will stop the animation of the given target
  19640. * @param target - the target
  19641. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19642. * @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)
  19643. */
  19644. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19645. /**
  19646. * Stops and removes all animations that have been applied to the scene
  19647. */
  19648. stopAllAnimations(): void;
  19649. }
  19650. }
  19651. module "babylonjs/Bones/bone" {
  19652. interface Bone {
  19653. /**
  19654. * Copy an animation range from another bone
  19655. * @param source defines the source bone
  19656. * @param rangeName defines the range name to copy
  19657. * @param frameOffset defines the frame offset
  19658. * @param rescaleAsRequired defines if rescaling must be applied if required
  19659. * @param skelDimensionsRatio defines the scaling ratio
  19660. * @returns true if operation was successful
  19661. */
  19662. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19663. }
  19664. }
  19665. }
  19666. declare module "babylonjs/Bones/skeleton" {
  19667. import { Bone } from "babylonjs/Bones/bone";
  19668. import { IAnimatable } from "babylonjs/Misc/tools";
  19669. import { Observable } from "babylonjs/Misc/observable";
  19670. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19671. import { Scene } from "babylonjs/scene";
  19672. import { Nullable } from "babylonjs/types";
  19673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19674. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19675. import { Animatable } from "babylonjs/Animations/animatable";
  19676. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19677. import { Animation } from "babylonjs/Animations/animation";
  19678. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19679. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19680. /**
  19681. * Class used to handle skinning animations
  19682. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19683. */
  19684. export class Skeleton implements IAnimatable {
  19685. /** defines the skeleton name */
  19686. name: string;
  19687. /** defines the skeleton Id */
  19688. id: string;
  19689. /**
  19690. * Defines the list of child bones
  19691. */
  19692. bones: Bone[];
  19693. /**
  19694. * Defines an estimate of the dimension of the skeleton at rest
  19695. */
  19696. dimensionsAtRest: Vector3;
  19697. /**
  19698. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19699. */
  19700. needInitialSkinMatrix: boolean;
  19701. /**
  19702. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19703. */
  19704. overrideMesh: Nullable<AbstractMesh>;
  19705. /**
  19706. * Gets the list of animations attached to this skeleton
  19707. */
  19708. animations: Array<Animation>;
  19709. private _scene;
  19710. private _isDirty;
  19711. private _transformMatrices;
  19712. private _transformMatrixTexture;
  19713. private _meshesWithPoseMatrix;
  19714. private _animatables;
  19715. private _identity;
  19716. private _synchronizedWithMesh;
  19717. private _ranges;
  19718. private _lastAbsoluteTransformsUpdateId;
  19719. private _canUseTextureForBones;
  19720. private _uniqueId;
  19721. /** @hidden */
  19722. _numBonesWithLinkedTransformNode: number;
  19723. /**
  19724. * Specifies if the skeleton should be serialized
  19725. */
  19726. doNotSerialize: boolean;
  19727. private _useTextureToStoreBoneMatrices;
  19728. /**
  19729. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19730. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19731. */
  19732. useTextureToStoreBoneMatrices: boolean;
  19733. private _animationPropertiesOverride;
  19734. /**
  19735. * Gets or sets the animation properties override
  19736. */
  19737. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19738. /**
  19739. * List of inspectable custom properties (used by the Inspector)
  19740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19741. */
  19742. inspectableCustomProperties: IInspectable[];
  19743. /**
  19744. * An observable triggered before computing the skeleton's matrices
  19745. */
  19746. onBeforeComputeObservable: Observable<Skeleton>;
  19747. /**
  19748. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19749. */
  19750. readonly isUsingTextureForMatrices: boolean;
  19751. /**
  19752. * Gets the unique ID of this skeleton
  19753. */
  19754. readonly uniqueId: number;
  19755. /**
  19756. * Creates a new skeleton
  19757. * @param name defines the skeleton name
  19758. * @param id defines the skeleton Id
  19759. * @param scene defines the hosting scene
  19760. */
  19761. constructor(
  19762. /** defines the skeleton name */
  19763. name: string,
  19764. /** defines the skeleton Id */
  19765. id: string, scene: Scene);
  19766. /**
  19767. * Gets the current object class name.
  19768. * @return the class name
  19769. */
  19770. getClassName(): string;
  19771. /**
  19772. * Returns an array containing the root bones
  19773. * @returns an array containing the root bones
  19774. */
  19775. getChildren(): Array<Bone>;
  19776. /**
  19777. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19778. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19779. * @returns a Float32Array containing matrices data
  19780. */
  19781. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19782. /**
  19783. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19784. * @returns a raw texture containing the data
  19785. */
  19786. getTransformMatrixTexture(): Nullable<RawTexture>;
  19787. /**
  19788. * Gets the current hosting scene
  19789. * @returns a scene object
  19790. */
  19791. getScene(): Scene;
  19792. /**
  19793. * Gets a string representing the current skeleton data
  19794. * @param fullDetails defines a boolean indicating if we want a verbose version
  19795. * @returns a string representing the current skeleton data
  19796. */
  19797. toString(fullDetails?: boolean): string;
  19798. /**
  19799. * Get bone's index searching by name
  19800. * @param name defines bone's name to search for
  19801. * @return the indice of the bone. Returns -1 if not found
  19802. */
  19803. getBoneIndexByName(name: string): number;
  19804. /**
  19805. * Creater a new animation range
  19806. * @param name defines the name of the range
  19807. * @param from defines the start key
  19808. * @param to defines the end key
  19809. */
  19810. createAnimationRange(name: string, from: number, to: number): void;
  19811. /**
  19812. * Delete a specific animation range
  19813. * @param name defines the name of the range
  19814. * @param deleteFrames defines if frames must be removed as well
  19815. */
  19816. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19817. /**
  19818. * Gets a specific animation range
  19819. * @param name defines the name of the range to look for
  19820. * @returns the requested animation range or null if not found
  19821. */
  19822. getAnimationRange(name: string): Nullable<AnimationRange>;
  19823. /**
  19824. * Gets the list of all animation ranges defined on this skeleton
  19825. * @returns an array
  19826. */
  19827. getAnimationRanges(): Nullable<AnimationRange>[];
  19828. /**
  19829. * Copy animation range from a source skeleton.
  19830. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19831. * @param source defines the source skeleton
  19832. * @param name defines the name of the range to copy
  19833. * @param rescaleAsRequired defines if rescaling must be applied if required
  19834. * @returns true if operation was successful
  19835. */
  19836. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19837. /**
  19838. * Forces the skeleton to go to rest pose
  19839. */
  19840. returnToRest(): void;
  19841. private _getHighestAnimationFrame;
  19842. /**
  19843. * Begin a specific animation range
  19844. * @param name defines the name of the range to start
  19845. * @param loop defines if looping must be turned on (false by default)
  19846. * @param speedRatio defines the speed ratio to apply (1 by default)
  19847. * @param onAnimationEnd defines a callback which will be called when animation will end
  19848. * @returns a new animatable
  19849. */
  19850. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19851. /** @hidden */
  19852. _markAsDirty(): void;
  19853. /** @hidden */
  19854. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19855. /** @hidden */
  19856. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19857. private _computeTransformMatrices;
  19858. /**
  19859. * Build all resources required to render a skeleton
  19860. */
  19861. prepare(): void;
  19862. /**
  19863. * Gets the list of animatables currently running for this skeleton
  19864. * @returns an array of animatables
  19865. */
  19866. getAnimatables(): IAnimatable[];
  19867. /**
  19868. * Clone the current skeleton
  19869. * @param name defines the name of the new skeleton
  19870. * @param id defines the id of the new skeleton
  19871. * @returns the new skeleton
  19872. */
  19873. clone(name: string, id: string): Skeleton;
  19874. /**
  19875. * Enable animation blending for this skeleton
  19876. * @param blendingSpeed defines the blending speed to apply
  19877. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19878. */
  19879. enableBlending(blendingSpeed?: number): void;
  19880. /**
  19881. * Releases all resources associated with the current skeleton
  19882. */
  19883. dispose(): void;
  19884. /**
  19885. * Serialize the skeleton in a JSON object
  19886. * @returns a JSON object
  19887. */
  19888. serialize(): any;
  19889. /**
  19890. * Creates a new skeleton from serialized data
  19891. * @param parsedSkeleton defines the serialized data
  19892. * @param scene defines the hosting scene
  19893. * @returns a new skeleton
  19894. */
  19895. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19896. /**
  19897. * Compute all node absolute transforms
  19898. * @param forceUpdate defines if computation must be done even if cache is up to date
  19899. */
  19900. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19901. /**
  19902. * Gets the root pose matrix
  19903. * @returns a matrix
  19904. */
  19905. getPoseMatrix(): Nullable<Matrix>;
  19906. /**
  19907. * Sorts bones per internal index
  19908. */
  19909. sortBones(): void;
  19910. private _sortBones;
  19911. }
  19912. }
  19913. declare module "babylonjs/Morph/morphTarget" {
  19914. import { IAnimatable } from "babylonjs/Misc/tools";
  19915. import { Observable } from "babylonjs/Misc/observable";
  19916. import { Nullable, FloatArray } from "babylonjs/types";
  19917. import { Scene } from "babylonjs/scene";
  19918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19919. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19920. /**
  19921. * Defines a target to use with MorphTargetManager
  19922. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19923. */
  19924. export class MorphTarget implements IAnimatable {
  19925. /** defines the name of the target */
  19926. name: string;
  19927. /**
  19928. * Gets or sets the list of animations
  19929. */
  19930. animations: import("babylonjs/Animations/animation").Animation[];
  19931. private _scene;
  19932. private _positions;
  19933. private _normals;
  19934. private _tangents;
  19935. private _influence;
  19936. /**
  19937. * Observable raised when the influence changes
  19938. */
  19939. onInfluenceChanged: Observable<boolean>;
  19940. /** @hidden */
  19941. _onDataLayoutChanged: Observable<void>;
  19942. /**
  19943. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19944. */
  19945. influence: number;
  19946. /**
  19947. * Gets or sets the id of the morph Target
  19948. */
  19949. id: string;
  19950. private _animationPropertiesOverride;
  19951. /**
  19952. * Gets or sets the animation properties override
  19953. */
  19954. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19955. /**
  19956. * Creates a new MorphTarget
  19957. * @param name defines the name of the target
  19958. * @param influence defines the influence to use
  19959. * @param scene defines the scene the morphtarget belongs to
  19960. */
  19961. constructor(
  19962. /** defines the name of the target */
  19963. name: string, influence?: number, scene?: Nullable<Scene>);
  19964. /**
  19965. * Gets a boolean defining if the target contains position data
  19966. */
  19967. readonly hasPositions: boolean;
  19968. /**
  19969. * Gets a boolean defining if the target contains normal data
  19970. */
  19971. readonly hasNormals: boolean;
  19972. /**
  19973. * Gets a boolean defining if the target contains tangent data
  19974. */
  19975. readonly hasTangents: boolean;
  19976. /**
  19977. * Affects position data to this target
  19978. * @param data defines the position data to use
  19979. */
  19980. setPositions(data: Nullable<FloatArray>): void;
  19981. /**
  19982. * Gets the position data stored in this target
  19983. * @returns a FloatArray containing the position data (or null if not present)
  19984. */
  19985. getPositions(): Nullable<FloatArray>;
  19986. /**
  19987. * Affects normal data to this target
  19988. * @param data defines the normal data to use
  19989. */
  19990. setNormals(data: Nullable<FloatArray>): void;
  19991. /**
  19992. * Gets the normal data stored in this target
  19993. * @returns a FloatArray containing the normal data (or null if not present)
  19994. */
  19995. getNormals(): Nullable<FloatArray>;
  19996. /**
  19997. * Affects tangent data to this target
  19998. * @param data defines the tangent data to use
  19999. */
  20000. setTangents(data: Nullable<FloatArray>): void;
  20001. /**
  20002. * Gets the tangent data stored in this target
  20003. * @returns a FloatArray containing the tangent data (or null if not present)
  20004. */
  20005. getTangents(): Nullable<FloatArray>;
  20006. /**
  20007. * Serializes the current target into a Serialization object
  20008. * @returns the serialized object
  20009. */
  20010. serialize(): any;
  20011. /**
  20012. * Returns the string "MorphTarget"
  20013. * @returns "MorphTarget"
  20014. */
  20015. getClassName(): string;
  20016. /**
  20017. * Creates a new target from serialized data
  20018. * @param serializationObject defines the serialized data to use
  20019. * @returns a new MorphTarget
  20020. */
  20021. static Parse(serializationObject: any): MorphTarget;
  20022. /**
  20023. * Creates a MorphTarget from mesh data
  20024. * @param mesh defines the source mesh
  20025. * @param name defines the name to use for the new target
  20026. * @param influence defines the influence to attach to the target
  20027. * @returns a new MorphTarget
  20028. */
  20029. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20030. }
  20031. }
  20032. declare module "babylonjs/Morph/morphTargetManager" {
  20033. import { Nullable } from "babylonjs/types";
  20034. import { Scene } from "babylonjs/scene";
  20035. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20036. /**
  20037. * This class is used to deform meshes using morphing between different targets
  20038. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20039. */
  20040. export class MorphTargetManager {
  20041. private _targets;
  20042. private _targetInfluenceChangedObservers;
  20043. private _targetDataLayoutChangedObservers;
  20044. private _activeTargets;
  20045. private _scene;
  20046. private _influences;
  20047. private _supportsNormals;
  20048. private _supportsTangents;
  20049. private _vertexCount;
  20050. private _uniqueId;
  20051. private _tempInfluences;
  20052. /**
  20053. * Creates a new MorphTargetManager
  20054. * @param scene defines the current scene
  20055. */
  20056. constructor(scene?: Nullable<Scene>);
  20057. /**
  20058. * Gets the unique ID of this manager
  20059. */
  20060. readonly uniqueId: number;
  20061. /**
  20062. * Gets the number of vertices handled by this manager
  20063. */
  20064. readonly vertexCount: number;
  20065. /**
  20066. * Gets a boolean indicating if this manager supports morphing of normals
  20067. */
  20068. readonly supportsNormals: boolean;
  20069. /**
  20070. * Gets a boolean indicating if this manager supports morphing of tangents
  20071. */
  20072. readonly supportsTangents: boolean;
  20073. /**
  20074. * Gets the number of targets stored in this manager
  20075. */
  20076. readonly numTargets: number;
  20077. /**
  20078. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20079. */
  20080. readonly numInfluencers: number;
  20081. /**
  20082. * Gets the list of influences (one per target)
  20083. */
  20084. readonly influences: Float32Array;
  20085. /**
  20086. * Gets the active target at specified index. An active target is a target with an influence > 0
  20087. * @param index defines the index to check
  20088. * @returns the requested target
  20089. */
  20090. getActiveTarget(index: number): MorphTarget;
  20091. /**
  20092. * Gets the target at specified index
  20093. * @param index defines the index to check
  20094. * @returns the requested target
  20095. */
  20096. getTarget(index: number): MorphTarget;
  20097. /**
  20098. * Add a new target to this manager
  20099. * @param target defines the target to add
  20100. */
  20101. addTarget(target: MorphTarget): void;
  20102. /**
  20103. * Removes a target from the manager
  20104. * @param target defines the target to remove
  20105. */
  20106. removeTarget(target: MorphTarget): void;
  20107. /**
  20108. * Serializes the current manager into a Serialization object
  20109. * @returns the serialized object
  20110. */
  20111. serialize(): any;
  20112. private _syncActiveTargets;
  20113. /**
  20114. * Syncrhonize the targets with all the meshes using this morph target manager
  20115. */
  20116. synchronize(): void;
  20117. /**
  20118. * Creates a new MorphTargetManager from serialized data
  20119. * @param serializationObject defines the serialized data
  20120. * @param scene defines the hosting scene
  20121. * @returns the new MorphTargetManager
  20122. */
  20123. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20124. }
  20125. }
  20126. declare module "babylonjs/Meshes/meshLODLevel" {
  20127. import { Mesh } from "babylonjs/Meshes/mesh";
  20128. import { Nullable } from "babylonjs/types";
  20129. /**
  20130. * Class used to represent a specific level of detail of a mesh
  20131. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20132. */
  20133. export class MeshLODLevel {
  20134. /** Defines the distance where this level should star being displayed */
  20135. distance: number;
  20136. /** Defines the mesh to use to render this level */
  20137. mesh: Nullable<Mesh>;
  20138. /**
  20139. * Creates a new LOD level
  20140. * @param distance defines the distance where this level should star being displayed
  20141. * @param mesh defines the mesh to use to render this level
  20142. */
  20143. constructor(
  20144. /** Defines the distance where this level should star being displayed */
  20145. distance: number,
  20146. /** Defines the mesh to use to render this level */
  20147. mesh: Nullable<Mesh>);
  20148. }
  20149. }
  20150. declare module "babylonjs/Meshes/groundMesh" {
  20151. import { Scene } from "babylonjs/scene";
  20152. import { Vector3 } from "babylonjs/Maths/math";
  20153. import { Mesh } from "babylonjs/Meshes/mesh";
  20154. /**
  20155. * Mesh representing the gorund
  20156. */
  20157. export class GroundMesh extends Mesh {
  20158. /** If octree should be generated */
  20159. generateOctree: boolean;
  20160. private _heightQuads;
  20161. /** @hidden */
  20162. _subdivisionsX: number;
  20163. /** @hidden */
  20164. _subdivisionsY: number;
  20165. /** @hidden */
  20166. _width: number;
  20167. /** @hidden */
  20168. _height: number;
  20169. /** @hidden */
  20170. _minX: number;
  20171. /** @hidden */
  20172. _maxX: number;
  20173. /** @hidden */
  20174. _minZ: number;
  20175. /** @hidden */
  20176. _maxZ: number;
  20177. constructor(name: string, scene: Scene);
  20178. /**
  20179. * "GroundMesh"
  20180. * @returns "GroundMesh"
  20181. */
  20182. getClassName(): string;
  20183. /**
  20184. * The minimum of x and y subdivisions
  20185. */
  20186. readonly subdivisions: number;
  20187. /**
  20188. * X subdivisions
  20189. */
  20190. readonly subdivisionsX: number;
  20191. /**
  20192. * Y subdivisions
  20193. */
  20194. readonly subdivisionsY: number;
  20195. /**
  20196. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20197. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20198. * @param chunksCount the number of subdivisions for x and y
  20199. * @param octreeBlocksSize (Default: 32)
  20200. */
  20201. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20202. /**
  20203. * Returns a height (y) value in the Worl system :
  20204. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20205. * @param x x coordinate
  20206. * @param z z coordinate
  20207. * @returns the ground y position if (x, z) are outside the ground surface.
  20208. */
  20209. getHeightAtCoordinates(x: number, z: number): number;
  20210. /**
  20211. * Returns a normalized vector (Vector3) orthogonal to the ground
  20212. * at the ground coordinates (x, z) expressed in the World system.
  20213. * @param x x coordinate
  20214. * @param z z coordinate
  20215. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20216. */
  20217. getNormalAtCoordinates(x: number, z: number): Vector3;
  20218. /**
  20219. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20220. * at the ground coordinates (x, z) expressed in the World system.
  20221. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20222. * @param x x coordinate
  20223. * @param z z coordinate
  20224. * @param ref vector to store the result
  20225. * @returns the GroundMesh.
  20226. */
  20227. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20228. /**
  20229. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20230. * if the ground has been updated.
  20231. * This can be used in the render loop.
  20232. * @returns the GroundMesh.
  20233. */
  20234. updateCoordinateHeights(): GroundMesh;
  20235. private _getFacetAt;
  20236. private _initHeightQuads;
  20237. private _computeHeightQuads;
  20238. /**
  20239. * Serializes this ground mesh
  20240. * @param serializationObject object to write serialization to
  20241. */
  20242. serialize(serializationObject: any): void;
  20243. /**
  20244. * Parses a serialized ground mesh
  20245. * @param parsedMesh the serialized mesh
  20246. * @param scene the scene to create the ground mesh in
  20247. * @returns the created ground mesh
  20248. */
  20249. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20250. }
  20251. }
  20252. declare module "babylonjs/Physics/physicsJoint" {
  20253. import { Vector3 } from "babylonjs/Maths/math";
  20254. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20255. /**
  20256. * Interface for Physics-Joint data
  20257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20258. */
  20259. export interface PhysicsJointData {
  20260. /**
  20261. * The main pivot of the joint
  20262. */
  20263. mainPivot?: Vector3;
  20264. /**
  20265. * The connected pivot of the joint
  20266. */
  20267. connectedPivot?: Vector3;
  20268. /**
  20269. * The main axis of the joint
  20270. */
  20271. mainAxis?: Vector3;
  20272. /**
  20273. * The connected axis of the joint
  20274. */
  20275. connectedAxis?: Vector3;
  20276. /**
  20277. * The collision of the joint
  20278. */
  20279. collision?: boolean;
  20280. /**
  20281. * Native Oimo/Cannon/Energy data
  20282. */
  20283. nativeParams?: any;
  20284. }
  20285. /**
  20286. * This is a holder class for the physics joint created by the physics plugin
  20287. * It holds a set of functions to control the underlying joint
  20288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20289. */
  20290. export class PhysicsJoint {
  20291. /**
  20292. * The type of the physics joint
  20293. */
  20294. type: number;
  20295. /**
  20296. * The data for the physics joint
  20297. */
  20298. jointData: PhysicsJointData;
  20299. private _physicsJoint;
  20300. protected _physicsPlugin: IPhysicsEnginePlugin;
  20301. /**
  20302. * Initializes the physics joint
  20303. * @param type The type of the physics joint
  20304. * @param jointData The data for the physics joint
  20305. */
  20306. constructor(
  20307. /**
  20308. * The type of the physics joint
  20309. */
  20310. type: number,
  20311. /**
  20312. * The data for the physics joint
  20313. */
  20314. jointData: PhysicsJointData);
  20315. /**
  20316. * Gets the physics joint
  20317. */
  20318. /**
  20319. * Sets the physics joint
  20320. */
  20321. physicsJoint: any;
  20322. /**
  20323. * Sets the physics plugin
  20324. */
  20325. physicsPlugin: IPhysicsEnginePlugin;
  20326. /**
  20327. * Execute a function that is physics-plugin specific.
  20328. * @param {Function} func the function that will be executed.
  20329. * It accepts two parameters: the physics world and the physics joint
  20330. */
  20331. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20332. /**
  20333. * Distance-Joint type
  20334. */
  20335. static DistanceJoint: number;
  20336. /**
  20337. * Hinge-Joint type
  20338. */
  20339. static HingeJoint: number;
  20340. /**
  20341. * Ball-and-Socket joint type
  20342. */
  20343. static BallAndSocketJoint: number;
  20344. /**
  20345. * Wheel-Joint type
  20346. */
  20347. static WheelJoint: number;
  20348. /**
  20349. * Slider-Joint type
  20350. */
  20351. static SliderJoint: number;
  20352. /**
  20353. * Prismatic-Joint type
  20354. */
  20355. static PrismaticJoint: number;
  20356. /**
  20357. * Universal-Joint type
  20358. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20359. */
  20360. static UniversalJoint: number;
  20361. /**
  20362. * Hinge-Joint 2 type
  20363. */
  20364. static Hinge2Joint: number;
  20365. /**
  20366. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20367. */
  20368. static PointToPointJoint: number;
  20369. /**
  20370. * Spring-Joint type
  20371. */
  20372. static SpringJoint: number;
  20373. /**
  20374. * Lock-Joint type
  20375. */
  20376. static LockJoint: number;
  20377. }
  20378. /**
  20379. * A class representing a physics distance joint
  20380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20381. */
  20382. export class DistanceJoint extends PhysicsJoint {
  20383. /**
  20384. *
  20385. * @param jointData The data for the Distance-Joint
  20386. */
  20387. constructor(jointData: DistanceJointData);
  20388. /**
  20389. * Update the predefined distance.
  20390. * @param maxDistance The maximum preferred distance
  20391. * @param minDistance The minimum preferred distance
  20392. */
  20393. updateDistance(maxDistance: number, minDistance?: number): void;
  20394. }
  20395. /**
  20396. * Represents a Motor-Enabled Joint
  20397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20398. */
  20399. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20400. /**
  20401. * Initializes the Motor-Enabled Joint
  20402. * @param type The type of the joint
  20403. * @param jointData The physica joint data for the joint
  20404. */
  20405. constructor(type: number, jointData: PhysicsJointData);
  20406. /**
  20407. * Set the motor values.
  20408. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20409. * @param force the force to apply
  20410. * @param maxForce max force for this motor.
  20411. */
  20412. setMotor(force?: number, maxForce?: number): void;
  20413. /**
  20414. * Set the motor's limits.
  20415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20416. * @param upperLimit The upper limit of the motor
  20417. * @param lowerLimit The lower limit of the motor
  20418. */
  20419. setLimit(upperLimit: number, lowerLimit?: number): void;
  20420. }
  20421. /**
  20422. * This class represents a single physics Hinge-Joint
  20423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20424. */
  20425. export class HingeJoint extends MotorEnabledJoint {
  20426. /**
  20427. * Initializes the Hinge-Joint
  20428. * @param jointData The joint data for the Hinge-Joint
  20429. */
  20430. constructor(jointData: PhysicsJointData);
  20431. /**
  20432. * Set the motor values.
  20433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20434. * @param {number} force the force to apply
  20435. * @param {number} maxForce max force for this motor.
  20436. */
  20437. setMotor(force?: number, maxForce?: number): void;
  20438. /**
  20439. * Set the motor's limits.
  20440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20441. * @param upperLimit The upper limit of the motor
  20442. * @param lowerLimit The lower limit of the motor
  20443. */
  20444. setLimit(upperLimit: number, lowerLimit?: number): void;
  20445. }
  20446. /**
  20447. * This class represents a dual hinge physics joint (same as wheel joint)
  20448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20449. */
  20450. export class Hinge2Joint extends MotorEnabledJoint {
  20451. /**
  20452. * Initializes the Hinge2-Joint
  20453. * @param jointData The joint data for the Hinge2-Joint
  20454. */
  20455. constructor(jointData: PhysicsJointData);
  20456. /**
  20457. * Set the motor values.
  20458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20459. * @param {number} targetSpeed the speed the motor is to reach
  20460. * @param {number} maxForce max force for this motor.
  20461. * @param {motorIndex} the motor's index, 0 or 1.
  20462. */
  20463. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20464. /**
  20465. * Set the motor limits.
  20466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20467. * @param {number} upperLimit the upper limit
  20468. * @param {number} lowerLimit lower limit
  20469. * @param {motorIndex} the motor's index, 0 or 1.
  20470. */
  20471. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20472. }
  20473. /**
  20474. * Interface for a motor enabled joint
  20475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20476. */
  20477. export interface IMotorEnabledJoint {
  20478. /**
  20479. * Physics joint
  20480. */
  20481. physicsJoint: any;
  20482. /**
  20483. * Sets the motor of the motor-enabled joint
  20484. * @param force The force of the motor
  20485. * @param maxForce The maximum force of the motor
  20486. * @param motorIndex The index of the motor
  20487. */
  20488. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20489. /**
  20490. * Sets the limit of the motor
  20491. * @param upperLimit The upper limit of the motor
  20492. * @param lowerLimit The lower limit of the motor
  20493. * @param motorIndex The index of the motor
  20494. */
  20495. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20496. }
  20497. /**
  20498. * Joint data for a Distance-Joint
  20499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20500. */
  20501. export interface DistanceJointData extends PhysicsJointData {
  20502. /**
  20503. * Max distance the 2 joint objects can be apart
  20504. */
  20505. maxDistance: number;
  20506. }
  20507. /**
  20508. * Joint data from a spring joint
  20509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20510. */
  20511. export interface SpringJointData extends PhysicsJointData {
  20512. /**
  20513. * Length of the spring
  20514. */
  20515. length: number;
  20516. /**
  20517. * Stiffness of the spring
  20518. */
  20519. stiffness: number;
  20520. /**
  20521. * Damping of the spring
  20522. */
  20523. damping: number;
  20524. /** this callback will be called when applying the force to the impostors. */
  20525. forceApplicationCallback: () => void;
  20526. }
  20527. }
  20528. declare module "babylonjs/Physics/physicsRaycastResult" {
  20529. import { Vector3 } from "babylonjs/Maths/math";
  20530. /**
  20531. * Holds the data for the raycast result
  20532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20533. */
  20534. export class PhysicsRaycastResult {
  20535. private _hasHit;
  20536. private _hitDistance;
  20537. private _hitNormalWorld;
  20538. private _hitPointWorld;
  20539. private _rayFromWorld;
  20540. private _rayToWorld;
  20541. /**
  20542. * Gets if there was a hit
  20543. */
  20544. readonly hasHit: boolean;
  20545. /**
  20546. * Gets the distance from the hit
  20547. */
  20548. readonly hitDistance: number;
  20549. /**
  20550. * Gets the hit normal/direction in the world
  20551. */
  20552. readonly hitNormalWorld: Vector3;
  20553. /**
  20554. * Gets the hit point in the world
  20555. */
  20556. readonly hitPointWorld: Vector3;
  20557. /**
  20558. * Gets the ray "start point" of the ray in the world
  20559. */
  20560. readonly rayFromWorld: Vector3;
  20561. /**
  20562. * Gets the ray "end point" of the ray in the world
  20563. */
  20564. readonly rayToWorld: Vector3;
  20565. /**
  20566. * Sets the hit data (normal & point in world space)
  20567. * @param hitNormalWorld defines the normal in world space
  20568. * @param hitPointWorld defines the point in world space
  20569. */
  20570. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20571. /**
  20572. * Sets the distance from the start point to the hit point
  20573. * @param distance
  20574. */
  20575. setHitDistance(distance: number): void;
  20576. /**
  20577. * Calculates the distance manually
  20578. */
  20579. calculateHitDistance(): void;
  20580. /**
  20581. * Resets all the values to default
  20582. * @param from The from point on world space
  20583. * @param to The to point on world space
  20584. */
  20585. reset(from?: Vector3, to?: Vector3): void;
  20586. }
  20587. /**
  20588. * Interface for the size containing width and height
  20589. */
  20590. interface IXYZ {
  20591. /**
  20592. * X
  20593. */
  20594. x: number;
  20595. /**
  20596. * Y
  20597. */
  20598. y: number;
  20599. /**
  20600. * Z
  20601. */
  20602. z: number;
  20603. }
  20604. }
  20605. declare module "babylonjs/Physics/IPhysicsEngine" {
  20606. import { Nullable } from "babylonjs/types";
  20607. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20609. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20610. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20611. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20612. /**
  20613. * Interface used to describe a physics joint
  20614. */
  20615. export interface PhysicsImpostorJoint {
  20616. /** Defines the main impostor to which the joint is linked */
  20617. mainImpostor: PhysicsImpostor;
  20618. /** Defines the impostor that is connected to the main impostor using this joint */
  20619. connectedImpostor: PhysicsImpostor;
  20620. /** Defines the joint itself */
  20621. joint: PhysicsJoint;
  20622. }
  20623. /** @hidden */
  20624. export interface IPhysicsEnginePlugin {
  20625. world: any;
  20626. name: string;
  20627. setGravity(gravity: Vector3): void;
  20628. setTimeStep(timeStep: number): void;
  20629. getTimeStep(): number;
  20630. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20634. removePhysicsBody(impostor: PhysicsImpostor): void;
  20635. generateJoint(joint: PhysicsImpostorJoint): void;
  20636. removeJoint(joint: PhysicsImpostorJoint): void;
  20637. isSupported(): boolean;
  20638. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20639. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20642. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20643. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20645. getBodyMass(impostor: PhysicsImpostor): number;
  20646. getBodyFriction(impostor: PhysicsImpostor): number;
  20647. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20648. getBodyRestitution(impostor: PhysicsImpostor): number;
  20649. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20650. getBodyPressure?(impostor: PhysicsImpostor): number;
  20651. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20652. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20653. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20654. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20655. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20656. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20657. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20658. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20659. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20660. sleepBody(impostor: PhysicsImpostor): void;
  20661. wakeUpBody(impostor: PhysicsImpostor): void;
  20662. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20663. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20664. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20665. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20666. getRadius(impostor: PhysicsImpostor): number;
  20667. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20668. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20669. dispose(): void;
  20670. }
  20671. /**
  20672. * Interface used to define a physics engine
  20673. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20674. */
  20675. export interface IPhysicsEngine {
  20676. /**
  20677. * Gets the gravity vector used by the simulation
  20678. */
  20679. gravity: Vector3;
  20680. /**
  20681. * Sets the gravity vector used by the simulation
  20682. * @param gravity defines the gravity vector to use
  20683. */
  20684. setGravity(gravity: Vector3): void;
  20685. /**
  20686. * Set the time step of the physics engine.
  20687. * Default is 1/60.
  20688. * To slow it down, enter 1/600 for example.
  20689. * To speed it up, 1/30
  20690. * @param newTimeStep the new timestep to apply to this world.
  20691. */
  20692. setTimeStep(newTimeStep: number): void;
  20693. /**
  20694. * Get the time step of the physics engine.
  20695. * @returns the current time step
  20696. */
  20697. getTimeStep(): number;
  20698. /**
  20699. * Release all resources
  20700. */
  20701. dispose(): void;
  20702. /**
  20703. * Gets the name of the current physics plugin
  20704. * @returns the name of the plugin
  20705. */
  20706. getPhysicsPluginName(): string;
  20707. /**
  20708. * Adding a new impostor for the impostor tracking.
  20709. * This will be done by the impostor itself.
  20710. * @param impostor the impostor to add
  20711. */
  20712. addImpostor(impostor: PhysicsImpostor): void;
  20713. /**
  20714. * Remove an impostor from the engine.
  20715. * This impostor and its mesh will not longer be updated by the physics engine.
  20716. * @param impostor the impostor to remove
  20717. */
  20718. removeImpostor(impostor: PhysicsImpostor): void;
  20719. /**
  20720. * Add a joint to the physics engine
  20721. * @param mainImpostor defines the main impostor to which the joint is added.
  20722. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20723. * @param joint defines the joint that will connect both impostors.
  20724. */
  20725. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20726. /**
  20727. * Removes a joint from the simulation
  20728. * @param mainImpostor defines the impostor used with the joint
  20729. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20730. * @param joint defines the joint to remove
  20731. */
  20732. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20733. /**
  20734. * Gets the current plugin used to run the simulation
  20735. * @returns current plugin
  20736. */
  20737. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20738. /**
  20739. * Gets the list of physic impostors
  20740. * @returns an array of PhysicsImpostor
  20741. */
  20742. getImpostors(): Array<PhysicsImpostor>;
  20743. /**
  20744. * Gets the impostor for a physics enabled object
  20745. * @param object defines the object impersonated by the impostor
  20746. * @returns the PhysicsImpostor or null if not found
  20747. */
  20748. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20749. /**
  20750. * Gets the impostor for a physics body object
  20751. * @param body defines physics body used by the impostor
  20752. * @returns the PhysicsImpostor or null if not found
  20753. */
  20754. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20755. /**
  20756. * Does a raycast in the physics world
  20757. * @param from when should the ray start?
  20758. * @param to when should the ray end?
  20759. * @returns PhysicsRaycastResult
  20760. */
  20761. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20762. /**
  20763. * Called by the scene. No need to call it.
  20764. * @param delta defines the timespam between frames
  20765. */
  20766. _step(delta: number): void;
  20767. }
  20768. }
  20769. declare module "babylonjs/Physics/physicsImpostor" {
  20770. import { Nullable, IndicesArray } from "babylonjs/types";
  20771. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20772. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20774. import { Scene } from "babylonjs/scene";
  20775. import { Bone } from "babylonjs/Bones/bone";
  20776. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20777. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20778. /**
  20779. * The interface for the physics imposter parameters
  20780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20781. */
  20782. export interface PhysicsImpostorParameters {
  20783. /**
  20784. * The mass of the physics imposter
  20785. */
  20786. mass: number;
  20787. /**
  20788. * The friction of the physics imposter
  20789. */
  20790. friction?: number;
  20791. /**
  20792. * The coefficient of restitution of the physics imposter
  20793. */
  20794. restitution?: number;
  20795. /**
  20796. * The native options of the physics imposter
  20797. */
  20798. nativeOptions?: any;
  20799. /**
  20800. * Specifies if the parent should be ignored
  20801. */
  20802. ignoreParent?: boolean;
  20803. /**
  20804. * Specifies if bi-directional transformations should be disabled
  20805. */
  20806. disableBidirectionalTransformation?: boolean;
  20807. /**
  20808. * The pressure inside the physics imposter, soft object only
  20809. */
  20810. pressure?: number;
  20811. /**
  20812. * The stiffness the physics imposter, soft object only
  20813. */
  20814. stiffness?: number;
  20815. /**
  20816. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20817. */
  20818. velocityIterations?: number;
  20819. /**
  20820. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20821. */
  20822. positionIterations?: number;
  20823. /**
  20824. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20825. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20826. * Add to fix multiple points
  20827. */
  20828. fixedPoints?: number;
  20829. /**
  20830. * The collision margin around a soft object
  20831. */
  20832. margin?: number;
  20833. /**
  20834. * The collision margin around a soft object
  20835. */
  20836. damping?: number;
  20837. /**
  20838. * The path for a rope based on an extrusion
  20839. */
  20840. path?: any;
  20841. /**
  20842. * The shape of an extrusion used for a rope based on an extrusion
  20843. */
  20844. shape?: any;
  20845. }
  20846. /**
  20847. * Interface for a physics-enabled object
  20848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20849. */
  20850. export interface IPhysicsEnabledObject {
  20851. /**
  20852. * The position of the physics-enabled object
  20853. */
  20854. position: Vector3;
  20855. /**
  20856. * The rotation of the physics-enabled object
  20857. */
  20858. rotationQuaternion: Nullable<Quaternion>;
  20859. /**
  20860. * The scale of the physics-enabled object
  20861. */
  20862. scaling: Vector3;
  20863. /**
  20864. * The rotation of the physics-enabled object
  20865. */
  20866. rotation?: Vector3;
  20867. /**
  20868. * The parent of the physics-enabled object
  20869. */
  20870. parent?: any;
  20871. /**
  20872. * The bounding info of the physics-enabled object
  20873. * @returns The bounding info of the physics-enabled object
  20874. */
  20875. getBoundingInfo(): BoundingInfo;
  20876. /**
  20877. * Computes the world matrix
  20878. * @param force Specifies if the world matrix should be computed by force
  20879. * @returns A world matrix
  20880. */
  20881. computeWorldMatrix(force: boolean): Matrix;
  20882. /**
  20883. * Gets the world matrix
  20884. * @returns A world matrix
  20885. */
  20886. getWorldMatrix?(): Matrix;
  20887. /**
  20888. * Gets the child meshes
  20889. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20890. * @returns An array of abstract meshes
  20891. */
  20892. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20893. /**
  20894. * Gets the vertex data
  20895. * @param kind The type of vertex data
  20896. * @returns A nullable array of numbers, or a float32 array
  20897. */
  20898. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20899. /**
  20900. * Gets the indices from the mesh
  20901. * @returns A nullable array of index arrays
  20902. */
  20903. getIndices?(): Nullable<IndicesArray>;
  20904. /**
  20905. * Gets the scene from the mesh
  20906. * @returns the indices array or null
  20907. */
  20908. getScene?(): Scene;
  20909. /**
  20910. * Gets the absolute position from the mesh
  20911. * @returns the absolute position
  20912. */
  20913. getAbsolutePosition(): Vector3;
  20914. /**
  20915. * Gets the absolute pivot point from the mesh
  20916. * @returns the absolute pivot point
  20917. */
  20918. getAbsolutePivotPoint(): Vector3;
  20919. /**
  20920. * Rotates the mesh
  20921. * @param axis The axis of rotation
  20922. * @param amount The amount of rotation
  20923. * @param space The space of the rotation
  20924. * @returns The rotation transform node
  20925. */
  20926. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20927. /**
  20928. * Translates the mesh
  20929. * @param axis The axis of translation
  20930. * @param distance The distance of translation
  20931. * @param space The space of the translation
  20932. * @returns The transform node
  20933. */
  20934. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20935. /**
  20936. * Sets the absolute position of the mesh
  20937. * @param absolutePosition The absolute position of the mesh
  20938. * @returns The transform node
  20939. */
  20940. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20941. /**
  20942. * Gets the class name of the mesh
  20943. * @returns The class name
  20944. */
  20945. getClassName(): string;
  20946. }
  20947. /**
  20948. * Represents a physics imposter
  20949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20950. */
  20951. export class PhysicsImpostor {
  20952. /**
  20953. * The physics-enabled object used as the physics imposter
  20954. */
  20955. object: IPhysicsEnabledObject;
  20956. /**
  20957. * The type of the physics imposter
  20958. */
  20959. type: number;
  20960. private _options;
  20961. private _scene?;
  20962. /**
  20963. * The default object size of the imposter
  20964. */
  20965. static DEFAULT_OBJECT_SIZE: Vector3;
  20966. /**
  20967. * The identity quaternion of the imposter
  20968. */
  20969. static IDENTITY_QUATERNION: Quaternion;
  20970. /** @hidden */
  20971. _pluginData: any;
  20972. private _physicsEngine;
  20973. private _physicsBody;
  20974. private _bodyUpdateRequired;
  20975. private _onBeforePhysicsStepCallbacks;
  20976. private _onAfterPhysicsStepCallbacks;
  20977. /** @hidden */
  20978. _onPhysicsCollideCallbacks: Array<{
  20979. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20980. otherImpostors: Array<PhysicsImpostor>;
  20981. }>;
  20982. private _deltaPosition;
  20983. private _deltaRotation;
  20984. private _deltaRotationConjugated;
  20985. /** hidden */
  20986. _isFromLine: boolean;
  20987. private _parent;
  20988. private _isDisposed;
  20989. private static _tmpVecs;
  20990. private static _tmpQuat;
  20991. /**
  20992. * Specifies if the physics imposter is disposed
  20993. */
  20994. readonly isDisposed: boolean;
  20995. /**
  20996. * Gets the mass of the physics imposter
  20997. */
  20998. mass: number;
  20999. /**
  21000. * Gets the coefficient of friction
  21001. */
  21002. /**
  21003. * Sets the coefficient of friction
  21004. */
  21005. friction: number;
  21006. /**
  21007. * Gets the coefficient of restitution
  21008. */
  21009. /**
  21010. * Sets the coefficient of restitution
  21011. */
  21012. restitution: number;
  21013. /**
  21014. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21015. */
  21016. /**
  21017. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21018. */
  21019. pressure: number;
  21020. /**
  21021. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21022. */
  21023. /**
  21024. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21025. */
  21026. stiffness: number;
  21027. /**
  21028. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21029. */
  21030. /**
  21031. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21032. */
  21033. velocityIterations: number;
  21034. /**
  21035. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21036. */
  21037. /**
  21038. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21039. */
  21040. positionIterations: number;
  21041. /**
  21042. * The unique id of the physics imposter
  21043. * set by the physics engine when adding this impostor to the array
  21044. */
  21045. uniqueId: number;
  21046. /**
  21047. * @hidden
  21048. */
  21049. soft: boolean;
  21050. /**
  21051. * @hidden
  21052. */
  21053. segments: number;
  21054. private _joints;
  21055. /**
  21056. * Initializes the physics imposter
  21057. * @param object The physics-enabled object used as the physics imposter
  21058. * @param type The type of the physics imposter
  21059. * @param _options The options for the physics imposter
  21060. * @param _scene The Babylon scene
  21061. */
  21062. constructor(
  21063. /**
  21064. * The physics-enabled object used as the physics imposter
  21065. */
  21066. object: IPhysicsEnabledObject,
  21067. /**
  21068. * The type of the physics imposter
  21069. */
  21070. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21071. /**
  21072. * This function will completly initialize this impostor.
  21073. * It will create a new body - but only if this mesh has no parent.
  21074. * If it has, this impostor will not be used other than to define the impostor
  21075. * of the child mesh.
  21076. * @hidden
  21077. */
  21078. _init(): void;
  21079. private _getPhysicsParent;
  21080. /**
  21081. * Should a new body be generated.
  21082. * @returns boolean specifying if body initialization is required
  21083. */
  21084. isBodyInitRequired(): boolean;
  21085. /**
  21086. * Sets the updated scaling
  21087. * @param updated Specifies if the scaling is updated
  21088. */
  21089. setScalingUpdated(): void;
  21090. /**
  21091. * Force a regeneration of this or the parent's impostor's body.
  21092. * Use under cautious - This will remove all joints already implemented.
  21093. */
  21094. forceUpdate(): void;
  21095. /**
  21096. * Gets the body that holds this impostor. Either its own, or its parent.
  21097. */
  21098. /**
  21099. * Set the physics body. Used mainly by the physics engine/plugin
  21100. */
  21101. physicsBody: any;
  21102. /**
  21103. * Get the parent of the physics imposter
  21104. * @returns Physics imposter or null
  21105. */
  21106. /**
  21107. * Sets the parent of the physics imposter
  21108. */
  21109. parent: Nullable<PhysicsImpostor>;
  21110. /**
  21111. * Resets the update flags
  21112. */
  21113. resetUpdateFlags(): void;
  21114. /**
  21115. * Gets the object extend size
  21116. * @returns the object extend size
  21117. */
  21118. getObjectExtendSize(): Vector3;
  21119. /**
  21120. * Gets the object center
  21121. * @returns The object center
  21122. */
  21123. getObjectCenter(): Vector3;
  21124. /**
  21125. * Get a specific parametes from the options parameter
  21126. * @param paramName The object parameter name
  21127. * @returns The object parameter
  21128. */
  21129. getParam(paramName: string): any;
  21130. /**
  21131. * Sets a specific parameter in the options given to the physics plugin
  21132. * @param paramName The parameter name
  21133. * @param value The value of the parameter
  21134. */
  21135. setParam(paramName: string, value: number): void;
  21136. /**
  21137. * Specifically change the body's mass option. Won't recreate the physics body object
  21138. * @param mass The mass of the physics imposter
  21139. */
  21140. setMass(mass: number): void;
  21141. /**
  21142. * Gets the linear velocity
  21143. * @returns linear velocity or null
  21144. */
  21145. getLinearVelocity(): Nullable<Vector3>;
  21146. /**
  21147. * Sets the linear velocity
  21148. * @param velocity linear velocity or null
  21149. */
  21150. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21151. /**
  21152. * Gets the angular velocity
  21153. * @returns angular velocity or null
  21154. */
  21155. getAngularVelocity(): Nullable<Vector3>;
  21156. /**
  21157. * Sets the angular velocity
  21158. * @param velocity The velocity or null
  21159. */
  21160. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21161. /**
  21162. * Execute a function with the physics plugin native code
  21163. * Provide a function the will have two variables - the world object and the physics body object
  21164. * @param func The function to execute with the physics plugin native code
  21165. */
  21166. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21167. /**
  21168. * Register a function that will be executed before the physics world is stepping forward
  21169. * @param func The function to execute before the physics world is stepped forward
  21170. */
  21171. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21172. /**
  21173. * Unregister a function that will be executed before the physics world is stepping forward
  21174. * @param func The function to execute before the physics world is stepped forward
  21175. */
  21176. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21177. /**
  21178. * Register a function that will be executed after the physics step
  21179. * @param func The function to execute after physics step
  21180. */
  21181. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21182. /**
  21183. * Unregisters a function that will be executed after the physics step
  21184. * @param func The function to execute after physics step
  21185. */
  21186. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21187. /**
  21188. * register a function that will be executed when this impostor collides against a different body
  21189. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21190. * @param func Callback that is executed on collision
  21191. */
  21192. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21193. /**
  21194. * Unregisters the physics imposter on contact
  21195. * @param collideAgainst The physics object to collide against
  21196. * @param func Callback to execute on collision
  21197. */
  21198. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21199. private _tmpQuat;
  21200. private _tmpQuat2;
  21201. /**
  21202. * Get the parent rotation
  21203. * @returns The parent rotation
  21204. */
  21205. getParentsRotation(): Quaternion;
  21206. /**
  21207. * this function is executed by the physics engine.
  21208. */
  21209. beforeStep: () => void;
  21210. /**
  21211. * this function is executed by the physics engine
  21212. */
  21213. afterStep: () => void;
  21214. /**
  21215. * Legacy collision detection event support
  21216. */
  21217. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21218. /**
  21219. * event and body object due to cannon's event-based architecture.
  21220. */
  21221. onCollide: (e: {
  21222. body: any;
  21223. }) => void;
  21224. /**
  21225. * Apply a force
  21226. * @param force The force to apply
  21227. * @param contactPoint The contact point for the force
  21228. * @returns The physics imposter
  21229. */
  21230. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21231. /**
  21232. * Apply an impulse
  21233. * @param force The impulse force
  21234. * @param contactPoint The contact point for the impulse force
  21235. * @returns The physics imposter
  21236. */
  21237. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21238. /**
  21239. * A help function to create a joint
  21240. * @param otherImpostor A physics imposter used to create a joint
  21241. * @param jointType The type of joint
  21242. * @param jointData The data for the joint
  21243. * @returns The physics imposter
  21244. */
  21245. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21246. /**
  21247. * Add a joint to this impostor with a different impostor
  21248. * @param otherImpostor A physics imposter used to add a joint
  21249. * @param joint The joint to add
  21250. * @returns The physics imposter
  21251. */
  21252. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21253. /**
  21254. * Add an anchor to a cloth impostor
  21255. * @param otherImpostor rigid impostor to anchor to
  21256. * @param width ratio across width from 0 to 1
  21257. * @param height ratio up height from 0 to 1
  21258. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21259. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21260. * @returns impostor the soft imposter
  21261. */
  21262. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21263. /**
  21264. * Add a hook to a rope impostor
  21265. * @param otherImpostor rigid impostor to anchor to
  21266. * @param length ratio across rope from 0 to 1
  21267. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21269. * @returns impostor the rope imposter
  21270. */
  21271. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21272. /**
  21273. * Will keep this body still, in a sleep mode.
  21274. * @returns the physics imposter
  21275. */
  21276. sleep(): PhysicsImpostor;
  21277. /**
  21278. * Wake the body up.
  21279. * @returns The physics imposter
  21280. */
  21281. wakeUp(): PhysicsImpostor;
  21282. /**
  21283. * Clones the physics imposter
  21284. * @param newObject The physics imposter clones to this physics-enabled object
  21285. * @returns A nullable physics imposter
  21286. */
  21287. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21288. /**
  21289. * Disposes the physics imposter
  21290. */
  21291. dispose(): void;
  21292. /**
  21293. * Sets the delta position
  21294. * @param position The delta position amount
  21295. */
  21296. setDeltaPosition(position: Vector3): void;
  21297. /**
  21298. * Sets the delta rotation
  21299. * @param rotation The delta rotation amount
  21300. */
  21301. setDeltaRotation(rotation: Quaternion): void;
  21302. /**
  21303. * Gets the box size of the physics imposter and stores the result in the input parameter
  21304. * @param result Stores the box size
  21305. * @returns The physics imposter
  21306. */
  21307. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21308. /**
  21309. * Gets the radius of the physics imposter
  21310. * @returns Radius of the physics imposter
  21311. */
  21312. getRadius(): number;
  21313. /**
  21314. * Sync a bone with this impostor
  21315. * @param bone The bone to sync to the impostor.
  21316. * @param boneMesh The mesh that the bone is influencing.
  21317. * @param jointPivot The pivot of the joint / bone in local space.
  21318. * @param distToJoint Optional distance from the impostor to the joint.
  21319. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21320. */
  21321. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21322. /**
  21323. * Sync impostor to a bone
  21324. * @param bone The bone that the impostor will be synced to.
  21325. * @param boneMesh The mesh that the bone is influencing.
  21326. * @param jointPivot The pivot of the joint / bone in local space.
  21327. * @param distToJoint Optional distance from the impostor to the joint.
  21328. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21329. * @param boneAxis Optional vector3 axis the bone is aligned with
  21330. */
  21331. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21332. /**
  21333. * No-Imposter type
  21334. */
  21335. static NoImpostor: number;
  21336. /**
  21337. * Sphere-Imposter type
  21338. */
  21339. static SphereImpostor: number;
  21340. /**
  21341. * Box-Imposter type
  21342. */
  21343. static BoxImpostor: number;
  21344. /**
  21345. * Plane-Imposter type
  21346. */
  21347. static PlaneImpostor: number;
  21348. /**
  21349. * Mesh-imposter type
  21350. */
  21351. static MeshImpostor: number;
  21352. /**
  21353. * Cylinder-Imposter type
  21354. */
  21355. static CylinderImpostor: number;
  21356. /**
  21357. * Particle-Imposter type
  21358. */
  21359. static ParticleImpostor: number;
  21360. /**
  21361. * Heightmap-Imposter type
  21362. */
  21363. static HeightmapImpostor: number;
  21364. /**
  21365. * ConvexHull-Impostor type (Ammo.js plugin only)
  21366. */
  21367. static ConvexHullImpostor: number;
  21368. /**
  21369. * Rope-Imposter type
  21370. */
  21371. static RopeImpostor: number;
  21372. /**
  21373. * Cloth-Imposter type
  21374. */
  21375. static ClothImpostor: number;
  21376. /**
  21377. * Softbody-Imposter type
  21378. */
  21379. static SoftbodyImpostor: number;
  21380. }
  21381. }
  21382. declare module "babylonjs/Meshes/mesh" {
  21383. import { Observable } from "babylonjs/Misc/observable";
  21384. import { IAnimatable } from "babylonjs/Misc/tools";
  21385. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21386. import { Camera } from "babylonjs/Cameras/camera";
  21387. import { Scene } from "babylonjs/scene";
  21388. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21389. import { Engine } from "babylonjs/Engines/engine";
  21390. import { Node } from "babylonjs/node";
  21391. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21392. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21393. import { Buffer } from "babylonjs/Meshes/buffer";
  21394. import { Geometry } from "babylonjs/Meshes/geometry";
  21395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21397. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21398. import { Effect } from "babylonjs/Materials/effect";
  21399. import { Material } from "babylonjs/Materials/material";
  21400. import { Skeleton } from "babylonjs/Bones/skeleton";
  21401. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21402. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21403. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21404. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21405. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21406. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21407. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21408. /**
  21409. * @hidden
  21410. **/
  21411. export class _CreationDataStorage {
  21412. closePath?: boolean;
  21413. closeArray?: boolean;
  21414. idx: number[];
  21415. dashSize: number;
  21416. gapSize: number;
  21417. path3D: Path3D;
  21418. pathArray: Vector3[][];
  21419. arc: number;
  21420. radius: number;
  21421. cap: number;
  21422. tessellation: number;
  21423. }
  21424. /**
  21425. * @hidden
  21426. **/
  21427. class _InstanceDataStorage {
  21428. visibleInstances: any;
  21429. batchCache: _InstancesBatch;
  21430. instancesBufferSize: number;
  21431. instancesBuffer: Nullable<Buffer>;
  21432. instancesData: Float32Array;
  21433. overridenInstanceCount: number;
  21434. isFrozen: boolean;
  21435. previousBatch: _InstancesBatch;
  21436. hardwareInstancedRendering: boolean;
  21437. sideOrientation: number;
  21438. }
  21439. /**
  21440. * @hidden
  21441. **/
  21442. export class _InstancesBatch {
  21443. mustReturn: boolean;
  21444. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21445. renderSelf: boolean[];
  21446. hardwareInstancedRendering: boolean[];
  21447. }
  21448. /**
  21449. * Class used to represent renderable models
  21450. */
  21451. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21452. /**
  21453. * Mesh side orientation : usually the external or front surface
  21454. */
  21455. static readonly FRONTSIDE: number;
  21456. /**
  21457. * Mesh side orientation : usually the internal or back surface
  21458. */
  21459. static readonly BACKSIDE: number;
  21460. /**
  21461. * Mesh side orientation : both internal and external or front and back surfaces
  21462. */
  21463. static readonly DOUBLESIDE: number;
  21464. /**
  21465. * Mesh side orientation : by default, `FRONTSIDE`
  21466. */
  21467. static readonly DEFAULTSIDE: number;
  21468. /**
  21469. * Mesh cap setting : no cap
  21470. */
  21471. static readonly NO_CAP: number;
  21472. /**
  21473. * Mesh cap setting : one cap at the beginning of the mesh
  21474. */
  21475. static readonly CAP_START: number;
  21476. /**
  21477. * Mesh cap setting : one cap at the end of the mesh
  21478. */
  21479. static readonly CAP_END: number;
  21480. /**
  21481. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21482. */
  21483. static readonly CAP_ALL: number;
  21484. /**
  21485. * Gets the default side orientation.
  21486. * @param orientation the orientation to value to attempt to get
  21487. * @returns the default orientation
  21488. * @hidden
  21489. */
  21490. static _GetDefaultSideOrientation(orientation?: number): number;
  21491. private _onBeforeRenderObservable;
  21492. private _onBeforeBindObservable;
  21493. private _onAfterRenderObservable;
  21494. private _onBeforeDrawObservable;
  21495. /**
  21496. * An event triggered before rendering the mesh
  21497. */
  21498. readonly onBeforeRenderObservable: Observable<Mesh>;
  21499. /**
  21500. * An event triggered before binding the mesh
  21501. */
  21502. readonly onBeforeBindObservable: Observable<Mesh>;
  21503. /**
  21504. * An event triggered after rendering the mesh
  21505. */
  21506. readonly onAfterRenderObservable: Observable<Mesh>;
  21507. /**
  21508. * An event triggered before drawing the mesh
  21509. */
  21510. readonly onBeforeDrawObservable: Observable<Mesh>;
  21511. private _onBeforeDrawObserver;
  21512. /**
  21513. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21514. */
  21515. onBeforeDraw: () => void;
  21516. /**
  21517. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21518. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21519. */
  21520. delayLoadState: number;
  21521. /**
  21522. * Gets the list of instances created from this mesh
  21523. * it is not supposed to be modified manually.
  21524. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21525. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21526. */
  21527. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21528. /**
  21529. * Gets the file containing delay loading data for this mesh
  21530. */
  21531. delayLoadingFile: string;
  21532. /** @hidden */
  21533. _binaryInfo: any;
  21534. private _LODLevels;
  21535. /**
  21536. * User defined function used to change how LOD level selection is done
  21537. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21538. */
  21539. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21540. private _morphTargetManager;
  21541. /**
  21542. * Gets or sets the morph target manager
  21543. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21544. */
  21545. morphTargetManager: Nullable<MorphTargetManager>;
  21546. /** @hidden */
  21547. _creationDataStorage: Nullable<_CreationDataStorage>;
  21548. /** @hidden */
  21549. _geometry: Nullable<Geometry>;
  21550. /** @hidden */
  21551. _delayInfo: Array<string>;
  21552. /** @hidden */
  21553. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21554. /** @hidden */
  21555. _instanceDataStorage: _InstanceDataStorage;
  21556. private _effectiveMaterial;
  21557. /** @hidden */
  21558. _shouldGenerateFlatShading: boolean;
  21559. private _preActivateId;
  21560. /** @hidden */
  21561. _originalBuilderSideOrientation: number;
  21562. /**
  21563. * Use this property to change the original side orientation defined at construction time
  21564. */
  21565. overrideMaterialSideOrientation: Nullable<number>;
  21566. private _areNormalsFrozen;
  21567. private _sourcePositions;
  21568. private _sourceNormals;
  21569. private _source;
  21570. private meshMap;
  21571. /**
  21572. * Gets the source mesh (the one used to clone this one from)
  21573. */
  21574. readonly source: Nullable<Mesh>;
  21575. /**
  21576. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21577. */
  21578. isUnIndexed: boolean;
  21579. /**
  21580. * @constructor
  21581. * @param name The value used by scene.getMeshByName() to do a lookup.
  21582. * @param scene The scene to add this mesh to.
  21583. * @param parent The parent of this mesh, if it has one
  21584. * @param source An optional Mesh from which geometry is shared, cloned.
  21585. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21586. * When false, achieved by calling a clone(), also passing False.
  21587. * This will make creation of children, recursive.
  21588. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21589. */
  21590. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21591. /**
  21592. * Gets the class name
  21593. * @returns the string "Mesh".
  21594. */
  21595. getClassName(): string;
  21596. /** @hidden */
  21597. readonly _isMesh: boolean;
  21598. /**
  21599. * Returns a description of this mesh
  21600. * @param fullDetails define if full details about this mesh must be used
  21601. * @returns a descriptive string representing this mesh
  21602. */
  21603. toString(fullDetails?: boolean): string;
  21604. /** @hidden */
  21605. _unBindEffect(): void;
  21606. /**
  21607. * Gets a boolean indicating if this mesh has LOD
  21608. */
  21609. readonly hasLODLevels: boolean;
  21610. /**
  21611. * Gets the list of MeshLODLevel associated with the current mesh
  21612. * @returns an array of MeshLODLevel
  21613. */
  21614. getLODLevels(): MeshLODLevel[];
  21615. private _sortLODLevels;
  21616. /**
  21617. * Add a mesh as LOD level triggered at the given distance.
  21618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21619. * @param distance The distance from the center of the object to show this level
  21620. * @param mesh The mesh to be added as LOD level (can be null)
  21621. * @return This mesh (for chaining)
  21622. */
  21623. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21624. /**
  21625. * Returns the LOD level mesh at the passed distance or null if not found.
  21626. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21627. * @param distance The distance from the center of the object to show this level
  21628. * @returns a Mesh or `null`
  21629. */
  21630. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21631. /**
  21632. * Remove a mesh from the LOD array
  21633. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21634. * @param mesh defines the mesh to be removed
  21635. * @return This mesh (for chaining)
  21636. */
  21637. removeLODLevel(mesh: Mesh): Mesh;
  21638. /**
  21639. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21640. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21641. * @param camera defines the camera to use to compute distance
  21642. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21643. * @return This mesh (for chaining)
  21644. */
  21645. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21646. /**
  21647. * Gets the mesh internal Geometry object
  21648. */
  21649. readonly geometry: Nullable<Geometry>;
  21650. /**
  21651. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21652. * @returns the total number of vertices
  21653. */
  21654. getTotalVertices(): number;
  21655. /**
  21656. * Returns the content of an associated vertex buffer
  21657. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21658. * - VertexBuffer.PositionKind
  21659. * - VertexBuffer.UVKind
  21660. * - VertexBuffer.UV2Kind
  21661. * - VertexBuffer.UV3Kind
  21662. * - VertexBuffer.UV4Kind
  21663. * - VertexBuffer.UV5Kind
  21664. * - VertexBuffer.UV6Kind
  21665. * - VertexBuffer.ColorKind
  21666. * - VertexBuffer.MatricesIndicesKind
  21667. * - VertexBuffer.MatricesIndicesExtraKind
  21668. * - VertexBuffer.MatricesWeightsKind
  21669. * - VertexBuffer.MatricesWeightsExtraKind
  21670. * @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
  21671. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21672. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21673. */
  21674. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21675. /**
  21676. * Returns the mesh VertexBuffer object from the requested `kind`
  21677. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21678. * - VertexBuffer.PositionKind
  21679. * - VertexBuffer.UVKind
  21680. * - VertexBuffer.UV2Kind
  21681. * - VertexBuffer.UV3Kind
  21682. * - VertexBuffer.UV4Kind
  21683. * - VertexBuffer.UV5Kind
  21684. * - VertexBuffer.UV6Kind
  21685. * - VertexBuffer.ColorKind
  21686. * - VertexBuffer.MatricesIndicesKind
  21687. * - VertexBuffer.MatricesIndicesExtraKind
  21688. * - VertexBuffer.MatricesWeightsKind
  21689. * - VertexBuffer.MatricesWeightsExtraKind
  21690. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21691. */
  21692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21693. /**
  21694. * Tests if a specific vertex buffer is associated with this mesh
  21695. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21696. * - VertexBuffer.PositionKind
  21697. * - VertexBuffer.UVKind
  21698. * - VertexBuffer.UV2Kind
  21699. * - VertexBuffer.UV3Kind
  21700. * - VertexBuffer.UV4Kind
  21701. * - VertexBuffer.UV5Kind
  21702. * - VertexBuffer.UV6Kind
  21703. * - VertexBuffer.ColorKind
  21704. * - VertexBuffer.MatricesIndicesKind
  21705. * - VertexBuffer.MatricesIndicesExtraKind
  21706. * - VertexBuffer.MatricesWeightsKind
  21707. * - VertexBuffer.MatricesWeightsExtraKind
  21708. * @returns a boolean
  21709. */
  21710. isVerticesDataPresent(kind: string): boolean;
  21711. /**
  21712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21713. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21714. * - VertexBuffer.PositionKind
  21715. * - VertexBuffer.UVKind
  21716. * - VertexBuffer.UV2Kind
  21717. * - VertexBuffer.UV3Kind
  21718. * - VertexBuffer.UV4Kind
  21719. * - VertexBuffer.UV5Kind
  21720. * - VertexBuffer.UV6Kind
  21721. * - VertexBuffer.ColorKind
  21722. * - VertexBuffer.MatricesIndicesKind
  21723. * - VertexBuffer.MatricesIndicesExtraKind
  21724. * - VertexBuffer.MatricesWeightsKind
  21725. * - VertexBuffer.MatricesWeightsExtraKind
  21726. * @returns a boolean
  21727. */
  21728. isVertexBufferUpdatable(kind: string): boolean;
  21729. /**
  21730. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21731. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21732. * - VertexBuffer.PositionKind
  21733. * - VertexBuffer.UVKind
  21734. * - VertexBuffer.UV2Kind
  21735. * - VertexBuffer.UV3Kind
  21736. * - VertexBuffer.UV4Kind
  21737. * - VertexBuffer.UV5Kind
  21738. * - VertexBuffer.UV6Kind
  21739. * - VertexBuffer.ColorKind
  21740. * - VertexBuffer.MatricesIndicesKind
  21741. * - VertexBuffer.MatricesIndicesExtraKind
  21742. * - VertexBuffer.MatricesWeightsKind
  21743. * - VertexBuffer.MatricesWeightsExtraKind
  21744. * @returns an array of strings
  21745. */
  21746. getVerticesDataKinds(): string[];
  21747. /**
  21748. * Returns a positive integer : the total number of indices in this mesh geometry.
  21749. * @returns the numner of indices or zero if the mesh has no geometry.
  21750. */
  21751. getTotalIndices(): number;
  21752. /**
  21753. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21754. * @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.
  21755. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21756. * @returns the indices array or an empty array if the mesh has no geometry
  21757. */
  21758. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21759. readonly isBlocked: boolean;
  21760. /**
  21761. * Determine if the current mesh is ready to be rendered
  21762. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21763. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21764. * @returns true if all associated assets are ready (material, textures, shaders)
  21765. */
  21766. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21767. /**
  21768. * 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.
  21769. */
  21770. readonly areNormalsFrozen: boolean;
  21771. /**
  21772. * 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.
  21773. * @returns the current mesh
  21774. */
  21775. freezeNormals(): Mesh;
  21776. /**
  21777. * 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
  21778. * @returns the current mesh
  21779. */
  21780. unfreezeNormals(): Mesh;
  21781. /**
  21782. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21783. */
  21784. overridenInstanceCount: number;
  21785. /** @hidden */
  21786. _preActivate(): Mesh;
  21787. /** @hidden */
  21788. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21789. /** @hidden */
  21790. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21791. /**
  21792. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21793. * This means the mesh underlying bounding box and sphere are recomputed.
  21794. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21795. * @returns the current mesh
  21796. */
  21797. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21798. /** @hidden */
  21799. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21800. /**
  21801. * This function will subdivide the mesh into multiple submeshes
  21802. * @param count defines the expected number of submeshes
  21803. */
  21804. subdivide(count: number): void;
  21805. /**
  21806. * Copy a FloatArray into a specific associated vertex buffer
  21807. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21808. * - VertexBuffer.PositionKind
  21809. * - VertexBuffer.UVKind
  21810. * - VertexBuffer.UV2Kind
  21811. * - VertexBuffer.UV3Kind
  21812. * - VertexBuffer.UV4Kind
  21813. * - VertexBuffer.UV5Kind
  21814. * - VertexBuffer.UV6Kind
  21815. * - VertexBuffer.ColorKind
  21816. * - VertexBuffer.MatricesIndicesKind
  21817. * - VertexBuffer.MatricesIndicesExtraKind
  21818. * - VertexBuffer.MatricesWeightsKind
  21819. * - VertexBuffer.MatricesWeightsExtraKind
  21820. * @param data defines the data source
  21821. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21822. * @param stride defines the data stride size (can be null)
  21823. * @returns the current mesh
  21824. */
  21825. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21826. /**
  21827. * Flags an associated vertex buffer as updatable
  21828. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21829. * - VertexBuffer.PositionKind
  21830. * - VertexBuffer.UVKind
  21831. * - VertexBuffer.UV2Kind
  21832. * - VertexBuffer.UV3Kind
  21833. * - VertexBuffer.UV4Kind
  21834. * - VertexBuffer.UV5Kind
  21835. * - VertexBuffer.UV6Kind
  21836. * - VertexBuffer.ColorKind
  21837. * - VertexBuffer.MatricesIndicesKind
  21838. * - VertexBuffer.MatricesIndicesExtraKind
  21839. * - VertexBuffer.MatricesWeightsKind
  21840. * - VertexBuffer.MatricesWeightsExtraKind
  21841. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21842. */
  21843. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21844. /**
  21845. * Sets the mesh global Vertex Buffer
  21846. * @param buffer defines the buffer to use
  21847. * @returns the current mesh
  21848. */
  21849. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21850. /**
  21851. * Update a specific associated vertex buffer
  21852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21853. * - VertexBuffer.PositionKind
  21854. * - VertexBuffer.UVKind
  21855. * - VertexBuffer.UV2Kind
  21856. * - VertexBuffer.UV3Kind
  21857. * - VertexBuffer.UV4Kind
  21858. * - VertexBuffer.UV5Kind
  21859. * - VertexBuffer.UV6Kind
  21860. * - VertexBuffer.ColorKind
  21861. * - VertexBuffer.MatricesIndicesKind
  21862. * - VertexBuffer.MatricesIndicesExtraKind
  21863. * - VertexBuffer.MatricesWeightsKind
  21864. * - VertexBuffer.MatricesWeightsExtraKind
  21865. * @param data defines the data source
  21866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21867. * @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)
  21868. * @returns the current mesh
  21869. */
  21870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21871. /**
  21872. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21873. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21874. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21875. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21876. * @returns the current mesh
  21877. */
  21878. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21879. /**
  21880. * Creates a un-shared specific occurence of the geometry for the mesh.
  21881. * @returns the current mesh
  21882. */
  21883. makeGeometryUnique(): Mesh;
  21884. /**
  21885. * Set the index buffer of this mesh
  21886. * @param indices defines the source data
  21887. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21888. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21889. * @returns the current mesh
  21890. */
  21891. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21892. /**
  21893. * Update the current index buffer
  21894. * @param indices defines the source data
  21895. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21896. * @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)
  21897. * @returns the current mesh
  21898. */
  21899. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21900. /**
  21901. * Invert the geometry to move from a right handed system to a left handed one.
  21902. * @returns the current mesh
  21903. */
  21904. toLeftHanded(): Mesh;
  21905. /** @hidden */
  21906. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21907. /** @hidden */
  21908. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21909. /**
  21910. * Registers for this mesh a javascript function called just before the rendering process
  21911. * @param func defines the function to call before rendering this mesh
  21912. * @returns the current mesh
  21913. */
  21914. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21915. /**
  21916. * Disposes a previously registered javascript function called before the rendering
  21917. * @param func defines the function to remove
  21918. * @returns the current mesh
  21919. */
  21920. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21921. /**
  21922. * Registers for this mesh a javascript function called just after the rendering is complete
  21923. * @param func defines the function to call after rendering this mesh
  21924. * @returns the current mesh
  21925. */
  21926. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21927. /**
  21928. * Disposes a previously registered javascript function called after the rendering.
  21929. * @param func defines the function to remove
  21930. * @returns the current mesh
  21931. */
  21932. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21933. /** @hidden */
  21934. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21935. /** @hidden */
  21936. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21937. /** @hidden */
  21938. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21939. /** @hidden */
  21940. _freeze(): void;
  21941. /** @hidden */
  21942. _unFreeze(): void;
  21943. /**
  21944. * 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
  21945. * @param subMesh defines the subMesh to render
  21946. * @param enableAlphaMode defines if alpha mode can be changed
  21947. * @returns the current mesh
  21948. */
  21949. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21950. private _onBeforeDraw;
  21951. /**
  21952. * Renormalize the mesh and patch it up if there are no weights
  21953. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21954. * However in the case of zero weights then we set just a single influence to 1.
  21955. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21956. */
  21957. cleanMatrixWeights(): void;
  21958. private normalizeSkinFourWeights;
  21959. private normalizeSkinWeightsAndExtra;
  21960. /**
  21961. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21962. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21963. * the user know there was an issue with importing the mesh
  21964. * @returns a validation object with skinned, valid and report string
  21965. */
  21966. validateSkinning(): {
  21967. skinned: boolean;
  21968. valid: boolean;
  21969. report: string;
  21970. };
  21971. /** @hidden */
  21972. _checkDelayState(): Mesh;
  21973. private _queueLoad;
  21974. /**
  21975. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21976. * A mesh is in the frustum if its bounding box intersects the frustum
  21977. * @param frustumPlanes defines the frustum to test
  21978. * @returns true if the mesh is in the frustum planes
  21979. */
  21980. isInFrustum(frustumPlanes: Plane[]): boolean;
  21981. /**
  21982. * Sets the mesh material by the material or multiMaterial `id` property
  21983. * @param id is a string identifying the material or the multiMaterial
  21984. * @returns the current mesh
  21985. */
  21986. setMaterialByID(id: string): Mesh;
  21987. /**
  21988. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21989. * @returns an array of IAnimatable
  21990. */
  21991. getAnimatables(): IAnimatable[];
  21992. /**
  21993. * Modifies the mesh geometry according to the passed transformation matrix.
  21994. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21995. * The mesh normals are modified using the same transformation.
  21996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21997. * @param transform defines the transform matrix to use
  21998. * @see http://doc.babylonjs.com/resources/baking_transformations
  21999. * @returns the current mesh
  22000. */
  22001. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22002. /**
  22003. * Modifies the mesh geometry according to its own current World Matrix.
  22004. * The mesh World Matrix is then reset.
  22005. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22006. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22007. * @see http://doc.babylonjs.com/resources/baking_transformations
  22008. * @returns the current mesh
  22009. */
  22010. bakeCurrentTransformIntoVertices(): Mesh;
  22011. /** @hidden */
  22012. readonly _positions: Nullable<Vector3[]>;
  22013. /** @hidden */
  22014. _resetPointsArrayCache(): Mesh;
  22015. /** @hidden */
  22016. _generatePointsArray(): boolean;
  22017. /**
  22018. * Returns a new Mesh object generated from the current mesh properties.
  22019. * This method must not get confused with createInstance()
  22020. * @param name is a string, the name given to the new mesh
  22021. * @param newParent can be any Node object (default `null`)
  22022. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22023. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22024. * @returns a new mesh
  22025. */
  22026. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22027. /**
  22028. * Releases resources associated with this mesh.
  22029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22031. */
  22032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22033. /**
  22034. * Modifies the mesh geometry according to a displacement map.
  22035. * 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.
  22036. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22037. * @param url is a string, the URL from the image file is to be downloaded.
  22038. * @param minHeight is the lower limit of the displacement.
  22039. * @param maxHeight is the upper limit of the displacement.
  22040. * @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.
  22041. * @param uvOffset is an optional vector2 used to offset UV.
  22042. * @param uvScale is an optional vector2 used to scale UV.
  22043. * @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.
  22044. * @returns the Mesh.
  22045. */
  22046. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22047. /**
  22048. * Modifies the mesh geometry according to a displacementMap buffer.
  22049. * 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.
  22050. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22051. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22052. * @param heightMapWidth is the width of the buffer image.
  22053. * @param heightMapHeight is the height of the buffer image.
  22054. * @param minHeight is the lower limit of the displacement.
  22055. * @param maxHeight is the upper limit of the displacement.
  22056. * @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.
  22057. * @param uvOffset is an optional vector2 used to offset UV.
  22058. * @param uvScale is an optional vector2 used to scale UV.
  22059. * @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.
  22060. * @returns the Mesh.
  22061. */
  22062. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22063. /**
  22064. * Modify the mesh to get a flat shading rendering.
  22065. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22066. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22067. * @returns current mesh
  22068. */
  22069. convertToFlatShadedMesh(): Mesh;
  22070. /**
  22071. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22072. * In other words, more vertices, no more indices and a single bigger VBO.
  22073. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22074. * @returns current mesh
  22075. */
  22076. convertToUnIndexedMesh(): Mesh;
  22077. /**
  22078. * Inverses facet orientations.
  22079. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22080. * @param flipNormals will also inverts the normals
  22081. * @returns current mesh
  22082. */
  22083. flipFaces(flipNormals?: boolean): Mesh;
  22084. /**
  22085. * Increase the number of facets and hence vertices in a mesh
  22086. * Vertex normals are interpolated from existing vertex normals
  22087. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22088. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22089. */
  22090. increaseVertices(numberPerEdge: number): void;
  22091. /**
  22092. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22093. * This will undo any application of covertToFlatShadedMesh
  22094. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22095. */
  22096. forceSharedVertices(): void;
  22097. /** @hidden */
  22098. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22099. /** @hidden */
  22100. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22101. /**
  22102. * Creates a new InstancedMesh object from the mesh model.
  22103. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22104. * @param name defines the name of the new instance
  22105. * @returns a new InstancedMesh
  22106. */
  22107. createInstance(name: string): InstancedMesh;
  22108. /**
  22109. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22110. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22111. * @returns the current mesh
  22112. */
  22113. synchronizeInstances(): Mesh;
  22114. /**
  22115. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22116. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22117. * This should be used together with the simplification to avoid disappearing triangles.
  22118. * @param successCallback an optional success callback to be called after the optimization finished.
  22119. * @returns the current mesh
  22120. */
  22121. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22122. /**
  22123. * Serialize current mesh
  22124. * @param serializationObject defines the object which will receive the serialization data
  22125. */
  22126. serialize(serializationObject: any): void;
  22127. /** @hidden */
  22128. _syncGeometryWithMorphTargetManager(): void;
  22129. /** @hidden */
  22130. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22131. /**
  22132. * Returns a new Mesh object parsed from the source provided.
  22133. * @param parsedMesh is the source
  22134. * @param scene defines the hosting scene
  22135. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22136. * @returns a new Mesh
  22137. */
  22138. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22139. /**
  22140. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22141. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22142. * @param name defines the name of the mesh to create
  22143. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22144. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22145. * @param closePath creates a seam between the first and the last points of each path of the path array
  22146. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  22151. * @returns a new Mesh
  22152. */
  22153. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22154. /**
  22155. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22156. * @param name defines the name of the mesh to create
  22157. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22158. * @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
  22159. * @param scene defines the hosting scene
  22160. * @param updatable defines if the mesh must be flagged as updatable
  22161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22162. * @returns a new Mesh
  22163. */
  22164. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22165. /**
  22166. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22167. * @param name defines the name of the mesh to create
  22168. * @param size sets the size (float) of each box side (default 1)
  22169. * @param scene defines the hosting scene
  22170. * @param updatable defines if the mesh must be flagged as updatable
  22171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22172. * @returns a new Mesh
  22173. */
  22174. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22175. /**
  22176. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22177. * @param name defines the name of the mesh to create
  22178. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22179. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22180. * @param scene defines the hosting scene
  22181. * @param updatable defines if the mesh must be flagged as updatable
  22182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22183. * @returns a new Mesh
  22184. */
  22185. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22186. /**
  22187. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22188. * @param name defines the name of the mesh to create
  22189. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22190. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22191. * @param scene defines the hosting scene
  22192. * @returns a new Mesh
  22193. */
  22194. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22195. /**
  22196. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22197. * @param name defines the name of the mesh to create
  22198. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22199. * @param diameterTop set the top cap diameter (floats, default 1)
  22200. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22201. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22202. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22203. * @param scene defines the hosting scene
  22204. * @param updatable defines if the mesh must be flagged as updatable
  22205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22206. * @returns a new Mesh
  22207. */
  22208. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22209. /**
  22210. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22211. * @param name defines the name of the mesh to create
  22212. * @param diameter sets the diameter size (float) of the torus (default 1)
  22213. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22214. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22215. * @param scene defines the hosting scene
  22216. * @param updatable defines if the mesh must be flagged as updatable
  22217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22218. * @returns a new Mesh
  22219. */
  22220. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22221. /**
  22222. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22223. * @param name defines the name of the mesh to create
  22224. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22225. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22226. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22227. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22228. * @param p the number of windings on X axis (positive integers, default 2)
  22229. * @param q the number of windings on Y axis (positive integers, default 3)
  22230. * @param scene defines the hosting scene
  22231. * @param updatable defines if the mesh must be flagged as updatable
  22232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22233. * @returns a new Mesh
  22234. */
  22235. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22236. /**
  22237. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22238. * @param name defines the name of the mesh to create
  22239. * @param points is an array successive Vector3
  22240. * @param scene defines the hosting scene
  22241. * @param updatable defines if the mesh must be flagged as updatable
  22242. * @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).
  22243. * @returns a new Mesh
  22244. */
  22245. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22246. /**
  22247. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22248. * @param name defines the name of the mesh to create
  22249. * @param points is an array successive Vector3
  22250. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22251. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22252. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22253. * @param scene defines the hosting scene
  22254. * @param updatable defines if the mesh must be flagged as updatable
  22255. * @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)
  22256. * @returns a new Mesh
  22257. */
  22258. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22259. /**
  22260. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22261. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22262. * 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.
  22263. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22264. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22265. * Remember you can only change the shape positions, not their number when updating a polygon.
  22266. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22267. * @param name defines the name of the mesh to create
  22268. * @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
  22269. * @param scene defines the hosting scene
  22270. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22271. * @param updatable defines if the mesh must be flagged as updatable
  22272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22273. * @param earcutInjection can be used to inject your own earcut reference
  22274. * @returns a new Mesh
  22275. */
  22276. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22277. /**
  22278. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22279. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22280. * @param name defines the name of the mesh to create
  22281. * @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
  22282. * @param depth defines the height of extrusion
  22283. * @param scene defines the hosting scene
  22284. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22285. * @param updatable defines if the mesh must be flagged as updatable
  22286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22287. * @param earcutInjection can be used to inject your own earcut reference
  22288. * @returns a new Mesh
  22289. */
  22290. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22291. /**
  22292. * Creates an extruded shape mesh.
  22293. * 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
  22294. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22295. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22296. * @param name defines the name of the mesh to create
  22297. * @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
  22298. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22299. * @param scale is the value to scale the shape
  22300. * @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
  22301. * @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
  22302. * @param scene defines the hosting scene
  22303. * @param updatable defines if the mesh must be flagged as updatable
  22304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22305. * @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)
  22306. * @returns a new Mesh
  22307. */
  22308. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22309. /**
  22310. * Creates an custom extruded shape mesh.
  22311. * The custom extrusion is a parametric shape.
  22312. * It has no predefined shape. Its final shape will depend on the input parameters.
  22313. * Please consider using the same method from the MeshBuilder class instead
  22314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22315. * @param name defines the name of the mesh to create
  22316. * @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
  22317. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22318. * @param scaleFunction is a custom Javascript function called on each path point
  22319. * @param rotationFunction is a custom Javascript function called on each path point
  22320. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22321. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22322. * @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
  22323. * @param scene defines the hosting scene
  22324. * @param updatable defines if the mesh must be flagged as updatable
  22325. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22326. * @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)
  22327. * @returns a new Mesh
  22328. */
  22329. 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;
  22330. /**
  22331. * Creates lathe mesh.
  22332. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22333. * Please consider using the same method from the MeshBuilder class instead
  22334. * @param name defines the name of the mesh to create
  22335. * @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
  22336. * @param radius is the radius value of the lathe
  22337. * @param tessellation is the side number of the lathe.
  22338. * @param scene defines the hosting scene
  22339. * @param updatable defines if the mesh must be flagged as updatable
  22340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22341. * @returns a new Mesh
  22342. */
  22343. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22344. /**
  22345. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22346. * @param name defines the name of the mesh to create
  22347. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22348. * @param scene defines the hosting scene
  22349. * @param updatable defines if the mesh must be flagged as updatable
  22350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22351. * @returns a new Mesh
  22352. */
  22353. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22354. /**
  22355. * Creates a ground mesh.
  22356. * Please consider using the same method from the MeshBuilder class instead
  22357. * @param name defines the name of the mesh to create
  22358. * @param width set the width of the ground
  22359. * @param height set the height of the ground
  22360. * @param subdivisions sets the number of subdivisions per side
  22361. * @param scene defines the hosting scene
  22362. * @param updatable defines if the mesh must be flagged as updatable
  22363. * @returns a new Mesh
  22364. */
  22365. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22366. /**
  22367. * Creates a tiled ground mesh.
  22368. * Please consider using the same method from the MeshBuilder class instead
  22369. * @param name defines the name of the mesh to create
  22370. * @param xmin set the ground minimum X coordinate
  22371. * @param zmin set the ground minimum Y coordinate
  22372. * @param xmax set the ground maximum X coordinate
  22373. * @param zmax set the ground maximum Z coordinate
  22374. * @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
  22375. * @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
  22376. * @param scene defines the hosting scene
  22377. * @param updatable defines if the mesh must be flagged as updatable
  22378. * @returns a new Mesh
  22379. */
  22380. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22381. w: number;
  22382. h: number;
  22383. }, precision: {
  22384. w: number;
  22385. h: number;
  22386. }, scene: Scene, updatable?: boolean): Mesh;
  22387. /**
  22388. * Creates a ground mesh from a height map.
  22389. * Please consider using the same method from the MeshBuilder class instead
  22390. * @see http://doc.babylonjs.com/babylon101/height_map
  22391. * @param name defines the name of the mesh to create
  22392. * @param url sets the URL of the height map image resource
  22393. * @param width set the ground width size
  22394. * @param height set the ground height size
  22395. * @param subdivisions sets the number of subdivision per side
  22396. * @param minHeight is the minimum altitude on the ground
  22397. * @param maxHeight is the maximum altitude on the ground
  22398. * @param scene defines the hosting scene
  22399. * @param updatable defines if the mesh must be flagged as updatable
  22400. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22401. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22402. * @returns a new Mesh
  22403. */
  22404. 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;
  22405. /**
  22406. * Creates a tube mesh.
  22407. * The tube is a parametric shape.
  22408. * It has no predefined shape. Its final shape will depend on the input parameters.
  22409. * Please consider using the same method from the MeshBuilder class instead
  22410. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22411. * @param name defines the name of the mesh to create
  22412. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22413. * @param radius sets the tube radius size
  22414. * @param tessellation is the number of sides on the tubular surface
  22415. * @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
  22416. * @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
  22417. * @param scene defines the hosting scene
  22418. * @param updatable defines if the mesh must be flagged as updatable
  22419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22420. * @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)
  22421. * @returns a new Mesh
  22422. */
  22423. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22424. (i: number, distance: number): number;
  22425. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22426. /**
  22427. * Creates a polyhedron mesh.
  22428. * Please consider using the same method from the MeshBuilder class instead.
  22429. * * 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
  22430. * * The parameter `size` (positive float, default 1) sets the polygon size
  22431. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22432. * * 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`
  22433. * * 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
  22434. * * 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)`)
  22435. * * 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
  22436. * * 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
  22437. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22438. * * If you create a double-sided mesh, you can choose what parts of 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
  22439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22440. * @param name defines the name of the mesh to create
  22441. * @param options defines the options used to create the mesh
  22442. * @param scene defines the hosting scene
  22443. * @returns a new Mesh
  22444. */
  22445. static CreatePolyhedron(name: string, options: {
  22446. type?: number;
  22447. size?: number;
  22448. sizeX?: number;
  22449. sizeY?: number;
  22450. sizeZ?: number;
  22451. custom?: any;
  22452. faceUV?: Vector4[];
  22453. faceColors?: Color4[];
  22454. updatable?: boolean;
  22455. sideOrientation?: number;
  22456. }, scene: Scene): Mesh;
  22457. /**
  22458. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22459. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22460. * * 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`)
  22461. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22462. * * 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
  22463. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22464. * * If you create a double-sided mesh, you can choose what parts of 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
  22465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22466. * @param name defines the name of the mesh
  22467. * @param options defines the options used to create the mesh
  22468. * @param scene defines the hosting scene
  22469. * @returns a new Mesh
  22470. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22471. */
  22472. static CreateIcoSphere(name: string, options: {
  22473. radius?: number;
  22474. flat?: boolean;
  22475. subdivisions?: number;
  22476. sideOrientation?: number;
  22477. updatable?: boolean;
  22478. }, scene: Scene): Mesh;
  22479. /**
  22480. * Creates a decal mesh.
  22481. * Please consider using the same method from the MeshBuilder class instead.
  22482. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22483. * @param name defines the name of the mesh
  22484. * @param sourceMesh defines the mesh receiving the decal
  22485. * @param position sets the position of the decal in world coordinates
  22486. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22487. * @param size sets the decal scaling
  22488. * @param angle sets the angle to rotate the decal
  22489. * @returns a new Mesh
  22490. */
  22491. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22492. /**
  22493. * Prepare internal position array for software CPU skinning
  22494. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22495. */
  22496. setPositionsForCPUSkinning(): Float32Array;
  22497. /**
  22498. * Prepare internal normal array for software CPU skinning
  22499. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22500. */
  22501. setNormalsForCPUSkinning(): Float32Array;
  22502. /**
  22503. * Updates the vertex buffer by applying transformation from the bones
  22504. * @param skeleton defines the skeleton to apply to current mesh
  22505. * @returns the current mesh
  22506. */
  22507. applySkeleton(skeleton: Skeleton): Mesh;
  22508. /**
  22509. * 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
  22510. * @param meshes defines the list of meshes to scan
  22511. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22512. */
  22513. static MinMax(meshes: AbstractMesh[]): {
  22514. min: Vector3;
  22515. max: Vector3;
  22516. };
  22517. /**
  22518. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22519. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22520. * @returns a vector3
  22521. */
  22522. static Center(meshesOrMinMaxVector: {
  22523. min: Vector3;
  22524. max: Vector3;
  22525. } | AbstractMesh[]): Vector3;
  22526. /**
  22527. * Merge the array of meshes into a single mesh for performance reasons.
  22528. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22529. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22530. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22531. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22532. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22533. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22534. * @returns a new mesh
  22535. */
  22536. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22537. /** @hidden */
  22538. addInstance(instance: InstancedMesh): void;
  22539. /** @hidden */
  22540. removeInstance(instance: InstancedMesh): void;
  22541. }
  22542. }
  22543. declare module "babylonjs/Materials/material" {
  22544. import { IAnimatable } from "babylonjs/Misc/tools";
  22545. import { SmartArray } from "babylonjs/Misc/smartArray";
  22546. import { Observable } from "babylonjs/Misc/observable";
  22547. import { Nullable } from "babylonjs/types";
  22548. import { Scene } from "babylonjs/scene";
  22549. import { Matrix } from "babylonjs/Maths/math";
  22550. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22552. import { Mesh } from "babylonjs/Meshes/mesh";
  22553. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22554. import { Effect } from "babylonjs/Materials/effect";
  22555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22558. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22559. import { Animation } from "babylonjs/Animations/animation";
  22560. /**
  22561. * Base class for the main features of a material in Babylon.js
  22562. */
  22563. export class Material implements IAnimatable {
  22564. /**
  22565. * Returns the triangle fill mode
  22566. */
  22567. static readonly TriangleFillMode: number;
  22568. /**
  22569. * Returns the wireframe mode
  22570. */
  22571. static readonly WireFrameFillMode: number;
  22572. /**
  22573. * Returns the point fill mode
  22574. */
  22575. static readonly PointFillMode: number;
  22576. /**
  22577. * Returns the point list draw mode
  22578. */
  22579. static readonly PointListDrawMode: number;
  22580. /**
  22581. * Returns the line list draw mode
  22582. */
  22583. static readonly LineListDrawMode: number;
  22584. /**
  22585. * Returns the line loop draw mode
  22586. */
  22587. static readonly LineLoopDrawMode: number;
  22588. /**
  22589. * Returns the line strip draw mode
  22590. */
  22591. static readonly LineStripDrawMode: number;
  22592. /**
  22593. * Returns the triangle strip draw mode
  22594. */
  22595. static readonly TriangleStripDrawMode: number;
  22596. /**
  22597. * Returns the triangle fan draw mode
  22598. */
  22599. static readonly TriangleFanDrawMode: number;
  22600. /**
  22601. * Stores the clock-wise side orientation
  22602. */
  22603. static readonly ClockWiseSideOrientation: number;
  22604. /**
  22605. * Stores the counter clock-wise side orientation
  22606. */
  22607. static readonly CounterClockWiseSideOrientation: number;
  22608. /**
  22609. * The dirty texture flag value
  22610. */
  22611. static readonly TextureDirtyFlag: number;
  22612. /**
  22613. * The dirty light flag value
  22614. */
  22615. static readonly LightDirtyFlag: number;
  22616. /**
  22617. * The dirty fresnel flag value
  22618. */
  22619. static readonly FresnelDirtyFlag: number;
  22620. /**
  22621. * The dirty attribute flag value
  22622. */
  22623. static readonly AttributesDirtyFlag: number;
  22624. /**
  22625. * The dirty misc flag value
  22626. */
  22627. static readonly MiscDirtyFlag: number;
  22628. /**
  22629. * The all dirty flag value
  22630. */
  22631. static readonly AllDirtyFlag: number;
  22632. /**
  22633. * The ID of the material
  22634. */
  22635. id: string;
  22636. /**
  22637. * Gets or sets the unique id of the material
  22638. */
  22639. uniqueId: number;
  22640. /**
  22641. * The name of the material
  22642. */
  22643. name: string;
  22644. /**
  22645. * Gets or sets user defined metadata
  22646. */
  22647. metadata: any;
  22648. /**
  22649. * For internal use only. Please do not use.
  22650. */
  22651. reservedDataStore: any;
  22652. /**
  22653. * Specifies if the ready state should be checked on each call
  22654. */
  22655. checkReadyOnEveryCall: boolean;
  22656. /**
  22657. * Specifies if the ready state should be checked once
  22658. */
  22659. checkReadyOnlyOnce: boolean;
  22660. /**
  22661. * The state of the material
  22662. */
  22663. state: string;
  22664. /**
  22665. * The alpha value of the material
  22666. */
  22667. protected _alpha: number;
  22668. /**
  22669. * List of inspectable custom properties (used by the Inspector)
  22670. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22671. */
  22672. inspectableCustomProperties: IInspectable[];
  22673. /**
  22674. * Sets the alpha value of the material
  22675. */
  22676. /**
  22677. * Gets the alpha value of the material
  22678. */
  22679. alpha: number;
  22680. /**
  22681. * Specifies if back face culling is enabled
  22682. */
  22683. protected _backFaceCulling: boolean;
  22684. /**
  22685. * Sets the back-face culling state
  22686. */
  22687. /**
  22688. * Gets the back-face culling state
  22689. */
  22690. backFaceCulling: boolean;
  22691. /**
  22692. * Stores the value for side orientation
  22693. */
  22694. sideOrientation: number;
  22695. /**
  22696. * Callback triggered when the material is compiled
  22697. */
  22698. onCompiled: Nullable<(effect: Effect) => void>;
  22699. /**
  22700. * Callback triggered when an error occurs
  22701. */
  22702. onError: Nullable<(effect: Effect, errors: string) => void>;
  22703. /**
  22704. * Callback triggered to get the render target textures
  22705. */
  22706. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22707. /**
  22708. * Gets a boolean indicating that current material needs to register RTT
  22709. */
  22710. readonly hasRenderTargetTextures: boolean;
  22711. /**
  22712. * Specifies if the material should be serialized
  22713. */
  22714. doNotSerialize: boolean;
  22715. /**
  22716. * @hidden
  22717. */
  22718. _storeEffectOnSubMeshes: boolean;
  22719. /**
  22720. * Stores the animations for the material
  22721. */
  22722. animations: Nullable<Array<Animation>>;
  22723. /**
  22724. * An event triggered when the material is disposed
  22725. */
  22726. onDisposeObservable: Observable<Material>;
  22727. /**
  22728. * An observer which watches for dispose events
  22729. */
  22730. private _onDisposeObserver;
  22731. private _onUnBindObservable;
  22732. /**
  22733. * Called during a dispose event
  22734. */
  22735. onDispose: () => void;
  22736. private _onBindObservable;
  22737. /**
  22738. * An event triggered when the material is bound
  22739. */
  22740. readonly onBindObservable: Observable<AbstractMesh>;
  22741. /**
  22742. * An observer which watches for bind events
  22743. */
  22744. private _onBindObserver;
  22745. /**
  22746. * Called during a bind event
  22747. */
  22748. onBind: (Mesh: AbstractMesh) => void;
  22749. /**
  22750. * An event triggered when the material is unbound
  22751. */
  22752. readonly onUnBindObservable: Observable<Material>;
  22753. /**
  22754. * Stores the value of the alpha mode
  22755. */
  22756. private _alphaMode;
  22757. /**
  22758. * Sets the value of the alpha mode.
  22759. *
  22760. * | Value | Type | Description |
  22761. * | --- | --- | --- |
  22762. * | 0 | ALPHA_DISABLE | |
  22763. * | 1 | ALPHA_ADD | |
  22764. * | 2 | ALPHA_COMBINE | |
  22765. * | 3 | ALPHA_SUBTRACT | |
  22766. * | 4 | ALPHA_MULTIPLY | |
  22767. * | 5 | ALPHA_MAXIMIZED | |
  22768. * | 6 | ALPHA_ONEONE | |
  22769. * | 7 | ALPHA_PREMULTIPLIED | |
  22770. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22771. * | 9 | ALPHA_INTERPOLATE | |
  22772. * | 10 | ALPHA_SCREENMODE | |
  22773. *
  22774. */
  22775. /**
  22776. * Gets the value of the alpha mode
  22777. */
  22778. alphaMode: number;
  22779. /**
  22780. * Stores the state of the need depth pre-pass value
  22781. */
  22782. private _needDepthPrePass;
  22783. /**
  22784. * Sets the need depth pre-pass value
  22785. */
  22786. /**
  22787. * Gets the depth pre-pass value
  22788. */
  22789. needDepthPrePass: boolean;
  22790. /**
  22791. * Specifies if depth writing should be disabled
  22792. */
  22793. disableDepthWrite: boolean;
  22794. /**
  22795. * Specifies if depth writing should be forced
  22796. */
  22797. forceDepthWrite: boolean;
  22798. /**
  22799. * Specifies if there should be a separate pass for culling
  22800. */
  22801. separateCullingPass: boolean;
  22802. /**
  22803. * Stores the state specifing if fog should be enabled
  22804. */
  22805. private _fogEnabled;
  22806. /**
  22807. * Sets the state for enabling fog
  22808. */
  22809. /**
  22810. * Gets the value of the fog enabled state
  22811. */
  22812. fogEnabled: boolean;
  22813. /**
  22814. * Stores the size of points
  22815. */
  22816. pointSize: number;
  22817. /**
  22818. * Stores the z offset value
  22819. */
  22820. zOffset: number;
  22821. /**
  22822. * Gets a value specifying if wireframe mode is enabled
  22823. */
  22824. /**
  22825. * Sets the state of wireframe mode
  22826. */
  22827. wireframe: boolean;
  22828. /**
  22829. * Gets the value specifying if point clouds are enabled
  22830. */
  22831. /**
  22832. * Sets the state of point cloud mode
  22833. */
  22834. pointsCloud: boolean;
  22835. /**
  22836. * Gets the material fill mode
  22837. */
  22838. /**
  22839. * Sets the material fill mode
  22840. */
  22841. fillMode: number;
  22842. /**
  22843. * @hidden
  22844. * Stores the effects for the material
  22845. */
  22846. _effect: Nullable<Effect>;
  22847. /**
  22848. * @hidden
  22849. * Specifies if the material was previously ready
  22850. */
  22851. _wasPreviouslyReady: boolean;
  22852. /**
  22853. * Specifies if uniform buffers should be used
  22854. */
  22855. private _useUBO;
  22856. /**
  22857. * Stores a reference to the scene
  22858. */
  22859. private _scene;
  22860. /**
  22861. * Stores the fill mode state
  22862. */
  22863. private _fillMode;
  22864. /**
  22865. * Specifies if the depth write state should be cached
  22866. */
  22867. private _cachedDepthWriteState;
  22868. /**
  22869. * Stores the uniform buffer
  22870. */
  22871. protected _uniformBuffer: UniformBuffer;
  22872. /** @hidden */
  22873. _indexInSceneMaterialArray: number;
  22874. /** @hidden */
  22875. meshMap: Nullable<{
  22876. [id: string]: AbstractMesh | undefined;
  22877. }>;
  22878. /**
  22879. * Creates a material instance
  22880. * @param name defines the name of the material
  22881. * @param scene defines the scene to reference
  22882. * @param doNotAdd specifies if the material should be added to the scene
  22883. */
  22884. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22885. /**
  22886. * Returns a string representation of the current material
  22887. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22888. * @returns a string with material information
  22889. */
  22890. toString(fullDetails?: boolean): string;
  22891. /**
  22892. * Gets the class name of the material
  22893. * @returns a string with the class name of the material
  22894. */
  22895. getClassName(): string;
  22896. /**
  22897. * Specifies if updates for the material been locked
  22898. */
  22899. readonly isFrozen: boolean;
  22900. /**
  22901. * Locks updates for the material
  22902. */
  22903. freeze(): void;
  22904. /**
  22905. * Unlocks updates for the material
  22906. */
  22907. unfreeze(): void;
  22908. /**
  22909. * Specifies if the material is ready to be used
  22910. * @param mesh defines the mesh to check
  22911. * @param useInstances specifies if instances should be used
  22912. * @returns a boolean indicating if the material is ready to be used
  22913. */
  22914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22915. /**
  22916. * Specifies that the submesh is ready to be used
  22917. * @param mesh defines the mesh to check
  22918. * @param subMesh defines which submesh to check
  22919. * @param useInstances specifies that instances should be used
  22920. * @returns a boolean indicating that the submesh is ready or not
  22921. */
  22922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22923. /**
  22924. * Returns the material effect
  22925. * @returns the effect associated with the material
  22926. */
  22927. getEffect(): Nullable<Effect>;
  22928. /**
  22929. * Returns the current scene
  22930. * @returns a Scene
  22931. */
  22932. getScene(): Scene;
  22933. /**
  22934. * Specifies if the material will require alpha blending
  22935. * @returns a boolean specifying if alpha blending is needed
  22936. */
  22937. needAlphaBlending(): boolean;
  22938. /**
  22939. * Specifies if the mesh will require alpha blending
  22940. * @param mesh defines the mesh to check
  22941. * @returns a boolean specifying if alpha blending is needed for the mesh
  22942. */
  22943. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22944. /**
  22945. * Specifies if this material should be rendered in alpha test mode
  22946. * @returns a boolean specifying if an alpha test is needed.
  22947. */
  22948. needAlphaTesting(): boolean;
  22949. /**
  22950. * Gets the texture used for the alpha test
  22951. * @returns the texture to use for alpha testing
  22952. */
  22953. getAlphaTestTexture(): Nullable<BaseTexture>;
  22954. /**
  22955. * Marks the material to indicate that it needs to be re-calculated
  22956. */
  22957. markDirty(): void;
  22958. /** @hidden */
  22959. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22960. /**
  22961. * Binds the material to the mesh
  22962. * @param world defines the world transformation matrix
  22963. * @param mesh defines the mesh to bind the material to
  22964. */
  22965. bind(world: Matrix, mesh?: Mesh): void;
  22966. /**
  22967. * Binds the submesh to the material
  22968. * @param world defines the world transformation matrix
  22969. * @param mesh defines the mesh containing the submesh
  22970. * @param subMesh defines the submesh to bind the material to
  22971. */
  22972. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22973. /**
  22974. * Binds the world matrix to the material
  22975. * @param world defines the world transformation matrix
  22976. */
  22977. bindOnlyWorldMatrix(world: Matrix): void;
  22978. /**
  22979. * Binds the scene's uniform buffer to the effect.
  22980. * @param effect defines the effect to bind to the scene uniform buffer
  22981. * @param sceneUbo defines the uniform buffer storing scene data
  22982. */
  22983. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22984. /**
  22985. * Binds the view matrix to the effect
  22986. * @param effect defines the effect to bind the view matrix to
  22987. */
  22988. bindView(effect: Effect): void;
  22989. /**
  22990. * Binds the view projection matrix to the effect
  22991. * @param effect defines the effect to bind the view projection matrix to
  22992. */
  22993. bindViewProjection(effect: Effect): void;
  22994. /**
  22995. * Specifies if material alpha testing should be turned on for the mesh
  22996. * @param mesh defines the mesh to check
  22997. */
  22998. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22999. /**
  23000. * Processes to execute after binding the material to a mesh
  23001. * @param mesh defines the rendered mesh
  23002. */
  23003. protected _afterBind(mesh?: Mesh): void;
  23004. /**
  23005. * Unbinds the material from the mesh
  23006. */
  23007. unbind(): void;
  23008. /**
  23009. * Gets the active textures from the material
  23010. * @returns an array of textures
  23011. */
  23012. getActiveTextures(): BaseTexture[];
  23013. /**
  23014. * Specifies if the material uses a texture
  23015. * @param texture defines the texture to check against the material
  23016. * @returns a boolean specifying if the material uses the texture
  23017. */
  23018. hasTexture(texture: BaseTexture): boolean;
  23019. /**
  23020. * Makes a duplicate of the material, and gives it a new name
  23021. * @param name defines the new name for the duplicated material
  23022. * @returns the cloned material
  23023. */
  23024. clone(name: string): Nullable<Material>;
  23025. /**
  23026. * Gets the meshes bound to the material
  23027. * @returns an array of meshes bound to the material
  23028. */
  23029. getBindedMeshes(): AbstractMesh[];
  23030. /**
  23031. * Force shader compilation
  23032. * @param mesh defines the mesh associated with this material
  23033. * @param onCompiled defines a function to execute once the material is compiled
  23034. * @param options defines the options to configure the compilation
  23035. */
  23036. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23037. clipPlane: boolean;
  23038. }>): void;
  23039. /**
  23040. * Force shader compilation
  23041. * @param mesh defines the mesh that will use this material
  23042. * @param options defines additional options for compiling the shaders
  23043. * @returns a promise that resolves when the compilation completes
  23044. */
  23045. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23046. clipPlane: boolean;
  23047. }>): Promise<void>;
  23048. private static readonly _ImageProcessingDirtyCallBack;
  23049. private static readonly _TextureDirtyCallBack;
  23050. private static readonly _FresnelDirtyCallBack;
  23051. private static readonly _MiscDirtyCallBack;
  23052. private static readonly _LightsDirtyCallBack;
  23053. private static readonly _AttributeDirtyCallBack;
  23054. private static _FresnelAndMiscDirtyCallBack;
  23055. private static _TextureAndMiscDirtyCallBack;
  23056. private static readonly _DirtyCallbackArray;
  23057. private static readonly _RunDirtyCallBacks;
  23058. /**
  23059. * Marks a define in the material to indicate that it needs to be re-computed
  23060. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23061. */
  23062. markAsDirty(flag: number): void;
  23063. /**
  23064. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23065. * @param func defines a function which checks material defines against the submeshes
  23066. */
  23067. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23068. /**
  23069. * Indicates that image processing needs to be re-calculated for all submeshes
  23070. */
  23071. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23072. /**
  23073. * Indicates that textures need to be re-calculated for all submeshes
  23074. */
  23075. protected _markAllSubMeshesAsTexturesDirty(): void;
  23076. /**
  23077. * Indicates that fresnel needs to be re-calculated for all submeshes
  23078. */
  23079. protected _markAllSubMeshesAsFresnelDirty(): void;
  23080. /**
  23081. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23082. */
  23083. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23084. /**
  23085. * Indicates that lights need to be re-calculated for all submeshes
  23086. */
  23087. protected _markAllSubMeshesAsLightsDirty(): void;
  23088. /**
  23089. * Indicates that attributes need to be re-calculated for all submeshes
  23090. */
  23091. protected _markAllSubMeshesAsAttributesDirty(): void;
  23092. /**
  23093. * Indicates that misc needs to be re-calculated for all submeshes
  23094. */
  23095. protected _markAllSubMeshesAsMiscDirty(): void;
  23096. /**
  23097. * Indicates that textures and misc need to be re-calculated for all submeshes
  23098. */
  23099. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23100. /**
  23101. * Disposes the material
  23102. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23103. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23104. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23105. */
  23106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23107. /** @hidden */
  23108. private releaseVertexArrayObject;
  23109. /**
  23110. * Serializes this material
  23111. * @returns the serialized material object
  23112. */
  23113. serialize(): any;
  23114. /**
  23115. * Creates a material from parsed material data
  23116. * @param parsedMaterial defines parsed material data
  23117. * @param scene defines the hosting scene
  23118. * @param rootUrl defines the root URL to use to load textures
  23119. * @returns a new material
  23120. */
  23121. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23122. }
  23123. }
  23124. declare module "babylonjs/Meshes/subMesh" {
  23125. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23126. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23127. import { Engine } from "babylonjs/Engines/engine";
  23128. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23129. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23130. import { Effect } from "babylonjs/Materials/effect";
  23131. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23132. import { Collider } from "babylonjs/Collisions/collider";
  23133. import { Material } from "babylonjs/Materials/material";
  23134. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23136. import { Mesh } from "babylonjs/Meshes/mesh";
  23137. import { Ray } from "babylonjs/Culling/ray";
  23138. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23139. /**
  23140. * Base class for submeshes
  23141. */
  23142. export class BaseSubMesh {
  23143. /** @hidden */
  23144. _materialDefines: Nullable<MaterialDefines>;
  23145. /** @hidden */
  23146. _materialEffect: Nullable<Effect>;
  23147. /**
  23148. * Gets associated effect
  23149. */
  23150. readonly effect: Nullable<Effect>;
  23151. /**
  23152. * Sets associated effect (effect used to render this submesh)
  23153. * @param effect defines the effect to associate with
  23154. * @param defines defines the set of defines used to compile this effect
  23155. */
  23156. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23157. }
  23158. /**
  23159. * Defines a subdivision inside a mesh
  23160. */
  23161. export class SubMesh extends BaseSubMesh implements ICullable {
  23162. /** the material index to use */
  23163. materialIndex: number;
  23164. /** vertex index start */
  23165. verticesStart: number;
  23166. /** vertices count */
  23167. verticesCount: number;
  23168. /** index start */
  23169. indexStart: number;
  23170. /** indices count */
  23171. indexCount: number;
  23172. /** @hidden */
  23173. _linesIndexCount: number;
  23174. private _mesh;
  23175. private _renderingMesh;
  23176. private _boundingInfo;
  23177. private _linesIndexBuffer;
  23178. /** @hidden */
  23179. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23180. /** @hidden */
  23181. _trianglePlanes: Plane[];
  23182. /** @hidden */
  23183. _lastColliderTransformMatrix: Nullable<Matrix>;
  23184. /** @hidden */
  23185. _renderId: number;
  23186. /** @hidden */
  23187. _alphaIndex: number;
  23188. /** @hidden */
  23189. _distanceToCamera: number;
  23190. /** @hidden */
  23191. _id: number;
  23192. private _currentMaterial;
  23193. /**
  23194. * Add a new submesh to a mesh
  23195. * @param materialIndex defines the material index to use
  23196. * @param verticesStart defines vertex index start
  23197. * @param verticesCount defines vertices count
  23198. * @param indexStart defines index start
  23199. * @param indexCount defines indices count
  23200. * @param mesh defines the parent mesh
  23201. * @param renderingMesh defines an optional rendering mesh
  23202. * @param createBoundingBox defines if bounding box should be created for this submesh
  23203. * @returns the new submesh
  23204. */
  23205. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23206. /**
  23207. * Creates a new submesh
  23208. * @param materialIndex defines the material index to use
  23209. * @param verticesStart defines vertex index start
  23210. * @param verticesCount defines vertices count
  23211. * @param indexStart defines index start
  23212. * @param indexCount defines indices count
  23213. * @param mesh defines the parent mesh
  23214. * @param renderingMesh defines an optional rendering mesh
  23215. * @param createBoundingBox defines if bounding box should be created for this submesh
  23216. */
  23217. constructor(
  23218. /** the material index to use */
  23219. materialIndex: number,
  23220. /** vertex index start */
  23221. verticesStart: number,
  23222. /** vertices count */
  23223. verticesCount: number,
  23224. /** index start */
  23225. indexStart: number,
  23226. /** indices count */
  23227. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23228. /**
  23229. * Returns true if this submesh covers the entire parent mesh
  23230. * @ignorenaming
  23231. */
  23232. readonly IsGlobal: boolean;
  23233. /**
  23234. * Returns the submesh BoudingInfo object
  23235. * @returns current bounding info (or mesh's one if the submesh is global)
  23236. */
  23237. getBoundingInfo(): BoundingInfo;
  23238. /**
  23239. * Sets the submesh BoundingInfo
  23240. * @param boundingInfo defines the new bounding info to use
  23241. * @returns the SubMesh
  23242. */
  23243. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23244. /**
  23245. * Returns the mesh of the current submesh
  23246. * @return the parent mesh
  23247. */
  23248. getMesh(): AbstractMesh;
  23249. /**
  23250. * Returns the rendering mesh of the submesh
  23251. * @returns the rendering mesh (could be different from parent mesh)
  23252. */
  23253. getRenderingMesh(): Mesh;
  23254. /**
  23255. * Returns the submesh material
  23256. * @returns null or the current material
  23257. */
  23258. getMaterial(): Nullable<Material>;
  23259. /**
  23260. * Sets a new updated BoundingInfo object to the submesh
  23261. * @param data defines an optional position array to use to determine the bounding info
  23262. * @returns the SubMesh
  23263. */
  23264. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23265. /** @hidden */
  23266. _checkCollision(collider: Collider): boolean;
  23267. /**
  23268. * Updates the submesh BoundingInfo
  23269. * @param world defines the world matrix to use to update the bounding info
  23270. * @returns the submesh
  23271. */
  23272. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23273. /**
  23274. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23275. * @param frustumPlanes defines the frustum planes
  23276. * @returns true if the submesh is intersecting with the frustum
  23277. */
  23278. isInFrustum(frustumPlanes: Plane[]): boolean;
  23279. /**
  23280. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23281. * @param frustumPlanes defines the frustum planes
  23282. * @returns true if the submesh is inside the frustum
  23283. */
  23284. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23285. /**
  23286. * Renders the submesh
  23287. * @param enableAlphaMode defines if alpha needs to be used
  23288. * @returns the submesh
  23289. */
  23290. render(enableAlphaMode: boolean): SubMesh;
  23291. /**
  23292. * @hidden
  23293. */
  23294. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23295. /**
  23296. * Checks if the submesh intersects with a ray
  23297. * @param ray defines the ray to test
  23298. * @returns true is the passed ray intersects the submesh bounding box
  23299. */
  23300. canIntersects(ray: Ray): boolean;
  23301. /**
  23302. * Intersects current submesh with a ray
  23303. * @param ray defines the ray to test
  23304. * @param positions defines mesh's positions array
  23305. * @param indices defines mesh's indices array
  23306. * @param fastCheck defines if only bounding info should be used
  23307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23308. * @returns intersection info or null if no intersection
  23309. */
  23310. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23311. /** @hidden */
  23312. private _intersectLines;
  23313. /** @hidden */
  23314. private _intersectTriangles;
  23315. /** @hidden */
  23316. _rebuild(): void;
  23317. /**
  23318. * Creates a new submesh from the passed mesh
  23319. * @param newMesh defines the new hosting mesh
  23320. * @param newRenderingMesh defines an optional rendering mesh
  23321. * @returns the new submesh
  23322. */
  23323. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23324. /**
  23325. * Release associated resources
  23326. */
  23327. dispose(): void;
  23328. /**
  23329. * Gets the class name
  23330. * @returns the string "SubMesh".
  23331. */
  23332. getClassName(): string;
  23333. /**
  23334. * Creates a new submesh from indices data
  23335. * @param materialIndex the index of the main mesh material
  23336. * @param startIndex the index where to start the copy in the mesh indices array
  23337. * @param indexCount the number of indices to copy then from the startIndex
  23338. * @param mesh the main mesh to create the submesh from
  23339. * @param renderingMesh the optional rendering mesh
  23340. * @returns a new submesh
  23341. */
  23342. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23343. }
  23344. }
  23345. declare module "babylonjs/Meshes/geometry" {
  23346. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23347. import { Scene } from "babylonjs/scene";
  23348. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23349. import { Engine } from "babylonjs/Engines/engine";
  23350. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23351. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23352. import { Effect } from "babylonjs/Materials/effect";
  23353. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23354. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23355. import { Mesh } from "babylonjs/Meshes/mesh";
  23356. /**
  23357. * Class used to store geometry data (vertex buffers + index buffer)
  23358. */
  23359. export class Geometry implements IGetSetVerticesData {
  23360. /**
  23361. * Gets or sets the ID of the geometry
  23362. */
  23363. id: string;
  23364. /**
  23365. * Gets or sets the unique ID of the geometry
  23366. */
  23367. uniqueId: number;
  23368. /**
  23369. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23370. */
  23371. delayLoadState: number;
  23372. /**
  23373. * Gets the file containing the data to load when running in delay load state
  23374. */
  23375. delayLoadingFile: Nullable<string>;
  23376. /**
  23377. * Callback called when the geometry is updated
  23378. */
  23379. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23380. private _scene;
  23381. private _engine;
  23382. private _meshes;
  23383. private _totalVertices;
  23384. /** @hidden */
  23385. _indices: IndicesArray;
  23386. /** @hidden */
  23387. _vertexBuffers: {
  23388. [key: string]: VertexBuffer;
  23389. };
  23390. private _isDisposed;
  23391. private _extend;
  23392. private _boundingBias;
  23393. /** @hidden */
  23394. _delayInfo: Array<string>;
  23395. private _indexBuffer;
  23396. private _indexBufferIsUpdatable;
  23397. /** @hidden */
  23398. _boundingInfo: Nullable<BoundingInfo>;
  23399. /** @hidden */
  23400. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23401. /** @hidden */
  23402. _softwareSkinningFrameId: number;
  23403. private _vertexArrayObjects;
  23404. private _updatable;
  23405. /** @hidden */
  23406. _positions: Nullable<Vector3[]>;
  23407. /**
  23408. * 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
  23409. */
  23410. /**
  23411. * 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
  23412. */
  23413. boundingBias: Vector2;
  23414. /**
  23415. * Static function used to attach a new empty geometry to a mesh
  23416. * @param mesh defines the mesh to attach the geometry to
  23417. * @returns the new Geometry
  23418. */
  23419. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23420. /**
  23421. * Creates a new geometry
  23422. * @param id defines the unique ID
  23423. * @param scene defines the hosting scene
  23424. * @param vertexData defines the VertexData used to get geometry data
  23425. * @param updatable defines if geometry must be updatable (false by default)
  23426. * @param mesh defines the mesh that will be associated with the geometry
  23427. */
  23428. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23429. /**
  23430. * Gets the current extend of the geometry
  23431. */
  23432. readonly extend: {
  23433. minimum: Vector3;
  23434. maximum: Vector3;
  23435. };
  23436. /**
  23437. * Gets the hosting scene
  23438. * @returns the hosting Scene
  23439. */
  23440. getScene(): Scene;
  23441. /**
  23442. * Gets the hosting engine
  23443. * @returns the hosting Engine
  23444. */
  23445. getEngine(): Engine;
  23446. /**
  23447. * Defines if the geometry is ready to use
  23448. * @returns true if the geometry is ready to be used
  23449. */
  23450. isReady(): boolean;
  23451. /**
  23452. * Gets a value indicating that the geometry should not be serialized
  23453. */
  23454. readonly doNotSerialize: boolean;
  23455. /** @hidden */
  23456. _rebuild(): void;
  23457. /**
  23458. * Affects all geometry data in one call
  23459. * @param vertexData defines the geometry data
  23460. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23461. */
  23462. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23463. /**
  23464. * Set specific vertex data
  23465. * @param kind defines the data kind (Position, normal, etc...)
  23466. * @param data defines the vertex data to use
  23467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23469. */
  23470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23471. /**
  23472. * Removes a specific vertex data
  23473. * @param kind defines the data kind (Position, normal, etc...)
  23474. */
  23475. removeVerticesData(kind: string): void;
  23476. /**
  23477. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23478. * @param buffer defines the vertex buffer to use
  23479. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23480. */
  23481. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23482. /**
  23483. * Update a specific vertex buffer
  23484. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23485. * It will do nothing if the buffer is not updatable
  23486. * @param kind defines the data kind (Position, normal, etc...)
  23487. * @param data defines the data to use
  23488. * @param offset defines the offset in the target buffer where to store the data
  23489. * @param useBytes set to true if the offset is in bytes
  23490. */
  23491. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23492. /**
  23493. * Update a specific vertex buffer
  23494. * This function will create a new buffer if the current one is not updatable
  23495. * @param kind defines the data kind (Position, normal, etc...)
  23496. * @param data defines the data to use
  23497. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23498. */
  23499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23500. private _updateBoundingInfo;
  23501. /** @hidden */
  23502. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23503. /**
  23504. * Gets total number of vertices
  23505. * @returns the total number of vertices
  23506. */
  23507. getTotalVertices(): number;
  23508. /**
  23509. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23510. * @param kind defines the data kind (Position, normal, etc...)
  23511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23513. * @returns a float array containing vertex data
  23514. */
  23515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23516. /**
  23517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23518. * @param kind defines the data kind (Position, normal, etc...)
  23519. * @returns true if the vertex buffer with the specified kind is updatable
  23520. */
  23521. isVertexBufferUpdatable(kind: string): boolean;
  23522. /**
  23523. * Gets a specific vertex buffer
  23524. * @param kind defines the data kind (Position, normal, etc...)
  23525. * @returns a VertexBuffer
  23526. */
  23527. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23528. /**
  23529. * Returns all vertex buffers
  23530. * @return an object holding all vertex buffers indexed by kind
  23531. */
  23532. getVertexBuffers(): Nullable<{
  23533. [key: string]: VertexBuffer;
  23534. }>;
  23535. /**
  23536. * Gets a boolean indicating if specific vertex buffer is present
  23537. * @param kind defines the data kind (Position, normal, etc...)
  23538. * @returns true if data is present
  23539. */
  23540. isVerticesDataPresent(kind: string): boolean;
  23541. /**
  23542. * Gets a list of all attached data kinds (Position, normal, etc...)
  23543. * @returns a list of string containing all kinds
  23544. */
  23545. getVerticesDataKinds(): string[];
  23546. /**
  23547. * Update index buffer
  23548. * @param indices defines the indices to store in the index buffer
  23549. * @param offset defines the offset in the target buffer where to store the data
  23550. * @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)
  23551. */
  23552. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23553. /**
  23554. * Creates a new index buffer
  23555. * @param indices defines the indices to store in the index buffer
  23556. * @param totalVertices defines the total number of vertices (could be null)
  23557. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23558. */
  23559. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23560. /**
  23561. * Return the total number of indices
  23562. * @returns the total number of indices
  23563. */
  23564. getTotalIndices(): number;
  23565. /**
  23566. * Gets the index buffer array
  23567. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23568. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23569. * @returns the index buffer array
  23570. */
  23571. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23572. /**
  23573. * Gets the index buffer
  23574. * @return the index buffer
  23575. */
  23576. getIndexBuffer(): Nullable<DataBuffer>;
  23577. /** @hidden */
  23578. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23579. /**
  23580. * Release the associated resources for a specific mesh
  23581. * @param mesh defines the source mesh
  23582. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23583. */
  23584. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23585. /**
  23586. * Apply current geometry to a given mesh
  23587. * @param mesh defines the mesh to apply geometry to
  23588. */
  23589. applyToMesh(mesh: Mesh): void;
  23590. private _updateExtend;
  23591. private _applyToMesh;
  23592. private notifyUpdate;
  23593. /**
  23594. * Load the geometry if it was flagged as delay loaded
  23595. * @param scene defines the hosting scene
  23596. * @param onLoaded defines a callback called when the geometry is loaded
  23597. */
  23598. load(scene: Scene, onLoaded?: () => void): void;
  23599. private _queueLoad;
  23600. /**
  23601. * Invert the geometry to move from a right handed system to a left handed one.
  23602. */
  23603. toLeftHanded(): void;
  23604. /** @hidden */
  23605. _resetPointsArrayCache(): void;
  23606. /** @hidden */
  23607. _generatePointsArray(): boolean;
  23608. /**
  23609. * Gets a value indicating if the geometry is disposed
  23610. * @returns true if the geometry was disposed
  23611. */
  23612. isDisposed(): boolean;
  23613. private _disposeVertexArrayObjects;
  23614. /**
  23615. * Free all associated resources
  23616. */
  23617. dispose(): void;
  23618. /**
  23619. * Clone the current geometry into a new geometry
  23620. * @param id defines the unique ID of the new geometry
  23621. * @returns a new geometry object
  23622. */
  23623. copy(id: string): Geometry;
  23624. /**
  23625. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23626. * @return a JSON representation of the current geometry data (without the vertices data)
  23627. */
  23628. serialize(): any;
  23629. private toNumberArray;
  23630. /**
  23631. * Serialize all vertices data into a JSON oject
  23632. * @returns a JSON representation of the current geometry data
  23633. */
  23634. serializeVerticeData(): any;
  23635. /**
  23636. * Extracts a clone of a mesh geometry
  23637. * @param mesh defines the source mesh
  23638. * @param id defines the unique ID of the new geometry object
  23639. * @returns the new geometry object
  23640. */
  23641. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23642. /**
  23643. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23645. * Be aware Math.random() could cause collisions, but:
  23646. * "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"
  23647. * @returns a string containing a new GUID
  23648. */
  23649. static RandomId(): string;
  23650. /** @hidden */
  23651. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23652. private static _CleanMatricesWeights;
  23653. /**
  23654. * Create a new geometry from persisted data (Using .babylon file format)
  23655. * @param parsedVertexData defines the persisted data
  23656. * @param scene defines the hosting scene
  23657. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23658. * @returns the new geometry object
  23659. */
  23660. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23661. }
  23662. }
  23663. declare module "babylonjs/Meshes/mesh.vertexData" {
  23664. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23665. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23666. import { Geometry } from "babylonjs/Meshes/geometry";
  23667. import { Mesh } from "babylonjs/Meshes/mesh";
  23668. /**
  23669. * Define an interface for all classes that will get and set the data on vertices
  23670. */
  23671. export interface IGetSetVerticesData {
  23672. /**
  23673. * Gets a boolean indicating if specific vertex data is present
  23674. * @param kind defines the vertex data kind to use
  23675. * @returns true is data kind is present
  23676. */
  23677. isVerticesDataPresent(kind: string): boolean;
  23678. /**
  23679. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23680. * @param kind defines the data kind (Position, normal, etc...)
  23681. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23682. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23683. * @returns a float array containing vertex data
  23684. */
  23685. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23686. /**
  23687. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23688. * @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.
  23689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23690. * @returns the indices array or an empty array if the mesh has no geometry
  23691. */
  23692. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23693. /**
  23694. * Set specific vertex data
  23695. * @param kind defines the data kind (Position, normal, etc...)
  23696. * @param data defines the vertex data to use
  23697. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23698. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23699. */
  23700. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23701. /**
  23702. * Update a specific associated vertex buffer
  23703. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23704. * - VertexBuffer.PositionKind
  23705. * - VertexBuffer.UVKind
  23706. * - VertexBuffer.UV2Kind
  23707. * - VertexBuffer.UV3Kind
  23708. * - VertexBuffer.UV4Kind
  23709. * - VertexBuffer.UV5Kind
  23710. * - VertexBuffer.UV6Kind
  23711. * - VertexBuffer.ColorKind
  23712. * - VertexBuffer.MatricesIndicesKind
  23713. * - VertexBuffer.MatricesIndicesExtraKind
  23714. * - VertexBuffer.MatricesWeightsKind
  23715. * - VertexBuffer.MatricesWeightsExtraKind
  23716. * @param data defines the data source
  23717. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23718. * @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)
  23719. */
  23720. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23721. /**
  23722. * Creates a new index buffer
  23723. * @param indices defines the indices to store in the index buffer
  23724. * @param totalVertices defines the total number of vertices (could be null)
  23725. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23726. */
  23727. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23728. }
  23729. /**
  23730. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23731. */
  23732. export class VertexData {
  23733. /**
  23734. * Mesh side orientation : usually the external or front surface
  23735. */
  23736. static readonly FRONTSIDE: number;
  23737. /**
  23738. * Mesh side orientation : usually the internal or back surface
  23739. */
  23740. static readonly BACKSIDE: number;
  23741. /**
  23742. * Mesh side orientation : both internal and external or front and back surfaces
  23743. */
  23744. static readonly DOUBLESIDE: number;
  23745. /**
  23746. * Mesh side orientation : by default, `FRONTSIDE`
  23747. */
  23748. static readonly DEFAULTSIDE: number;
  23749. /**
  23750. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23751. */
  23752. positions: Nullable<FloatArray>;
  23753. /**
  23754. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23755. */
  23756. normals: Nullable<FloatArray>;
  23757. /**
  23758. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23759. */
  23760. tangents: Nullable<FloatArray>;
  23761. /**
  23762. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23763. */
  23764. uvs: Nullable<FloatArray>;
  23765. /**
  23766. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23767. */
  23768. uvs2: Nullable<FloatArray>;
  23769. /**
  23770. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23771. */
  23772. uvs3: Nullable<FloatArray>;
  23773. /**
  23774. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23775. */
  23776. uvs4: Nullable<FloatArray>;
  23777. /**
  23778. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23779. */
  23780. uvs5: Nullable<FloatArray>;
  23781. /**
  23782. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23783. */
  23784. uvs6: Nullable<FloatArray>;
  23785. /**
  23786. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23787. */
  23788. colors: Nullable<FloatArray>;
  23789. /**
  23790. * 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).
  23791. */
  23792. matricesIndices: Nullable<FloatArray>;
  23793. /**
  23794. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23795. */
  23796. matricesWeights: Nullable<FloatArray>;
  23797. /**
  23798. * An array extending the number of possible indices
  23799. */
  23800. matricesIndicesExtra: Nullable<FloatArray>;
  23801. /**
  23802. * An array extending the number of possible weights when the number of indices is extended
  23803. */
  23804. matricesWeightsExtra: Nullable<FloatArray>;
  23805. /**
  23806. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23807. */
  23808. indices: Nullable<IndicesArray>;
  23809. /**
  23810. * Uses the passed data array to set the set the values for the specified kind of data
  23811. * @param data a linear array of floating numbers
  23812. * @param kind the type of data that is being set, eg positions, colors etc
  23813. */
  23814. set(data: FloatArray, kind: string): void;
  23815. /**
  23816. * Associates the vertexData to the passed Mesh.
  23817. * Sets it as updatable or not (default `false`)
  23818. * @param mesh the mesh the vertexData is applied to
  23819. * @param updatable when used and having the value true allows new data to update the vertexData
  23820. * @returns the VertexData
  23821. */
  23822. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23823. /**
  23824. * Associates the vertexData to the passed Geometry.
  23825. * Sets it as updatable or not (default `false`)
  23826. * @param geometry the geometry the vertexData is applied to
  23827. * @param updatable when used and having the value true allows new data to update the vertexData
  23828. * @returns VertexData
  23829. */
  23830. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23831. /**
  23832. * Updates the associated mesh
  23833. * @param mesh the mesh to be updated
  23834. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23835. * @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
  23836. * @returns VertexData
  23837. */
  23838. updateMesh(mesh: Mesh): VertexData;
  23839. /**
  23840. * Updates the associated geometry
  23841. * @param geometry the geometry to be updated
  23842. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23843. * @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
  23844. * @returns VertexData.
  23845. */
  23846. updateGeometry(geometry: Geometry): VertexData;
  23847. private _applyTo;
  23848. private _update;
  23849. /**
  23850. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23851. * @param matrix the transforming matrix
  23852. * @returns the VertexData
  23853. */
  23854. transform(matrix: Matrix): VertexData;
  23855. /**
  23856. * Merges the passed VertexData into the current one
  23857. * @param other the VertexData to be merged into the current one
  23858. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23859. * @returns the modified VertexData
  23860. */
  23861. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23862. private _mergeElement;
  23863. private _validate;
  23864. /**
  23865. * Serializes the VertexData
  23866. * @returns a serialized object
  23867. */
  23868. serialize(): any;
  23869. /**
  23870. * Extracts the vertexData from a mesh
  23871. * @param mesh the mesh from which to extract the VertexData
  23872. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23873. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23874. * @returns the object VertexData associated to the passed mesh
  23875. */
  23876. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23877. /**
  23878. * Extracts the vertexData from the geometry
  23879. * @param geometry the geometry from which to extract the VertexData
  23880. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23881. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23882. * @returns the object VertexData associated to the passed mesh
  23883. */
  23884. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23885. private static _ExtractFrom;
  23886. /**
  23887. * Creates the VertexData for a Ribbon
  23888. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23889. * * pathArray array of paths, each of which an array of successive Vector3
  23890. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23891. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23892. * * 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
  23893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23894. * * 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)
  23895. * * 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)
  23896. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23897. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23898. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23899. * @returns the VertexData of the ribbon
  23900. */
  23901. static CreateRibbon(options: {
  23902. pathArray: Vector3[][];
  23903. closeArray?: boolean;
  23904. closePath?: boolean;
  23905. offset?: number;
  23906. sideOrientation?: number;
  23907. frontUVs?: Vector4;
  23908. backUVs?: Vector4;
  23909. invertUV?: boolean;
  23910. uvs?: Vector2[];
  23911. colors?: Color4[];
  23912. }): VertexData;
  23913. /**
  23914. * Creates the VertexData for a box
  23915. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23916. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23917. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23918. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23919. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23920. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23921. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23923. * * 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)
  23924. * * 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)
  23925. * @returns the VertexData of the box
  23926. */
  23927. static CreateBox(options: {
  23928. size?: number;
  23929. width?: number;
  23930. height?: number;
  23931. depth?: number;
  23932. faceUV?: Vector4[];
  23933. faceColors?: Color4[];
  23934. sideOrientation?: number;
  23935. frontUVs?: Vector4;
  23936. backUVs?: Vector4;
  23937. }): VertexData;
  23938. /**
  23939. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23940. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23941. * * segments sets the number of horizontal strips optional, default 32
  23942. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23943. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23944. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23945. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23946. * * 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
  23947. * * 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
  23948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23949. * * 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)
  23950. * * 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)
  23951. * @returns the VertexData of the ellipsoid
  23952. */
  23953. static CreateSphere(options: {
  23954. segments?: number;
  23955. diameter?: number;
  23956. diameterX?: number;
  23957. diameterY?: number;
  23958. diameterZ?: number;
  23959. arc?: number;
  23960. slice?: number;
  23961. sideOrientation?: number;
  23962. frontUVs?: Vector4;
  23963. backUVs?: Vector4;
  23964. }): VertexData;
  23965. /**
  23966. * Creates the VertexData for a cylinder, cone or prism
  23967. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23968. * * height sets the height (y direction) of the cylinder, optional, default 2
  23969. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23970. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23971. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23972. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23973. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23974. * * 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
  23975. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23976. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23977. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23978. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23980. * * 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)
  23981. * * 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)
  23982. * @returns the VertexData of the cylinder, cone or prism
  23983. */
  23984. static CreateCylinder(options: {
  23985. height?: number;
  23986. diameterTop?: number;
  23987. diameterBottom?: number;
  23988. diameter?: number;
  23989. tessellation?: number;
  23990. subdivisions?: number;
  23991. arc?: number;
  23992. faceColors?: Color4[];
  23993. faceUV?: Vector4[];
  23994. hasRings?: boolean;
  23995. enclose?: boolean;
  23996. sideOrientation?: number;
  23997. frontUVs?: Vector4;
  23998. backUVs?: Vector4;
  23999. }): VertexData;
  24000. /**
  24001. * Creates the VertexData for a torus
  24002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24003. * * diameter the diameter of the torus, optional default 1
  24004. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24007. * * 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)
  24008. * * 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)
  24009. * @returns the VertexData of the torus
  24010. */
  24011. static CreateTorus(options: {
  24012. diameter?: number;
  24013. thickness?: number;
  24014. tessellation?: number;
  24015. sideOrientation?: number;
  24016. frontUVs?: Vector4;
  24017. backUVs?: Vector4;
  24018. }): VertexData;
  24019. /**
  24020. * Creates the VertexData of the LineSystem
  24021. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24022. * - lines an array of lines, each line being an array of successive Vector3
  24023. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24024. * @returns the VertexData of the LineSystem
  24025. */
  24026. static CreateLineSystem(options: {
  24027. lines: Vector3[][];
  24028. colors?: Nullable<Color4[][]>;
  24029. }): VertexData;
  24030. /**
  24031. * Create the VertexData for a DashedLines
  24032. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24033. * - points an array successive Vector3
  24034. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24035. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24036. * - dashNb the intended total number of dashes, optional, default 200
  24037. * @returns the VertexData for the DashedLines
  24038. */
  24039. static CreateDashedLines(options: {
  24040. points: Vector3[];
  24041. dashSize?: number;
  24042. gapSize?: number;
  24043. dashNb?: number;
  24044. }): VertexData;
  24045. /**
  24046. * Creates the VertexData for a Ground
  24047. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24048. * - width the width (x direction) of the ground, optional, default 1
  24049. * - height the height (z direction) of the ground, optional, default 1
  24050. * - subdivisions the number of subdivisions per side, optional, default 1
  24051. * @returns the VertexData of the Ground
  24052. */
  24053. static CreateGround(options: {
  24054. width?: number;
  24055. height?: number;
  24056. subdivisions?: number;
  24057. subdivisionsX?: number;
  24058. subdivisionsY?: number;
  24059. }): VertexData;
  24060. /**
  24061. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24062. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24063. * * xmin the ground minimum X coordinate, optional, default -1
  24064. * * zmin the ground minimum Z coordinate, optional, default -1
  24065. * * xmax the ground maximum X coordinate, optional, default 1
  24066. * * zmax the ground maximum Z coordinate, optional, default 1
  24067. * * 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}
  24068. * * 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}
  24069. * @returns the VertexData of the TiledGround
  24070. */
  24071. static CreateTiledGround(options: {
  24072. xmin: number;
  24073. zmin: number;
  24074. xmax: number;
  24075. zmax: number;
  24076. subdivisions?: {
  24077. w: number;
  24078. h: number;
  24079. };
  24080. precision?: {
  24081. w: number;
  24082. h: number;
  24083. };
  24084. }): VertexData;
  24085. /**
  24086. * Creates the VertexData of the Ground designed from a heightmap
  24087. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24088. * * width the width (x direction) of the ground
  24089. * * height the height (z direction) of the ground
  24090. * * subdivisions the number of subdivisions per side
  24091. * * minHeight the minimum altitude on the ground, optional, default 0
  24092. * * maxHeight the maximum altitude on the ground, optional default 1
  24093. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24094. * * buffer the array holding the image color data
  24095. * * bufferWidth the width of image
  24096. * * bufferHeight the height of image
  24097. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24098. * @returns the VertexData of the Ground designed from a heightmap
  24099. */
  24100. static CreateGroundFromHeightMap(options: {
  24101. width: number;
  24102. height: number;
  24103. subdivisions: number;
  24104. minHeight: number;
  24105. maxHeight: number;
  24106. colorFilter: Color3;
  24107. buffer: Uint8Array;
  24108. bufferWidth: number;
  24109. bufferHeight: number;
  24110. alphaFilter: number;
  24111. }): VertexData;
  24112. /**
  24113. * Creates the VertexData for a Plane
  24114. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24115. * * size sets the width and height of the plane to the value of size, optional default 1
  24116. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24117. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24119. * * 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)
  24120. * * 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)
  24121. * @returns the VertexData of the box
  24122. */
  24123. static CreatePlane(options: {
  24124. size?: number;
  24125. width?: number;
  24126. height?: number;
  24127. sideOrientation?: number;
  24128. frontUVs?: Vector4;
  24129. backUVs?: Vector4;
  24130. }): VertexData;
  24131. /**
  24132. * Creates the VertexData of the Disc or regular Polygon
  24133. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24134. * * radius the radius of the disc, optional default 0.5
  24135. * * tessellation the number of polygon sides, optional, default 64
  24136. * * 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
  24137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24138. * * 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)
  24139. * * 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)
  24140. * @returns the VertexData of the box
  24141. */
  24142. static CreateDisc(options: {
  24143. radius?: number;
  24144. tessellation?: number;
  24145. arc?: number;
  24146. sideOrientation?: number;
  24147. frontUVs?: Vector4;
  24148. backUVs?: Vector4;
  24149. }): VertexData;
  24150. /**
  24151. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24152. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24153. * @param polygon a mesh built from polygonTriangulation.build()
  24154. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24155. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24156. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24157. * @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)
  24158. * @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)
  24159. * @returns the VertexData of the Polygon
  24160. */
  24161. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24162. /**
  24163. * Creates the VertexData of the IcoSphere
  24164. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24165. * * radius the radius of the IcoSphere, optional default 1
  24166. * * radiusX allows stretching in the x direction, optional, default radius
  24167. * * radiusY allows stretching in the y direction, optional, default radius
  24168. * * radiusZ allows stretching in the z direction, optional, default radius
  24169. * * flat when true creates a flat shaded mesh, optional, default true
  24170. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24172. * * 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)
  24173. * * 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)
  24174. * @returns the VertexData of the IcoSphere
  24175. */
  24176. static CreateIcoSphere(options: {
  24177. radius?: number;
  24178. radiusX?: number;
  24179. radiusY?: number;
  24180. radiusZ?: number;
  24181. flat?: boolean;
  24182. subdivisions?: number;
  24183. sideOrientation?: number;
  24184. frontUVs?: Vector4;
  24185. backUVs?: Vector4;
  24186. }): VertexData;
  24187. /**
  24188. * Creates the VertexData for a Polyhedron
  24189. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24190. * * type provided types are:
  24191. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24192. * * 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)
  24193. * * size the size of the IcoSphere, optional default 1
  24194. * * sizeX allows stretching in the x direction, optional, default size
  24195. * * sizeY allows stretching in the y direction, optional, default size
  24196. * * sizeZ allows stretching in the z direction, optional, default size
  24197. * * 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
  24198. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24199. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24200. * * flat when true creates a flat shaded mesh, optional, default true
  24201. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24203. * * 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)
  24204. * * 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)
  24205. * @returns the VertexData of the Polyhedron
  24206. */
  24207. static CreatePolyhedron(options: {
  24208. type?: number;
  24209. size?: number;
  24210. sizeX?: number;
  24211. sizeY?: number;
  24212. sizeZ?: number;
  24213. custom?: any;
  24214. faceUV?: Vector4[];
  24215. faceColors?: Color4[];
  24216. flat?: boolean;
  24217. sideOrientation?: number;
  24218. frontUVs?: Vector4;
  24219. backUVs?: Vector4;
  24220. }): VertexData;
  24221. /**
  24222. * Creates the VertexData for a TorusKnot
  24223. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24224. * * radius the radius of the torus knot, optional, default 2
  24225. * * tube the thickness of the tube, optional, default 0.5
  24226. * * radialSegments the number of sides on each tube segments, optional, default 32
  24227. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24228. * * p the number of windings around the z axis, optional, default 2
  24229. * * q the number of windings around the x axis, optional, default 3
  24230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24231. * * 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)
  24232. * * 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)
  24233. * @returns the VertexData of the Torus Knot
  24234. */
  24235. static CreateTorusKnot(options: {
  24236. radius?: number;
  24237. tube?: number;
  24238. radialSegments?: number;
  24239. tubularSegments?: number;
  24240. p?: number;
  24241. q?: number;
  24242. sideOrientation?: number;
  24243. frontUVs?: Vector4;
  24244. backUVs?: Vector4;
  24245. }): VertexData;
  24246. /**
  24247. * Compute normals for given positions and indices
  24248. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24249. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24250. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24251. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24252. * * facetNormals : optional array of facet normals (vector3)
  24253. * * facetPositions : optional array of facet positions (vector3)
  24254. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24255. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24256. * * bInfo : optional bounding info, required for facetPartitioning computation
  24257. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24258. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24259. * * useRightHandedSystem: optional boolean to for right handed system computation
  24260. * * depthSort : optional boolean to enable the facet depth sort computation
  24261. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24262. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24263. */
  24264. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24265. facetNormals?: any;
  24266. facetPositions?: any;
  24267. facetPartitioning?: any;
  24268. ratio?: number;
  24269. bInfo?: any;
  24270. bbSize?: Vector3;
  24271. subDiv?: any;
  24272. useRightHandedSystem?: boolean;
  24273. depthSort?: boolean;
  24274. distanceTo?: Vector3;
  24275. depthSortedFacets?: any;
  24276. }): void;
  24277. /** @hidden */
  24278. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24279. /**
  24280. * Applies VertexData created from the imported parameters to the geometry
  24281. * @param parsedVertexData the parsed data from an imported file
  24282. * @param geometry the geometry to apply the VertexData to
  24283. */
  24284. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24285. }
  24286. }
  24287. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24288. import { Nullable } from "babylonjs/types";
  24289. import { Scene } from "babylonjs/scene";
  24290. import { Vector4 } from "babylonjs/Maths/math";
  24291. import { Mesh } from "babylonjs/Meshes/mesh";
  24292. /**
  24293. * Class containing static functions to help procedurally build meshes
  24294. */
  24295. export class DiscBuilder {
  24296. /**
  24297. * Creates a plane polygonal mesh. By default, this is a disc
  24298. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24299. * * 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
  24300. * * 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
  24301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24304. * @param name defines the name of the mesh
  24305. * @param options defines the options used to create the mesh
  24306. * @param scene defines the hosting scene
  24307. * @returns the plane polygonal mesh
  24308. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24309. */
  24310. static CreateDisc(name: string, options: {
  24311. radius?: number;
  24312. tessellation?: number;
  24313. arc?: number;
  24314. updatable?: boolean;
  24315. sideOrientation?: number;
  24316. frontUVs?: Vector4;
  24317. backUVs?: Vector4;
  24318. }, scene?: Nullable<Scene>): Mesh;
  24319. }
  24320. }
  24321. declare module "babylonjs/Particles/solidParticleSystem" {
  24322. import { Vector3 } from "babylonjs/Maths/math";
  24323. import { Mesh } from "babylonjs/Meshes/mesh";
  24324. import { Scene, IDisposable } from "babylonjs/scene";
  24325. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24326. /**
  24327. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24328. *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.
  24329. * The SPS is also a particle system. It provides some methods to manage the particles.
  24330. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24331. *
  24332. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24333. */
  24334. export class SolidParticleSystem implements IDisposable {
  24335. /**
  24336. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24337. * Example : var p = SPS.particles[i];
  24338. */
  24339. particles: SolidParticle[];
  24340. /**
  24341. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24342. */
  24343. nbParticles: number;
  24344. /**
  24345. * If the particles must ever face the camera (default false). Useful for planar particles.
  24346. */
  24347. billboard: boolean;
  24348. /**
  24349. * Recompute normals when adding a shape
  24350. */
  24351. recomputeNormals: boolean;
  24352. /**
  24353. * This a counter ofr your own usage. It's not set by any SPS functions.
  24354. */
  24355. counter: number;
  24356. /**
  24357. * The SPS name. This name is also given to the underlying mesh.
  24358. */
  24359. name: string;
  24360. /**
  24361. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24362. */
  24363. mesh: Mesh;
  24364. /**
  24365. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24366. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24367. */
  24368. vars: any;
  24369. /**
  24370. * This array is populated when the SPS is set as 'pickable'.
  24371. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24372. * Each element of this array is an object `{idx: int, faceId: int}`.
  24373. * `idx` is the picked particle index in the `SPS.particles` array
  24374. * `faceId` is the picked face index counted within this particle.
  24375. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24376. */
  24377. pickedParticles: {
  24378. idx: number;
  24379. faceId: number;
  24380. }[];
  24381. /**
  24382. * This array is populated when `enableDepthSort` is set to true.
  24383. * Each element of this array is an instance of the class DepthSortedParticle.
  24384. */
  24385. depthSortedParticles: DepthSortedParticle[];
  24386. /**
  24387. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24388. * @hidden
  24389. */
  24390. _bSphereOnly: boolean;
  24391. /**
  24392. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24393. * @hidden
  24394. */
  24395. _bSphereRadiusFactor: number;
  24396. private _scene;
  24397. private _positions;
  24398. private _indices;
  24399. private _normals;
  24400. private _colors;
  24401. private _uvs;
  24402. private _indices32;
  24403. private _positions32;
  24404. private _normals32;
  24405. private _fixedNormal32;
  24406. private _colors32;
  24407. private _uvs32;
  24408. private _index;
  24409. private _updatable;
  24410. private _pickable;
  24411. private _isVisibilityBoxLocked;
  24412. private _alwaysVisible;
  24413. private _depthSort;
  24414. private _shapeCounter;
  24415. private _copy;
  24416. private _color;
  24417. private _computeParticleColor;
  24418. private _computeParticleTexture;
  24419. private _computeParticleRotation;
  24420. private _computeParticleVertex;
  24421. private _computeBoundingBox;
  24422. private _depthSortParticles;
  24423. private _camera;
  24424. private _mustUnrotateFixedNormals;
  24425. private _particlesIntersect;
  24426. private _needs32Bits;
  24427. /**
  24428. * Creates a SPS (Solid Particle System) object.
  24429. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24430. * @param scene (Scene) is the scene in which the SPS is added.
  24431. * @param options defines the options of the sps e.g.
  24432. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24433. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24434. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24435. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24436. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24437. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24438. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24439. */
  24440. constructor(name: string, scene: Scene, options?: {
  24441. updatable?: boolean;
  24442. isPickable?: boolean;
  24443. enableDepthSort?: boolean;
  24444. particleIntersection?: boolean;
  24445. boundingSphereOnly?: boolean;
  24446. bSphereRadiusFactor?: number;
  24447. });
  24448. /**
  24449. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24450. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24451. * @returns the created mesh
  24452. */
  24453. buildMesh(): Mesh;
  24454. /**
  24455. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24456. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24457. * Thus the particles generated from `digest()` have their property `position` set yet.
  24458. * @param mesh ( Mesh ) is the mesh to be digested
  24459. * @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
  24460. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24461. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24462. * @returns the current SPS
  24463. */
  24464. digest(mesh: Mesh, options?: {
  24465. facetNb?: number;
  24466. number?: number;
  24467. delta?: number;
  24468. }): SolidParticleSystem;
  24469. private _unrotateFixedNormals;
  24470. private _resetCopy;
  24471. private _meshBuilder;
  24472. private _posToShape;
  24473. private _uvsToShapeUV;
  24474. private _addParticle;
  24475. /**
  24476. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24477. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24478. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24479. * @param nb (positive integer) the number of particles to be created from this model
  24480. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24481. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24482. * @returns the number of shapes in the system
  24483. */
  24484. addShape(mesh: Mesh, nb: number, options?: {
  24485. positionFunction?: any;
  24486. vertexFunction?: any;
  24487. }): number;
  24488. private _rebuildParticle;
  24489. /**
  24490. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24491. * @returns the SPS.
  24492. */
  24493. rebuildMesh(): SolidParticleSystem;
  24494. /**
  24495. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24496. * This method calls `updateParticle()` for each particle of the SPS.
  24497. * For an animated SPS, it is usually called within the render loop.
  24498. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24499. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24500. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24501. * @returns the SPS.
  24502. */
  24503. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24504. /**
  24505. * Disposes the SPS.
  24506. */
  24507. dispose(): void;
  24508. /**
  24509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24511. * @returns the SPS.
  24512. */
  24513. refreshVisibleSize(): SolidParticleSystem;
  24514. /**
  24515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24516. * @param size the size (float) of the visibility box
  24517. * note : this doesn't lock the SPS mesh bounding box.
  24518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24519. */
  24520. setVisibilityBox(size: number): void;
  24521. /**
  24522. * Gets whether the SPS as always visible or not
  24523. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24524. */
  24525. /**
  24526. * Sets the SPS as always visible or not
  24527. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24528. */
  24529. isAlwaysVisible: boolean;
  24530. /**
  24531. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24533. */
  24534. /**
  24535. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24537. */
  24538. isVisibilityBoxLocked: boolean;
  24539. /**
  24540. * Tells to `setParticles()` to compute the particle rotations or not.
  24541. * Default value : true. The SPS is faster when it's set to false.
  24542. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24543. */
  24544. /**
  24545. * Gets if `setParticles()` computes the particle rotations or not.
  24546. * Default value : true. The SPS is faster when it's set to false.
  24547. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24548. */
  24549. computeParticleRotation: boolean;
  24550. /**
  24551. * Tells to `setParticles()` to compute the particle colors or not.
  24552. * Default value : true. The SPS is faster when it's set to false.
  24553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24554. */
  24555. /**
  24556. * Gets if `setParticles()` computes the particle colors or not.
  24557. * Default value : true. The SPS is faster when it's set to false.
  24558. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24559. */
  24560. computeParticleColor: boolean;
  24561. /**
  24562. * Gets if `setParticles()` computes the particle textures or not.
  24563. * Default value : true. The SPS is faster when it's set to false.
  24564. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24565. */
  24566. computeParticleTexture: boolean;
  24567. /**
  24568. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24569. * Default value : false. The SPS is faster when it's set to false.
  24570. * Note : the particle custom vertex positions aren't stored values.
  24571. */
  24572. /**
  24573. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24574. * Default value : false. The SPS is faster when it's set to false.
  24575. * Note : the particle custom vertex positions aren't stored values.
  24576. */
  24577. computeParticleVertex: boolean;
  24578. /**
  24579. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24580. */
  24581. /**
  24582. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24583. */
  24584. computeBoundingBox: boolean;
  24585. /**
  24586. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24588. * Default : `true`
  24589. */
  24590. /**
  24591. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24592. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24593. * Default : `true`
  24594. */
  24595. depthSortParticles: boolean;
  24596. /**
  24597. * This function does nothing. It may be overwritten to set all the particle first values.
  24598. * The SPS doesn't call this function, you may have to call it by your own.
  24599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24600. */
  24601. initParticles(): void;
  24602. /**
  24603. * This function does nothing. It may be overwritten to recycle a particle.
  24604. * The SPS doesn't call this function, you may have to call it by your own.
  24605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24606. * @param particle The particle to recycle
  24607. * @returns the recycled particle
  24608. */
  24609. recycleParticle(particle: SolidParticle): SolidParticle;
  24610. /**
  24611. * Updates a particle : this function should be overwritten by the user.
  24612. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24613. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24614. * @example : just set a particle position or velocity and recycle conditions
  24615. * @param particle The particle to update
  24616. * @returns the updated particle
  24617. */
  24618. updateParticle(particle: SolidParticle): SolidParticle;
  24619. /**
  24620. * Updates a vertex of a particle : it can be overwritten by the user.
  24621. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24622. * @param particle the current particle
  24623. * @param vertex the current index of the current particle
  24624. * @param pt the index of the current vertex in the particle shape
  24625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24626. * @example : just set a vertex particle position
  24627. * @returns the updated vertex
  24628. */
  24629. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24630. /**
  24631. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24632. * This does nothing and may be overwritten by the user.
  24633. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24634. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24635. * @param update the boolean update value actually passed to setParticles()
  24636. */
  24637. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24638. /**
  24639. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24640. * This will be passed three parameters.
  24641. * This does nothing and may be overwritten by the user.
  24642. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24643. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24644. * @param update the boolean update value actually passed to setParticles()
  24645. */
  24646. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24647. }
  24648. }
  24649. declare module "babylonjs/Particles/solidParticle" {
  24650. import { Nullable } from "babylonjs/types";
  24651. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24652. import { Mesh } from "babylonjs/Meshes/mesh";
  24653. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24654. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24655. /**
  24656. * Represents one particle of a solid particle system.
  24657. */
  24658. export class SolidParticle {
  24659. /**
  24660. * particle global index
  24661. */
  24662. idx: number;
  24663. /**
  24664. * The color of the particle
  24665. */
  24666. color: Nullable<Color4>;
  24667. /**
  24668. * The world space position of the particle.
  24669. */
  24670. position: Vector3;
  24671. /**
  24672. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24673. */
  24674. rotation: Vector3;
  24675. /**
  24676. * The world space rotation quaternion of the particle.
  24677. */
  24678. rotationQuaternion: Nullable<Quaternion>;
  24679. /**
  24680. * The scaling of the particle.
  24681. */
  24682. scaling: Vector3;
  24683. /**
  24684. * The uvs of the particle.
  24685. */
  24686. uvs: Vector4;
  24687. /**
  24688. * The current speed of the particle.
  24689. */
  24690. velocity: Vector3;
  24691. /**
  24692. * The pivot point in the particle local space.
  24693. */
  24694. pivot: Vector3;
  24695. /**
  24696. * Must the particle be translated from its pivot point in its local space ?
  24697. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24698. * Default : false
  24699. */
  24700. translateFromPivot: boolean;
  24701. /**
  24702. * Is the particle active or not ?
  24703. */
  24704. alive: boolean;
  24705. /**
  24706. * Is the particle visible or not ?
  24707. */
  24708. isVisible: boolean;
  24709. /**
  24710. * Index of this particle in the global "positions" array (Internal use)
  24711. * @hidden
  24712. */
  24713. _pos: number;
  24714. /**
  24715. * @hidden Index of this particle in the global "indices" array (Internal use)
  24716. */
  24717. _ind: number;
  24718. /**
  24719. * @hidden ModelShape of this particle (Internal use)
  24720. */
  24721. _model: ModelShape;
  24722. /**
  24723. * ModelShape id of this particle
  24724. */
  24725. shapeId: number;
  24726. /**
  24727. * Index of the particle in its shape id (Internal use)
  24728. */
  24729. idxInShape: number;
  24730. /**
  24731. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24732. */
  24733. _modelBoundingInfo: BoundingInfo;
  24734. /**
  24735. * @hidden Particle BoundingInfo object (Internal use)
  24736. */
  24737. _boundingInfo: BoundingInfo;
  24738. /**
  24739. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24740. */
  24741. _sps: SolidParticleSystem;
  24742. /**
  24743. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24744. */
  24745. _stillInvisible: boolean;
  24746. /**
  24747. * @hidden Last computed particle rotation matrix
  24748. */
  24749. _rotationMatrix: number[];
  24750. /**
  24751. * Parent particle Id, if any.
  24752. * Default null.
  24753. */
  24754. parentId: Nullable<number>;
  24755. /**
  24756. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24757. * The possible values are :
  24758. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24759. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24760. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24761. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24762. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24763. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24764. * */
  24765. cullingStrategy: number;
  24766. /**
  24767. * @hidden Internal global position in the SPS.
  24768. */
  24769. _globalPosition: Vector3;
  24770. /**
  24771. * Creates a Solid Particle object.
  24772. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24773. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24774. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24775. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24776. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24777. * @param shapeId (integer) is the model shape identifier in the SPS.
  24778. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24779. * @param sps defines the sps it is associated to
  24780. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24781. */
  24782. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24783. /**
  24784. * Legacy support, changed scale to scaling
  24785. */
  24786. /**
  24787. * Legacy support, changed scale to scaling
  24788. */
  24789. scale: Vector3;
  24790. /**
  24791. * Legacy support, changed quaternion to rotationQuaternion
  24792. */
  24793. /**
  24794. * Legacy support, changed quaternion to rotationQuaternion
  24795. */
  24796. quaternion: Nullable<Quaternion>;
  24797. /**
  24798. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24799. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24800. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24801. * @returns true if it intersects
  24802. */
  24803. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24804. /**
  24805. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24806. * A particle is in the frustum if its bounding box intersects the frustum
  24807. * @param frustumPlanes defines the frustum to test
  24808. * @returns true if the particle is in the frustum planes
  24809. */
  24810. isInFrustum(frustumPlanes: Plane[]): boolean;
  24811. /**
  24812. * get the rotation matrix of the particle
  24813. * @hidden
  24814. */
  24815. getRotationMatrix(m: Matrix): void;
  24816. }
  24817. /**
  24818. * Represents the shape of the model used by one particle of a solid particle system.
  24819. * SPS internal tool, don't use it manually.
  24820. */
  24821. export class ModelShape {
  24822. /**
  24823. * The shape id
  24824. * @hidden
  24825. */
  24826. shapeID: number;
  24827. /**
  24828. * flat array of model positions (internal use)
  24829. * @hidden
  24830. */
  24831. _shape: Vector3[];
  24832. /**
  24833. * flat array of model UVs (internal use)
  24834. * @hidden
  24835. */
  24836. _shapeUV: number[];
  24837. /**
  24838. * length of the shape in the model indices array (internal use)
  24839. * @hidden
  24840. */
  24841. _indicesLength: number;
  24842. /**
  24843. * Custom position function (internal use)
  24844. * @hidden
  24845. */
  24846. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24847. /**
  24848. * Custom vertex function (internal use)
  24849. * @hidden
  24850. */
  24851. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24852. /**
  24853. * 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.
  24854. * SPS internal tool, don't use it manually.
  24855. * @hidden
  24856. */
  24857. 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>);
  24858. }
  24859. /**
  24860. * Represents a Depth Sorted Particle in the solid particle system.
  24861. */
  24862. export class DepthSortedParticle {
  24863. /**
  24864. * Index of the particle in the "indices" array
  24865. */
  24866. ind: number;
  24867. /**
  24868. * Length of the particle shape in the "indices" array
  24869. */
  24870. indicesLength: number;
  24871. /**
  24872. * Squared distance from the particle to the camera
  24873. */
  24874. sqDistance: number;
  24875. }
  24876. }
  24877. declare module "babylonjs/Meshes/abstractMesh" {
  24878. import { Observable } from "babylonjs/Misc/observable";
  24879. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24880. import { Camera } from "babylonjs/Cameras/camera";
  24881. import { Scene, IDisposable } from "babylonjs/scene";
  24882. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24883. import { Node } from "babylonjs/node";
  24884. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24887. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24888. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24889. import { Material } from "babylonjs/Materials/material";
  24890. import { Light } from "babylonjs/Lights/light";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24893. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24894. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24895. import { Ray } from "babylonjs/Culling/ray";
  24896. import { Collider } from "babylonjs/Collisions/collider";
  24897. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24898. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24899. /**
  24900. * Class used to store all common mesh properties
  24901. */
  24902. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24903. /** No occlusion */
  24904. static OCCLUSION_TYPE_NONE: number;
  24905. /** Occlusion set to optimisitic */
  24906. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24907. /** Occlusion set to strict */
  24908. static OCCLUSION_TYPE_STRICT: number;
  24909. /** Use an accurante occlusion algorithm */
  24910. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24911. /** Use a conservative occlusion algorithm */
  24912. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24913. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24914. * Test order :
  24915. * Is the bounding sphere outside the frustum ?
  24916. * If not, are the bounding box vertices outside the frustum ?
  24917. * It not, then the cullable object is in the frustum.
  24918. */
  24919. static readonly CULLINGSTRATEGY_STANDARD: number;
  24920. /** Culling strategy : Bounding Sphere Only.
  24921. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24922. * It's also less accurate than the standard because some not visible objects can still be selected.
  24923. * Test : is the bounding sphere outside the frustum ?
  24924. * If not, then the cullable object is in the frustum.
  24925. */
  24926. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24927. /** Culling strategy : Optimistic Inclusion.
  24928. * This in an inclusion test first, then the standard exclusion test.
  24929. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24930. * 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.
  24931. * Anyway, it's as accurate as the standard strategy.
  24932. * Test :
  24933. * Is the cullable object bounding sphere center in the frustum ?
  24934. * If not, apply the default culling strategy.
  24935. */
  24936. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24937. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24938. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24939. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24940. * 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.
  24941. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24942. * Test :
  24943. * Is the cullable object bounding sphere center in the frustum ?
  24944. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24945. */
  24946. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24947. /**
  24948. * No billboard
  24949. */
  24950. static readonly BILLBOARDMODE_NONE: number;
  24951. /** Billboard on X axis */
  24952. static readonly BILLBOARDMODE_X: number;
  24953. /** Billboard on Y axis */
  24954. static readonly BILLBOARDMODE_Y: number;
  24955. /** Billboard on Z axis */
  24956. static readonly BILLBOARDMODE_Z: number;
  24957. /** Billboard on all axes */
  24958. static readonly BILLBOARDMODE_ALL: number;
  24959. private _facetData;
  24960. /**
  24961. * The culling strategy to use to check whether the mesh must be rendered or not.
  24962. * This value can be changed at any time and will be used on the next render mesh selection.
  24963. * The possible values are :
  24964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24968. * Please read each static variable documentation to get details about the culling process.
  24969. * */
  24970. cullingStrategy: number;
  24971. /**
  24972. * Gets the number of facets in the mesh
  24973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24974. */
  24975. readonly facetNb: number;
  24976. /**
  24977. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24979. */
  24980. partitioningSubdivisions: number;
  24981. /**
  24982. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24983. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24985. */
  24986. partitioningBBoxRatio: number;
  24987. /**
  24988. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24989. * Works only for updatable meshes.
  24990. * Doesn't work with multi-materials
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24992. */
  24993. mustDepthSortFacets: boolean;
  24994. /**
  24995. * The location (Vector3) where the facet depth sort must be computed from.
  24996. * By default, the active camera position.
  24997. * Used only when facet depth sort is enabled
  24998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24999. */
  25000. facetDepthSortFrom: Vector3;
  25001. /**
  25002. * gets a boolean indicating if facetData is enabled
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25004. */
  25005. readonly isFacetDataEnabled: boolean;
  25006. /** @hidden */
  25007. _updateNonUniformScalingState(value: boolean): boolean;
  25008. /**
  25009. * An event triggered when this mesh collides with another one
  25010. */
  25011. onCollideObservable: Observable<AbstractMesh>;
  25012. private _onCollideObserver;
  25013. /** Set a function to call when this mesh collides with another one */
  25014. onCollide: () => void;
  25015. /**
  25016. * An event triggered when the collision's position changes
  25017. */
  25018. onCollisionPositionChangeObservable: Observable<Vector3>;
  25019. private _onCollisionPositionChangeObserver;
  25020. /** Set a function to call when the collision's position changes */
  25021. onCollisionPositionChange: () => void;
  25022. /**
  25023. * An event triggered when material is changed
  25024. */
  25025. onMaterialChangedObservable: Observable<AbstractMesh>;
  25026. /**
  25027. * Gets or sets the orientation for POV movement & rotation
  25028. */
  25029. definedFacingForward: boolean;
  25030. /** @hidden */
  25031. _occlusionQuery: Nullable<WebGLQuery>;
  25032. private _visibility;
  25033. /** @hidden */
  25034. _isActive: boolean;
  25035. /** @hidden */
  25036. _onlyForInstances: boolean;
  25037. /** @hidden */
  25038. _renderingGroup: Nullable<RenderingGroup>;
  25039. /**
  25040. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25041. */
  25042. /**
  25043. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25044. */
  25045. visibility: number;
  25046. /** Gets or sets the alpha index used to sort transparent meshes
  25047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25048. */
  25049. alphaIndex: number;
  25050. /**
  25051. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25052. */
  25053. isVisible: boolean;
  25054. /**
  25055. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25056. */
  25057. isPickable: boolean;
  25058. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25059. showSubMeshesBoundingBox: boolean;
  25060. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25062. */
  25063. isBlocker: boolean;
  25064. /**
  25065. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25066. */
  25067. enablePointerMoveEvents: boolean;
  25068. /**
  25069. * Specifies the rendering group id for this mesh (0 by default)
  25070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25071. */
  25072. renderingGroupId: number;
  25073. private _material;
  25074. /** Gets or sets current material */
  25075. material: Nullable<Material>;
  25076. private _receiveShadows;
  25077. /**
  25078. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25079. * @see http://doc.babylonjs.com/babylon101/shadows
  25080. */
  25081. receiveShadows: boolean;
  25082. /** Defines color to use when rendering outline */
  25083. outlineColor: Color3;
  25084. /** Define width to use when rendering outline */
  25085. outlineWidth: number;
  25086. /** Defines color to use when rendering overlay */
  25087. overlayColor: Color3;
  25088. /** Defines alpha to use when rendering overlay */
  25089. overlayAlpha: number;
  25090. private _hasVertexAlpha;
  25091. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25092. hasVertexAlpha: boolean;
  25093. private _useVertexColors;
  25094. /** 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) */
  25095. useVertexColors: boolean;
  25096. private _computeBonesUsingShaders;
  25097. /**
  25098. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25099. */
  25100. computeBonesUsingShaders: boolean;
  25101. private _numBoneInfluencers;
  25102. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25103. numBoneInfluencers: number;
  25104. private _applyFog;
  25105. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25106. applyFog: boolean;
  25107. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25108. useOctreeForRenderingSelection: boolean;
  25109. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25110. useOctreeForPicking: boolean;
  25111. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25112. useOctreeForCollisions: boolean;
  25113. private _layerMask;
  25114. /**
  25115. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25116. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25117. */
  25118. layerMask: number;
  25119. /**
  25120. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25121. */
  25122. alwaysSelectAsActiveMesh: boolean;
  25123. /**
  25124. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25125. */
  25126. doNotSyncBoundingInfo: boolean;
  25127. /**
  25128. * Gets or sets the current action manager
  25129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25130. */
  25131. actionManager: Nullable<AbstractActionManager>;
  25132. private _checkCollisions;
  25133. private _collisionMask;
  25134. private _collisionGroup;
  25135. /**
  25136. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25138. */
  25139. ellipsoid: Vector3;
  25140. /**
  25141. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25143. */
  25144. ellipsoidOffset: Vector3;
  25145. private _collider;
  25146. private _oldPositionForCollisions;
  25147. private _diffPositionForCollisions;
  25148. /**
  25149. * Gets or sets a collision mask used to mask collisions (default is -1).
  25150. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25151. */
  25152. collisionMask: number;
  25153. /**
  25154. * Gets or sets the current collision group mask (-1 by default).
  25155. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25156. */
  25157. collisionGroup: number;
  25158. /**
  25159. * Defines edge width used when edgesRenderer is enabled
  25160. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25161. */
  25162. edgesWidth: number;
  25163. /**
  25164. * Defines edge color used when edgesRenderer is enabled
  25165. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25166. */
  25167. edgesColor: Color4;
  25168. /** @hidden */
  25169. _edgesRenderer: Nullable<IEdgesRenderer>;
  25170. /** @hidden */
  25171. _masterMesh: Nullable<AbstractMesh>;
  25172. /** @hidden */
  25173. _boundingInfo: Nullable<BoundingInfo>;
  25174. /** @hidden */
  25175. _renderId: number;
  25176. /**
  25177. * Gets or sets the list of subMeshes
  25178. * @see http://doc.babylonjs.com/how_to/multi_materials
  25179. */
  25180. subMeshes: SubMesh[];
  25181. /** @hidden */
  25182. _intersectionsInProgress: AbstractMesh[];
  25183. /** @hidden */
  25184. _unIndexed: boolean;
  25185. /** @hidden */
  25186. _lightSources: Light[];
  25187. /** Gets the list of lights affecting that mesh */
  25188. readonly lightSources: Light[];
  25189. /** @hidden */
  25190. readonly _positions: Nullable<Vector3[]>;
  25191. /** @hidden */
  25192. _waitingActions: Nullable<any>;
  25193. /** @hidden */
  25194. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25195. private _skeleton;
  25196. /** @hidden */
  25197. _bonesTransformMatrices: Nullable<Float32Array>;
  25198. /**
  25199. * Gets or sets a skeleton to apply skining transformations
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25201. */
  25202. skeleton: Nullable<Skeleton>;
  25203. /**
  25204. * An event triggered when the mesh is rebuilt.
  25205. */
  25206. onRebuildObservable: Observable<AbstractMesh>;
  25207. /**
  25208. * Creates a new AbstractMesh
  25209. * @param name defines the name of the mesh
  25210. * @param scene defines the hosting scene
  25211. */
  25212. constructor(name: string, scene?: Nullable<Scene>);
  25213. /**
  25214. * Returns the string "AbstractMesh"
  25215. * @returns "AbstractMesh"
  25216. */
  25217. getClassName(): string;
  25218. /**
  25219. * Gets a string representation of the current mesh
  25220. * @param fullDetails defines a boolean indicating if full details must be included
  25221. * @returns a string representation of the current mesh
  25222. */
  25223. toString(fullDetails?: boolean): string;
  25224. /**
  25225. * @hidden
  25226. */
  25227. protected _getEffectiveParent(): Nullable<Node>;
  25228. /** @hidden */
  25229. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25230. /** @hidden */
  25231. _rebuild(): void;
  25232. /** @hidden */
  25233. _resyncLightSources(): void;
  25234. /** @hidden */
  25235. _resyncLighSource(light: Light): void;
  25236. /** @hidden */
  25237. _unBindEffect(): void;
  25238. /** @hidden */
  25239. _removeLightSource(light: Light): void;
  25240. private _markSubMeshesAsDirty;
  25241. /** @hidden */
  25242. _markSubMeshesAsLightDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsAttributesDirty(): void;
  25245. /** @hidden */
  25246. _markSubMeshesAsMiscDirty(): void;
  25247. /**
  25248. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25249. */
  25250. scaling: Vector3;
  25251. /**
  25252. * Returns true if the mesh is blocked. Implemented by child classes
  25253. */
  25254. readonly isBlocked: boolean;
  25255. /**
  25256. * Returns the mesh itself by default. Implemented by child classes
  25257. * @param camera defines the camera to use to pick the right LOD level
  25258. * @returns the currentAbstractMesh
  25259. */
  25260. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25261. /**
  25262. * Returns 0 by default. Implemented by child classes
  25263. * @returns an integer
  25264. */
  25265. getTotalVertices(): number;
  25266. /**
  25267. * Returns a positive integer : the total number of indices in this mesh geometry.
  25268. * @returns the numner of indices or zero if the mesh has no geometry.
  25269. */
  25270. getTotalIndices(): number;
  25271. /**
  25272. * Returns null by default. Implemented by child classes
  25273. * @returns null
  25274. */
  25275. getIndices(): Nullable<IndicesArray>;
  25276. /**
  25277. * Returns the array of the requested vertex data kind. Implemented by child classes
  25278. * @param kind defines the vertex data kind to use
  25279. * @returns null
  25280. */
  25281. getVerticesData(kind: string): Nullable<FloatArray>;
  25282. /**
  25283. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25284. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25285. * Note that a new underlying VertexBuffer object is created each call.
  25286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25287. * @param kind defines vertex data kind:
  25288. * * VertexBuffer.PositionKind
  25289. * * VertexBuffer.UVKind
  25290. * * VertexBuffer.UV2Kind
  25291. * * VertexBuffer.UV3Kind
  25292. * * VertexBuffer.UV4Kind
  25293. * * VertexBuffer.UV5Kind
  25294. * * VertexBuffer.UV6Kind
  25295. * * VertexBuffer.ColorKind
  25296. * * VertexBuffer.MatricesIndicesKind
  25297. * * VertexBuffer.MatricesIndicesExtraKind
  25298. * * VertexBuffer.MatricesWeightsKind
  25299. * * VertexBuffer.MatricesWeightsExtraKind
  25300. * @param data defines the data source
  25301. * @param updatable defines if the data must be flagged as updatable (or static)
  25302. * @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
  25303. * @returns the current mesh
  25304. */
  25305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25306. /**
  25307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25308. * If the mesh has no geometry, it is simply returned as it is.
  25309. * @param kind defines vertex data kind:
  25310. * * VertexBuffer.PositionKind
  25311. * * VertexBuffer.UVKind
  25312. * * VertexBuffer.UV2Kind
  25313. * * VertexBuffer.UV3Kind
  25314. * * VertexBuffer.UV4Kind
  25315. * * VertexBuffer.UV5Kind
  25316. * * VertexBuffer.UV6Kind
  25317. * * VertexBuffer.ColorKind
  25318. * * VertexBuffer.MatricesIndicesKind
  25319. * * VertexBuffer.MatricesIndicesExtraKind
  25320. * * VertexBuffer.MatricesWeightsKind
  25321. * * VertexBuffer.MatricesWeightsExtraKind
  25322. * @param data defines the data source
  25323. * @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
  25324. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25325. * @returns the current mesh
  25326. */
  25327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25328. /**
  25329. * Sets the mesh indices,
  25330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25331. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25332. * @param totalVertices Defines the total number of vertices
  25333. * @returns the current mesh
  25334. */
  25335. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25336. /**
  25337. * Gets a boolean indicating if specific vertex data is present
  25338. * @param kind defines the vertex data kind to use
  25339. * @returns true is data kind is present
  25340. */
  25341. isVerticesDataPresent(kind: string): boolean;
  25342. /**
  25343. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25344. * @returns a BoundingInfo
  25345. */
  25346. getBoundingInfo(): BoundingInfo;
  25347. /**
  25348. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25349. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25350. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25351. * @returns the current mesh
  25352. */
  25353. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25354. /**
  25355. * Overwrite the current bounding info
  25356. * @param boundingInfo defines the new bounding info
  25357. * @returns the current mesh
  25358. */
  25359. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25360. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25361. readonly useBones: boolean;
  25362. /** @hidden */
  25363. _preActivate(): void;
  25364. /** @hidden */
  25365. _preActivateForIntermediateRendering(renderId: number): void;
  25366. /** @hidden */
  25367. _activate(renderId: number): boolean;
  25368. /** @hidden */
  25369. _freeze(): void;
  25370. /** @hidden */
  25371. _unFreeze(): void;
  25372. /**
  25373. * Gets the current world matrix
  25374. * @returns a Matrix
  25375. */
  25376. getWorldMatrix(): Matrix;
  25377. /** @hidden */
  25378. _getWorldMatrixDeterminant(): number;
  25379. /**
  25380. * Perform relative position change from the point of view of behind the front of the mesh.
  25381. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25382. * Supports definition of mesh facing forward or backward
  25383. * @param amountRight defines the distance on the right axis
  25384. * @param amountUp defines the distance on the up axis
  25385. * @param amountForward defines the distance on the forward axis
  25386. * @returns the current mesh
  25387. */
  25388. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25389. /**
  25390. * Calculate relative position change from the point of view of behind the front of the mesh.
  25391. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25392. * Supports definition of mesh facing forward or backward
  25393. * @param amountRight defines the distance on the right axis
  25394. * @param amountUp defines the distance on the up axis
  25395. * @param amountForward defines the distance on the forward axis
  25396. * @returns the new displacement vector
  25397. */
  25398. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25399. /**
  25400. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25401. * Supports definition of mesh facing forward or backward
  25402. * @param flipBack defines the flip
  25403. * @param twirlClockwise defines the twirl
  25404. * @param tiltRight defines the tilt
  25405. * @returns the current mesh
  25406. */
  25407. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25408. /**
  25409. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25410. * Supports definition of mesh facing forward or backward.
  25411. * @param flipBack defines the flip
  25412. * @param twirlClockwise defines the twirl
  25413. * @param tiltRight defines the tilt
  25414. * @returns the new rotation vector
  25415. */
  25416. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25417. /**
  25418. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25419. * This means the mesh underlying bounding box and sphere are recomputed.
  25420. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25421. * @returns the current mesh
  25422. */
  25423. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25424. /** @hidden */
  25425. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25426. /** @hidden */
  25427. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25428. /** @hidden */
  25429. _updateBoundingInfo(): AbstractMesh;
  25430. /** @hidden */
  25431. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25432. /** @hidden */
  25433. protected _afterComputeWorldMatrix(): void;
  25434. /** @hidden */
  25435. readonly _effectiveMesh: AbstractMesh;
  25436. /**
  25437. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25438. * A mesh is in the frustum if its bounding box intersects the frustum
  25439. * @param frustumPlanes defines the frustum to test
  25440. * @returns true if the mesh is in the frustum planes
  25441. */
  25442. isInFrustum(frustumPlanes: Plane[]): boolean;
  25443. /**
  25444. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25445. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25446. * @param frustumPlanes defines the frustum to test
  25447. * @returns true if the mesh is completely in the frustum planes
  25448. */
  25449. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25450. /**
  25451. * True if the mesh intersects another mesh or a SolidParticle object
  25452. * @param mesh defines a target mesh or SolidParticle to test
  25453. * @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)
  25454. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25455. * @returns true if there is an intersection
  25456. */
  25457. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25458. /**
  25459. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25460. * @param point defines the point to test
  25461. * @returns true if there is an intersection
  25462. */
  25463. intersectsPoint(point: Vector3): boolean;
  25464. /**
  25465. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25467. */
  25468. checkCollisions: boolean;
  25469. /**
  25470. * Gets Collider object used to compute collisions (not physics)
  25471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25472. */
  25473. readonly collider: Nullable<Collider>;
  25474. /**
  25475. * Move the mesh using collision engine
  25476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25477. * @param displacement defines the requested displacement vector
  25478. * @returns the current mesh
  25479. */
  25480. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25481. private _onCollisionPositionChange;
  25482. /** @hidden */
  25483. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25484. /** @hidden */
  25485. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25486. /** @hidden */
  25487. _checkCollision(collider: Collider): AbstractMesh;
  25488. /** @hidden */
  25489. _generatePointsArray(): boolean;
  25490. /**
  25491. * Checks if the passed Ray intersects with the mesh
  25492. * @param ray defines the ray to use
  25493. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25494. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25495. * @returns the picking info
  25496. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25497. */
  25498. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25499. /**
  25500. * Clones the current mesh
  25501. * @param name defines the mesh name
  25502. * @param newParent defines the new mesh parent
  25503. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25504. * @returns the new mesh
  25505. */
  25506. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25507. /**
  25508. * Disposes all the submeshes of the current meshnp
  25509. * @returns the current mesh
  25510. */
  25511. releaseSubMeshes(): AbstractMesh;
  25512. /**
  25513. * Releases resources associated with this abstract mesh.
  25514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25516. */
  25517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25518. /**
  25519. * Adds the passed mesh as a child to the current mesh
  25520. * @param mesh defines the child mesh
  25521. * @returns the current mesh
  25522. */
  25523. addChild(mesh: AbstractMesh): AbstractMesh;
  25524. /**
  25525. * Removes the passed mesh from the current mesh children list
  25526. * @param mesh defines the child mesh
  25527. * @returns the current mesh
  25528. */
  25529. removeChild(mesh: AbstractMesh): AbstractMesh;
  25530. /** @hidden */
  25531. private _initFacetData;
  25532. /**
  25533. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25534. * This method can be called within the render loop.
  25535. * 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
  25536. * @returns the current mesh
  25537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25538. */
  25539. updateFacetData(): AbstractMesh;
  25540. /**
  25541. * Returns the facetLocalNormals array.
  25542. * The normals are expressed in the mesh local spac
  25543. * @returns an array of Vector3
  25544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25545. */
  25546. getFacetLocalNormals(): Vector3[];
  25547. /**
  25548. * Returns the facetLocalPositions array.
  25549. * The facet positions are expressed in the mesh local space
  25550. * @returns an array of Vector3
  25551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25552. */
  25553. getFacetLocalPositions(): Vector3[];
  25554. /**
  25555. * Returns the facetLocalPartioning array
  25556. * @returns an array of array of numbers
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25558. */
  25559. getFacetLocalPartitioning(): number[][];
  25560. /**
  25561. * Returns the i-th facet position in the world system.
  25562. * This method allocates a new Vector3 per call
  25563. * @param i defines the facet index
  25564. * @returns a new Vector3
  25565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25566. */
  25567. getFacetPosition(i: number): Vector3;
  25568. /**
  25569. * Sets the reference Vector3 with the i-th facet position in the world system
  25570. * @param i defines the facet index
  25571. * @param ref defines the target vector
  25572. * @returns the current mesh
  25573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25574. */
  25575. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25576. /**
  25577. * Returns the i-th facet normal in the world system.
  25578. * This method allocates a new Vector3 per call
  25579. * @param i defines the facet index
  25580. * @returns a new Vector3
  25581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25582. */
  25583. getFacetNormal(i: number): Vector3;
  25584. /**
  25585. * Sets the reference Vector3 with the i-th facet normal in the world system
  25586. * @param i defines the facet index
  25587. * @param ref defines the target vector
  25588. * @returns the current mesh
  25589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25590. */
  25591. getFacetNormalToRef(i: number, ref: Vector3): this;
  25592. /**
  25593. * 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)
  25594. * @param x defines x coordinate
  25595. * @param y defines y coordinate
  25596. * @param z defines z coordinate
  25597. * @returns the array of facet indexes
  25598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25599. */
  25600. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25601. /**
  25602. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25603. * @param projected sets as the (x,y,z) world projection on the facet
  25604. * @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
  25605. * @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
  25606. * @param x defines x coordinate
  25607. * @param y defines y coordinate
  25608. * @param z defines z coordinate
  25609. * @returns the face index if found (or null instead)
  25610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25611. */
  25612. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25613. /**
  25614. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25615. * @param projected sets as the (x,y,z) local projection on the facet
  25616. * @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
  25617. * @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
  25618. * @param x defines x coordinate
  25619. * @param y defines y coordinate
  25620. * @param z defines z coordinate
  25621. * @returns the face index if found (or null instead)
  25622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25623. */
  25624. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25625. /**
  25626. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25627. * @returns the parameters
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. getFacetDataParameters(): any;
  25631. /**
  25632. * Disables the feature FacetData and frees the related memory
  25633. * @returns the current mesh
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. disableFacetData(): AbstractMesh;
  25637. /**
  25638. * Updates the AbstractMesh indices array
  25639. * @param indices defines the data source
  25640. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25641. * @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)
  25642. * @returns the current mesh
  25643. */
  25644. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25645. /**
  25646. * Creates new normals data for the mesh
  25647. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25648. * @returns the current mesh
  25649. */
  25650. createNormals(updatable: boolean): AbstractMesh;
  25651. /**
  25652. * Align the mesh with a normal
  25653. * @param normal defines the normal to use
  25654. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25655. * @returns the current mesh
  25656. */
  25657. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25658. /** @hidden */
  25659. _checkOcclusionQuery(): boolean;
  25660. }
  25661. }
  25662. declare module "babylonjs/Actions/actionEvent" {
  25663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25664. import { Nullable } from "babylonjs/types";
  25665. import { Sprite } from "babylonjs/Sprites/sprite";
  25666. import { Scene } from "babylonjs/scene";
  25667. import { Vector2 } from "babylonjs/Maths/math";
  25668. /**
  25669. * Interface used to define ActionEvent
  25670. */
  25671. export interface IActionEvent {
  25672. /** The mesh or sprite that triggered the action */
  25673. source: any;
  25674. /** The X mouse cursor position at the time of the event */
  25675. pointerX: number;
  25676. /** The Y mouse cursor position at the time of the event */
  25677. pointerY: number;
  25678. /** The mesh that is currently pointed at (can be null) */
  25679. meshUnderPointer: Nullable<AbstractMesh>;
  25680. /** the original (browser) event that triggered the ActionEvent */
  25681. sourceEvent?: any;
  25682. /** additional data for the event */
  25683. additionalData?: any;
  25684. }
  25685. /**
  25686. * ActionEvent is the event being sent when an action is triggered.
  25687. */
  25688. export class ActionEvent implements IActionEvent {
  25689. /** The mesh or sprite that triggered the action */
  25690. source: any;
  25691. /** The X mouse cursor position at the time of the event */
  25692. pointerX: number;
  25693. /** The Y mouse cursor position at the time of the event */
  25694. pointerY: number;
  25695. /** The mesh that is currently pointed at (can be null) */
  25696. meshUnderPointer: Nullable<AbstractMesh>;
  25697. /** the original (browser) event that triggered the ActionEvent */
  25698. sourceEvent?: any;
  25699. /** additional data for the event */
  25700. additionalData?: any;
  25701. /**
  25702. * Creates a new ActionEvent
  25703. * @param source The mesh or sprite that triggered the action
  25704. * @param pointerX The X mouse cursor position at the time of the event
  25705. * @param pointerY The Y mouse cursor position at the time of the event
  25706. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25707. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25708. * @param additionalData additional data for the event
  25709. */
  25710. constructor(
  25711. /** The mesh or sprite that triggered the action */
  25712. source: any,
  25713. /** The X mouse cursor position at the time of the event */
  25714. pointerX: number,
  25715. /** The Y mouse cursor position at the time of the event */
  25716. pointerY: number,
  25717. /** The mesh that is currently pointed at (can be null) */
  25718. meshUnderPointer: Nullable<AbstractMesh>,
  25719. /** the original (browser) event that triggered the ActionEvent */
  25720. sourceEvent?: any,
  25721. /** additional data for the event */
  25722. additionalData?: any);
  25723. /**
  25724. * Helper function to auto-create an ActionEvent from a source mesh.
  25725. * @param source The source mesh that triggered the event
  25726. * @param evt The original (browser) event
  25727. * @param additionalData additional data for the event
  25728. * @returns the new ActionEvent
  25729. */
  25730. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25731. /**
  25732. * Helper function to auto-create an ActionEvent from a source sprite
  25733. * @param source The source sprite that triggered the event
  25734. * @param scene Scene associated with the sprite
  25735. * @param evt The original (browser) event
  25736. * @param additionalData additional data for the event
  25737. * @returns the new ActionEvent
  25738. */
  25739. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25740. /**
  25741. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25742. * @param scene the scene where the event occurred
  25743. * @param evt The original (browser) event
  25744. * @returns the new ActionEvent
  25745. */
  25746. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25747. /**
  25748. * Helper function to auto-create an ActionEvent from a primitive
  25749. * @param prim defines the target primitive
  25750. * @param pointerPos defines the pointer position
  25751. * @param evt The original (browser) event
  25752. * @param additionalData additional data for the event
  25753. * @returns the new ActionEvent
  25754. */
  25755. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25756. }
  25757. }
  25758. declare module "babylonjs/Actions/abstractActionManager" {
  25759. import { IDisposable } from "babylonjs/scene";
  25760. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25761. import { IAction } from "babylonjs/Actions/action";
  25762. import { Nullable } from "babylonjs/types";
  25763. /**
  25764. * Abstract class used to decouple action Manager from scene and meshes.
  25765. * Do not instantiate.
  25766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25767. */
  25768. export abstract class AbstractActionManager implements IDisposable {
  25769. /** Gets the list of active triggers */
  25770. static Triggers: {
  25771. [key: string]: number;
  25772. };
  25773. /** Gets the cursor to use when hovering items */
  25774. hoverCursor: string;
  25775. /** Gets the list of actions */
  25776. actions: IAction[];
  25777. /**
  25778. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25779. */
  25780. isRecursive: boolean;
  25781. /**
  25782. * Releases all associated resources
  25783. */
  25784. abstract dispose(): void;
  25785. /**
  25786. * Does this action manager has pointer triggers
  25787. */
  25788. abstract readonly hasPointerTriggers: boolean;
  25789. /**
  25790. * Does this action manager has pick triggers
  25791. */
  25792. abstract readonly hasPickTriggers: boolean;
  25793. /**
  25794. * Process a specific trigger
  25795. * @param trigger defines the trigger to process
  25796. * @param evt defines the event details to be processed
  25797. */
  25798. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25799. /**
  25800. * Does this action manager handles actions of any of the given triggers
  25801. * @param triggers defines the triggers to be tested
  25802. * @return a boolean indicating whether one (or more) of the triggers is handled
  25803. */
  25804. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25805. /**
  25806. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25807. * speed.
  25808. * @param triggerA defines the trigger to be tested
  25809. * @param triggerB defines the trigger to be tested
  25810. * @return a boolean indicating whether one (or more) of the triggers is handled
  25811. */
  25812. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25813. /**
  25814. * Does this action manager handles actions of a given trigger
  25815. * @param trigger defines the trigger to be tested
  25816. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25817. * @return whether the trigger is handled
  25818. */
  25819. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25820. /**
  25821. * Serialize this manager to a JSON object
  25822. * @param name defines the property name to store this manager
  25823. * @returns a JSON representation of this manager
  25824. */
  25825. abstract serialize(name: string): any;
  25826. /**
  25827. * Registers an action to this action manager
  25828. * @param action defines the action to be registered
  25829. * @return the action amended (prepared) after registration
  25830. */
  25831. abstract registerAction(action: IAction): Nullable<IAction>;
  25832. /**
  25833. * Unregisters an action to this action manager
  25834. * @param action defines the action to be unregistered
  25835. * @return a boolean indicating whether the action has been unregistered
  25836. */
  25837. abstract unregisterAction(action: IAction): Boolean;
  25838. /**
  25839. * Does exist one action manager with at least one trigger
  25840. **/
  25841. static readonly HasTriggers: boolean;
  25842. /**
  25843. * Does exist one action manager with at least one pick trigger
  25844. **/
  25845. static readonly HasPickTriggers: boolean;
  25846. /**
  25847. * Does exist one action manager that handles actions of a given trigger
  25848. * @param trigger defines the trigger to be tested
  25849. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25850. **/
  25851. static HasSpecificTrigger(trigger: number): boolean;
  25852. }
  25853. }
  25854. declare module "babylonjs/node" {
  25855. import { Scene } from "babylonjs/scene";
  25856. import { Nullable } from "babylonjs/types";
  25857. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25858. import { Engine } from "babylonjs/Engines/engine";
  25859. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25860. import { Observable } from "babylonjs/Misc/observable";
  25861. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25862. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25863. import { Animatable } from "babylonjs/Animations/animatable";
  25864. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25865. import { Animation } from "babylonjs/Animations/animation";
  25866. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25868. /**
  25869. * Defines how a node can be built from a string name.
  25870. */
  25871. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25872. /**
  25873. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25874. */
  25875. export class Node implements IBehaviorAware<Node> {
  25876. /** @hidden */
  25877. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25878. private static _NodeConstructors;
  25879. /**
  25880. * Add a new node constructor
  25881. * @param type defines the type name of the node to construct
  25882. * @param constructorFunc defines the constructor function
  25883. */
  25884. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25885. /**
  25886. * Returns a node constructor based on type name
  25887. * @param type defines the type name
  25888. * @param name defines the new node name
  25889. * @param scene defines the hosting scene
  25890. * @param options defines optional options to transmit to constructors
  25891. * @returns the new constructor or null
  25892. */
  25893. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25894. /**
  25895. * Gets or sets the name of the node
  25896. */
  25897. name: string;
  25898. /**
  25899. * Gets or sets the id of the node
  25900. */
  25901. id: string;
  25902. /**
  25903. * Gets or sets the unique id of the node
  25904. */
  25905. uniqueId: number;
  25906. /**
  25907. * Gets or sets a string used to store user defined state for the node
  25908. */
  25909. state: string;
  25910. /**
  25911. * Gets or sets an object used to store user defined information for the node
  25912. */
  25913. metadata: any;
  25914. /**
  25915. * For internal use only. Please do not use.
  25916. */
  25917. reservedDataStore: any;
  25918. /**
  25919. * List of inspectable custom properties (used by the Inspector)
  25920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25921. */
  25922. inspectableCustomProperties: IInspectable[];
  25923. /**
  25924. * Gets or sets a boolean used to define if the node must be serialized
  25925. */
  25926. doNotSerialize: boolean;
  25927. /** @hidden */
  25928. _isDisposed: boolean;
  25929. /**
  25930. * Gets a list of Animations associated with the node
  25931. */
  25932. animations: import("babylonjs/Animations/animation").Animation[];
  25933. protected _ranges: {
  25934. [name: string]: Nullable<AnimationRange>;
  25935. };
  25936. /**
  25937. * Callback raised when the node is ready to be used
  25938. */
  25939. onReady: Nullable<(node: Node) => void>;
  25940. private _isEnabled;
  25941. private _isParentEnabled;
  25942. private _isReady;
  25943. /** @hidden */
  25944. _currentRenderId: number;
  25945. private _parentUpdateId;
  25946. /** @hidden */
  25947. _childUpdateId: number;
  25948. /** @hidden */
  25949. _waitingParentId: Nullable<string>;
  25950. /** @hidden */
  25951. _scene: Scene;
  25952. /** @hidden */
  25953. _cache: any;
  25954. private _parentNode;
  25955. private _children;
  25956. /** @hidden */
  25957. _worldMatrix: Matrix;
  25958. /** @hidden */
  25959. _worldMatrixDeterminant: number;
  25960. /** @hidden */
  25961. _worldMatrixDeterminantIsDirty: boolean;
  25962. /** @hidden */
  25963. private _sceneRootNodesIndex;
  25964. /**
  25965. * Gets a boolean indicating if the node has been disposed
  25966. * @returns true if the node was disposed
  25967. */
  25968. isDisposed(): boolean;
  25969. /**
  25970. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25971. * @see https://doc.babylonjs.com/how_to/parenting
  25972. */
  25973. parent: Nullable<Node>;
  25974. private addToSceneRootNodes;
  25975. private removeFromSceneRootNodes;
  25976. private _animationPropertiesOverride;
  25977. /**
  25978. * Gets or sets the animation properties override
  25979. */
  25980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25981. /**
  25982. * Gets a string idenfifying the name of the class
  25983. * @returns "Node" string
  25984. */
  25985. getClassName(): string;
  25986. /** @hidden */
  25987. readonly _isNode: boolean;
  25988. /**
  25989. * An event triggered when the mesh is disposed
  25990. */
  25991. onDisposeObservable: Observable<Node>;
  25992. private _onDisposeObserver;
  25993. /**
  25994. * Sets a callback that will be raised when the node will be disposed
  25995. */
  25996. onDispose: () => void;
  25997. /**
  25998. * Creates a new Node
  25999. * @param name the name and id to be given to this node
  26000. * @param scene the scene this node will be added to
  26001. * @param addToRootNodes the node will be added to scene.rootNodes
  26002. */
  26003. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26004. /**
  26005. * Gets the scene of the node
  26006. * @returns a scene
  26007. */
  26008. getScene(): Scene;
  26009. /**
  26010. * Gets the engine of the node
  26011. * @returns a Engine
  26012. */
  26013. getEngine(): Engine;
  26014. private _behaviors;
  26015. /**
  26016. * Attach a behavior to the node
  26017. * @see http://doc.babylonjs.com/features/behaviour
  26018. * @param behavior defines the behavior to attach
  26019. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26020. * @returns the current Node
  26021. */
  26022. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26023. /**
  26024. * Remove an attached behavior
  26025. * @see http://doc.babylonjs.com/features/behaviour
  26026. * @param behavior defines the behavior to attach
  26027. * @returns the current Node
  26028. */
  26029. removeBehavior(behavior: Behavior<Node>): Node;
  26030. /**
  26031. * Gets the list of attached behaviors
  26032. * @see http://doc.babylonjs.com/features/behaviour
  26033. */
  26034. readonly behaviors: Behavior<Node>[];
  26035. /**
  26036. * Gets an attached behavior by name
  26037. * @param name defines the name of the behavior to look for
  26038. * @see http://doc.babylonjs.com/features/behaviour
  26039. * @returns null if behavior was not found else the requested behavior
  26040. */
  26041. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26042. /**
  26043. * Returns the latest update of the World matrix
  26044. * @returns a Matrix
  26045. */
  26046. getWorldMatrix(): Matrix;
  26047. /** @hidden */
  26048. _getWorldMatrixDeterminant(): number;
  26049. /**
  26050. * Returns directly the latest state of the mesh World matrix.
  26051. * A Matrix is returned.
  26052. */
  26053. readonly worldMatrixFromCache: Matrix;
  26054. /** @hidden */
  26055. _initCache(): void;
  26056. /** @hidden */
  26057. updateCache(force?: boolean): void;
  26058. /** @hidden */
  26059. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26060. /** @hidden */
  26061. _updateCache(ignoreParentClass?: boolean): void;
  26062. /** @hidden */
  26063. _isSynchronized(): boolean;
  26064. /** @hidden */
  26065. _markSyncedWithParent(): void;
  26066. /** @hidden */
  26067. isSynchronizedWithParent(): boolean;
  26068. /** @hidden */
  26069. isSynchronized(): boolean;
  26070. /**
  26071. * Is this node ready to be used/rendered
  26072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26073. * @return true if the node is ready
  26074. */
  26075. isReady(completeCheck?: boolean): boolean;
  26076. /**
  26077. * Is this node enabled?
  26078. * 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
  26079. * @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
  26080. * @return whether this node (and its parent) is enabled
  26081. */
  26082. isEnabled(checkAncestors?: boolean): boolean;
  26083. /** @hidden */
  26084. protected _syncParentEnabledState(): void;
  26085. /**
  26086. * Set the enabled state of this node
  26087. * @param value defines the new enabled state
  26088. */
  26089. setEnabled(value: boolean): void;
  26090. /**
  26091. * Is this node a descendant of the given node?
  26092. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26093. * @param ancestor defines the parent node to inspect
  26094. * @returns a boolean indicating if this node is a descendant of the given node
  26095. */
  26096. isDescendantOf(ancestor: Node): boolean;
  26097. /** @hidden */
  26098. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26099. /**
  26100. * Will return all nodes that have this node as ascendant
  26101. * @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
  26102. * @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
  26103. * @return all children nodes of all types
  26104. */
  26105. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26106. /**
  26107. * Get all child-meshes of this node
  26108. * @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)
  26109. * @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
  26110. * @returns an array of AbstractMesh
  26111. */
  26112. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26113. /**
  26114. * Get all direct children of this node
  26115. * @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
  26116. * @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)
  26117. * @returns an array of Node
  26118. */
  26119. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26120. /** @hidden */
  26121. _setReady(state: boolean): void;
  26122. /**
  26123. * Get an animation by name
  26124. * @param name defines the name of the animation to look for
  26125. * @returns null if not found else the requested animation
  26126. */
  26127. getAnimationByName(name: string): Nullable<Animation>;
  26128. /**
  26129. * Creates an animation range for this node
  26130. * @param name defines the name of the range
  26131. * @param from defines the starting key
  26132. * @param to defines the end key
  26133. */
  26134. createAnimationRange(name: string, from: number, to: number): void;
  26135. /**
  26136. * Delete a specific animation range
  26137. * @param name defines the name of the range to delete
  26138. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26139. */
  26140. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26141. /**
  26142. * Get an animation range by name
  26143. * @param name defines the name of the animation range to look for
  26144. * @returns null if not found else the requested animation range
  26145. */
  26146. getAnimationRange(name: string): Nullable<AnimationRange>;
  26147. /**
  26148. * Gets the list of all animation ranges defined on this node
  26149. * @returns an array
  26150. */
  26151. getAnimationRanges(): Nullable<AnimationRange>[];
  26152. /**
  26153. * Will start the animation sequence
  26154. * @param name defines the range frames for animation sequence
  26155. * @param loop defines if the animation should loop (false by default)
  26156. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26157. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26158. * @returns the object created for this animation. If range does not exist, it will return null
  26159. */
  26160. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26161. /**
  26162. * Serialize animation ranges into a JSON compatible object
  26163. * @returns serialization object
  26164. */
  26165. serializeAnimationRanges(): any;
  26166. /**
  26167. * Computes the world matrix of the node
  26168. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26169. * @returns the world matrix
  26170. */
  26171. computeWorldMatrix(force?: boolean): Matrix;
  26172. /**
  26173. * Releases resources associated with this node.
  26174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26176. */
  26177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26178. /**
  26179. * Parse animation range data from a serialization object and store them into a given node
  26180. * @param node defines where to store the animation ranges
  26181. * @param parsedNode defines the serialization object to read data from
  26182. * @param scene defines the hosting scene
  26183. */
  26184. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26185. /**
  26186. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26187. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26188. * @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
  26189. * @returns the new bounding vectors
  26190. */
  26191. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26192. min: Vector3;
  26193. max: Vector3;
  26194. };
  26195. }
  26196. }
  26197. declare module "babylonjs/Animations/animation" {
  26198. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26199. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26200. import { Nullable } from "babylonjs/types";
  26201. import { Scene } from "babylonjs/scene";
  26202. import { IAnimatable } from "babylonjs/Misc/tools";
  26203. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26204. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26205. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26206. import { Node } from "babylonjs/node";
  26207. import { Animatable } from "babylonjs/Animations/animatable";
  26208. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26209. /**
  26210. * @hidden
  26211. */
  26212. export class _IAnimationState {
  26213. key: number;
  26214. repeatCount: number;
  26215. workValue?: any;
  26216. loopMode?: number;
  26217. offsetValue?: any;
  26218. highLimitValue?: any;
  26219. }
  26220. /**
  26221. * Class used to store any kind of animation
  26222. */
  26223. export class Animation {
  26224. /**Name of the animation */
  26225. name: string;
  26226. /**Property to animate */
  26227. targetProperty: string;
  26228. /**The frames per second of the animation */
  26229. framePerSecond: number;
  26230. /**The data type of the animation */
  26231. dataType: number;
  26232. /**The loop mode of the animation */
  26233. loopMode?: number | undefined;
  26234. /**Specifies if blending should be enabled */
  26235. enableBlending?: boolean | undefined;
  26236. /**
  26237. * Use matrix interpolation instead of using direct key value when animating matrices
  26238. */
  26239. static AllowMatricesInterpolation: boolean;
  26240. /**
  26241. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26242. */
  26243. static AllowMatrixDecomposeForInterpolation: boolean;
  26244. /**
  26245. * Stores the key frames of the animation
  26246. */
  26247. private _keys;
  26248. /**
  26249. * Stores the easing function of the animation
  26250. */
  26251. private _easingFunction;
  26252. /**
  26253. * @hidden Internal use only
  26254. */
  26255. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26256. /**
  26257. * The set of event that will be linked to this animation
  26258. */
  26259. private _events;
  26260. /**
  26261. * Stores an array of target property paths
  26262. */
  26263. targetPropertyPath: string[];
  26264. /**
  26265. * Stores the blending speed of the animation
  26266. */
  26267. blendingSpeed: number;
  26268. /**
  26269. * Stores the animation ranges for the animation
  26270. */
  26271. private _ranges;
  26272. /**
  26273. * @hidden Internal use
  26274. */
  26275. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26276. /**
  26277. * Sets up an animation
  26278. * @param property The property to animate
  26279. * @param animationType The animation type to apply
  26280. * @param framePerSecond The frames per second of the animation
  26281. * @param easingFunction The easing function used in the animation
  26282. * @returns The created animation
  26283. */
  26284. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26285. /**
  26286. * Create and start an animation on a node
  26287. * @param name defines the name of the global animation that will be run on all nodes
  26288. * @param node defines the root node where the animation will take place
  26289. * @param targetProperty defines property to animate
  26290. * @param framePerSecond defines the number of frame per second yo use
  26291. * @param totalFrame defines the number of frames in total
  26292. * @param from defines the initial value
  26293. * @param to defines the final value
  26294. * @param loopMode defines which loop mode you want to use (off by default)
  26295. * @param easingFunction defines the easing function to use (linear by default)
  26296. * @param onAnimationEnd defines the callback to call when animation end
  26297. * @returns the animatable created for this animation
  26298. */
  26299. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26300. /**
  26301. * Create and start an animation on a node and its descendants
  26302. * @param name defines the name of the global animation that will be run on all nodes
  26303. * @param node defines the root node where the animation will take place
  26304. * @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
  26305. * @param targetProperty defines property to animate
  26306. * @param framePerSecond defines the number of frame per second to use
  26307. * @param totalFrame defines the number of frames in total
  26308. * @param from defines the initial value
  26309. * @param to defines the final value
  26310. * @param loopMode defines which loop mode you want to use (off by default)
  26311. * @param easingFunction defines the easing function to use (linear by default)
  26312. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26313. * @returns the list of animatables created for all nodes
  26314. * @example https://www.babylonjs-playground.com/#MH0VLI
  26315. */
  26316. 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[]>;
  26317. /**
  26318. * Creates a new animation, merges it with the existing animations and starts it
  26319. * @param name Name of the animation
  26320. * @param node Node which contains the scene that begins the animations
  26321. * @param targetProperty Specifies which property to animate
  26322. * @param framePerSecond The frames per second of the animation
  26323. * @param totalFrame The total number of frames
  26324. * @param from The frame at the beginning of the animation
  26325. * @param to The frame at the end of the animation
  26326. * @param loopMode Specifies the loop mode of the animation
  26327. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26328. * @param onAnimationEnd Callback to run once the animation is complete
  26329. * @returns Nullable animation
  26330. */
  26331. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26332. /**
  26333. * Transition property of an host to the target Value
  26334. * @param property The property to transition
  26335. * @param targetValue The target Value of the property
  26336. * @param host The object where the property to animate belongs
  26337. * @param scene Scene used to run the animation
  26338. * @param frameRate Framerate (in frame/s) to use
  26339. * @param transition The transition type we want to use
  26340. * @param duration The duration of the animation, in milliseconds
  26341. * @param onAnimationEnd Callback trigger at the end of the animation
  26342. * @returns Nullable animation
  26343. */
  26344. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26345. /**
  26346. * Return the array of runtime animations currently using this animation
  26347. */
  26348. readonly runtimeAnimations: RuntimeAnimation[];
  26349. /**
  26350. * Specifies if any of the runtime animations are currently running
  26351. */
  26352. readonly hasRunningRuntimeAnimations: boolean;
  26353. /**
  26354. * Initializes the animation
  26355. * @param name Name of the animation
  26356. * @param targetProperty Property to animate
  26357. * @param framePerSecond The frames per second of the animation
  26358. * @param dataType The data type of the animation
  26359. * @param loopMode The loop mode of the animation
  26360. * @param enableBlending Specifies if blending should be enabled
  26361. */
  26362. constructor(
  26363. /**Name of the animation */
  26364. name: string,
  26365. /**Property to animate */
  26366. targetProperty: string,
  26367. /**The frames per second of the animation */
  26368. framePerSecond: number,
  26369. /**The data type of the animation */
  26370. dataType: number,
  26371. /**The loop mode of the animation */
  26372. loopMode?: number | undefined,
  26373. /**Specifies if blending should be enabled */
  26374. enableBlending?: boolean | undefined);
  26375. /**
  26376. * Converts the animation to a string
  26377. * @param fullDetails support for multiple levels of logging within scene loading
  26378. * @returns String form of the animation
  26379. */
  26380. toString(fullDetails?: boolean): string;
  26381. /**
  26382. * Add an event to this animation
  26383. * @param event Event to add
  26384. */
  26385. addEvent(event: AnimationEvent): void;
  26386. /**
  26387. * Remove all events found at the given frame
  26388. * @param frame The frame to remove events from
  26389. */
  26390. removeEvents(frame: number): void;
  26391. /**
  26392. * Retrieves all the events from the animation
  26393. * @returns Events from the animation
  26394. */
  26395. getEvents(): AnimationEvent[];
  26396. /**
  26397. * Creates an animation range
  26398. * @param name Name of the animation range
  26399. * @param from Starting frame of the animation range
  26400. * @param to Ending frame of the animation
  26401. */
  26402. createRange(name: string, from: number, to: number): void;
  26403. /**
  26404. * Deletes an animation range by name
  26405. * @param name Name of the animation range to delete
  26406. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26407. */
  26408. deleteRange(name: string, deleteFrames?: boolean): void;
  26409. /**
  26410. * Gets the animation range by name, or null if not defined
  26411. * @param name Name of the animation range
  26412. * @returns Nullable animation range
  26413. */
  26414. getRange(name: string): Nullable<AnimationRange>;
  26415. /**
  26416. * Gets the key frames from the animation
  26417. * @returns The key frames of the animation
  26418. */
  26419. getKeys(): Array<IAnimationKey>;
  26420. /**
  26421. * Gets the highest frame rate of the animation
  26422. * @returns Highest frame rate of the animation
  26423. */
  26424. getHighestFrame(): number;
  26425. /**
  26426. * Gets the easing function of the animation
  26427. * @returns Easing function of the animation
  26428. */
  26429. getEasingFunction(): IEasingFunction;
  26430. /**
  26431. * Sets the easing function of the animation
  26432. * @param easingFunction A custom mathematical formula for animation
  26433. */
  26434. setEasingFunction(easingFunction: EasingFunction): void;
  26435. /**
  26436. * Interpolates a scalar linearly
  26437. * @param startValue Start value of the animation curve
  26438. * @param endValue End value of the animation curve
  26439. * @param gradient Scalar amount to interpolate
  26440. * @returns Interpolated scalar value
  26441. */
  26442. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26443. /**
  26444. * Interpolates a scalar cubically
  26445. * @param startValue Start value of the animation curve
  26446. * @param outTangent End tangent of the animation
  26447. * @param endValue End value of the animation curve
  26448. * @param inTangent Start tangent of the animation curve
  26449. * @param gradient Scalar amount to interpolate
  26450. * @returns Interpolated scalar value
  26451. */
  26452. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26453. /**
  26454. * Interpolates a quaternion using a spherical linear interpolation
  26455. * @param startValue Start value of the animation curve
  26456. * @param endValue End value of the animation curve
  26457. * @param gradient Scalar amount to interpolate
  26458. * @returns Interpolated quaternion value
  26459. */
  26460. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26461. /**
  26462. * Interpolates a quaternion cubically
  26463. * @param startValue Start value of the animation curve
  26464. * @param outTangent End tangent of the animation curve
  26465. * @param endValue End value of the animation curve
  26466. * @param inTangent Start tangent of the animation curve
  26467. * @param gradient Scalar amount to interpolate
  26468. * @returns Interpolated quaternion value
  26469. */
  26470. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26471. /**
  26472. * Interpolates a Vector3 linearl
  26473. * @param startValue Start value of the animation curve
  26474. * @param endValue End value of the animation curve
  26475. * @param gradient Scalar amount to interpolate
  26476. * @returns Interpolated scalar value
  26477. */
  26478. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26479. /**
  26480. * Interpolates a Vector3 cubically
  26481. * @param startValue Start value of the animation curve
  26482. * @param outTangent End tangent of the animation
  26483. * @param endValue End value of the animation curve
  26484. * @param inTangent Start tangent of the animation curve
  26485. * @param gradient Scalar amount to interpolate
  26486. * @returns InterpolatedVector3 value
  26487. */
  26488. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26489. /**
  26490. * Interpolates a Vector2 linearly
  26491. * @param startValue Start value of the animation curve
  26492. * @param endValue End value of the animation curve
  26493. * @param gradient Scalar amount to interpolate
  26494. * @returns Interpolated Vector2 value
  26495. */
  26496. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26497. /**
  26498. * Interpolates a Vector2 cubically
  26499. * @param startValue Start value of the animation curve
  26500. * @param outTangent End tangent of the animation
  26501. * @param endValue End value of the animation curve
  26502. * @param inTangent Start tangent of the animation curve
  26503. * @param gradient Scalar amount to interpolate
  26504. * @returns Interpolated Vector2 value
  26505. */
  26506. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26507. /**
  26508. * Interpolates a size linearly
  26509. * @param startValue Start value of the animation curve
  26510. * @param endValue End value of the animation curve
  26511. * @param gradient Scalar amount to interpolate
  26512. * @returns Interpolated Size value
  26513. */
  26514. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26515. /**
  26516. * Interpolates a Color3 linearly
  26517. * @param startValue Start value of the animation curve
  26518. * @param endValue End value of the animation curve
  26519. * @param gradient Scalar amount to interpolate
  26520. * @returns Interpolated Color3 value
  26521. */
  26522. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26523. /**
  26524. * @hidden Internal use only
  26525. */
  26526. _getKeyValue(value: any): any;
  26527. /**
  26528. * @hidden Internal use only
  26529. */
  26530. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26531. /**
  26532. * Defines the function to use to interpolate matrices
  26533. * @param startValue defines the start matrix
  26534. * @param endValue defines the end matrix
  26535. * @param gradient defines the gradient between both matrices
  26536. * @param result defines an optional target matrix where to store the interpolation
  26537. * @returns the interpolated matrix
  26538. */
  26539. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26540. /**
  26541. * Makes a copy of the animation
  26542. * @returns Cloned animation
  26543. */
  26544. clone(): Animation;
  26545. /**
  26546. * Sets the key frames of the animation
  26547. * @param values The animation key frames to set
  26548. */
  26549. setKeys(values: Array<IAnimationKey>): void;
  26550. /**
  26551. * Serializes the animation to an object
  26552. * @returns Serialized object
  26553. */
  26554. serialize(): any;
  26555. /**
  26556. * Float animation type
  26557. */
  26558. private static _ANIMATIONTYPE_FLOAT;
  26559. /**
  26560. * Vector3 animation type
  26561. */
  26562. private static _ANIMATIONTYPE_VECTOR3;
  26563. /**
  26564. * Quaternion animation type
  26565. */
  26566. private static _ANIMATIONTYPE_QUATERNION;
  26567. /**
  26568. * Matrix animation type
  26569. */
  26570. private static _ANIMATIONTYPE_MATRIX;
  26571. /**
  26572. * Color3 animation type
  26573. */
  26574. private static _ANIMATIONTYPE_COLOR3;
  26575. /**
  26576. * Vector2 animation type
  26577. */
  26578. private static _ANIMATIONTYPE_VECTOR2;
  26579. /**
  26580. * Size animation type
  26581. */
  26582. private static _ANIMATIONTYPE_SIZE;
  26583. /**
  26584. * Relative Loop Mode
  26585. */
  26586. private static _ANIMATIONLOOPMODE_RELATIVE;
  26587. /**
  26588. * Cycle Loop Mode
  26589. */
  26590. private static _ANIMATIONLOOPMODE_CYCLE;
  26591. /**
  26592. * Constant Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_CONSTANT;
  26595. /**
  26596. * Get the float animation type
  26597. */
  26598. static readonly ANIMATIONTYPE_FLOAT: number;
  26599. /**
  26600. * Get the Vector3 animation type
  26601. */
  26602. static readonly ANIMATIONTYPE_VECTOR3: number;
  26603. /**
  26604. * Get the Vector2 animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_VECTOR2: number;
  26607. /**
  26608. * Get the Size animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_SIZE: number;
  26611. /**
  26612. * Get the Quaternion animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_QUATERNION: number;
  26615. /**
  26616. * Get the Matrix animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_MATRIX: number;
  26619. /**
  26620. * Get the Color3 animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_COLOR3: number;
  26623. /**
  26624. * Get the Relative Loop Mode
  26625. */
  26626. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26627. /**
  26628. * Get the Cycle Loop Mode
  26629. */
  26630. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26631. /**
  26632. * Get the Constant Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26635. /** @hidden */
  26636. static _UniversalLerp(left: any, right: any, amount: number): any;
  26637. /**
  26638. * Parses an animation object and creates an animation
  26639. * @param parsedAnimation Parsed animation object
  26640. * @returns Animation object
  26641. */
  26642. static Parse(parsedAnimation: any): Animation;
  26643. /**
  26644. * Appends the serialized animations from the source animations
  26645. * @param source Source containing the animations
  26646. * @param destination Target to store the animations
  26647. */
  26648. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26649. }
  26650. }
  26651. declare module "babylonjs/Materials/Textures/baseTexture" {
  26652. import { Observable } from "babylonjs/Misc/observable";
  26653. import { IAnimatable } from "babylonjs/Misc/tools";
  26654. import { Nullable } from "babylonjs/types";
  26655. import { Scene } from "babylonjs/scene";
  26656. import { Matrix, ISize } from "babylonjs/Maths/math";
  26657. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26659. /**
  26660. * Base class of all the textures in babylon.
  26661. * It groups all the common properties the materials, post process, lights... might need
  26662. * in order to make a correct use of the texture.
  26663. */
  26664. export class BaseTexture implements IAnimatable {
  26665. /**
  26666. * Default anisotropic filtering level for the application.
  26667. * It is set to 4 as a good tradeoff between perf and quality.
  26668. */
  26669. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26670. /**
  26671. * Gets or sets the unique id of the texture
  26672. */
  26673. uniqueId: number;
  26674. /**
  26675. * Define the name of the texture.
  26676. */
  26677. name: string;
  26678. /**
  26679. * Gets or sets an object used to store user defined information.
  26680. */
  26681. metadata: any;
  26682. /**
  26683. * For internal use only. Please do not use.
  26684. */
  26685. reservedDataStore: any;
  26686. private _hasAlpha;
  26687. /**
  26688. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26689. */
  26690. hasAlpha: boolean;
  26691. /**
  26692. * Defines if the alpha value should be determined via the rgb values.
  26693. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26694. */
  26695. getAlphaFromRGB: boolean;
  26696. /**
  26697. * Intensity or strength of the texture.
  26698. * It is commonly used by materials to fine tune the intensity of the texture
  26699. */
  26700. level: number;
  26701. /**
  26702. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26703. * This is part of the texture as textures usually maps to one uv set.
  26704. */
  26705. coordinatesIndex: number;
  26706. private _coordinatesMode;
  26707. /**
  26708. * How a texture is mapped.
  26709. *
  26710. * | Value | Type | Description |
  26711. * | ----- | ----------------------------------- | ----------- |
  26712. * | 0 | EXPLICIT_MODE | |
  26713. * | 1 | SPHERICAL_MODE | |
  26714. * | 2 | PLANAR_MODE | |
  26715. * | 3 | CUBIC_MODE | |
  26716. * | 4 | PROJECTION_MODE | |
  26717. * | 5 | SKYBOX_MODE | |
  26718. * | 6 | INVCUBIC_MODE | |
  26719. * | 7 | EQUIRECTANGULAR_MODE | |
  26720. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26721. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26722. */
  26723. coordinatesMode: number;
  26724. /**
  26725. * | Value | Type | Description |
  26726. * | ----- | ------------------ | ----------- |
  26727. * | 0 | CLAMP_ADDRESSMODE | |
  26728. * | 1 | WRAP_ADDRESSMODE | |
  26729. * | 2 | MIRROR_ADDRESSMODE | |
  26730. */
  26731. wrapU: number;
  26732. /**
  26733. * | Value | Type | Description |
  26734. * | ----- | ------------------ | ----------- |
  26735. * | 0 | CLAMP_ADDRESSMODE | |
  26736. * | 1 | WRAP_ADDRESSMODE | |
  26737. * | 2 | MIRROR_ADDRESSMODE | |
  26738. */
  26739. wrapV: number;
  26740. /**
  26741. * | Value | Type | Description |
  26742. * | ----- | ------------------ | ----------- |
  26743. * | 0 | CLAMP_ADDRESSMODE | |
  26744. * | 1 | WRAP_ADDRESSMODE | |
  26745. * | 2 | MIRROR_ADDRESSMODE | |
  26746. */
  26747. wrapR: number;
  26748. /**
  26749. * With compliant hardware and browser (supporting anisotropic filtering)
  26750. * this defines the level of anisotropic filtering in the texture.
  26751. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26752. */
  26753. anisotropicFilteringLevel: number;
  26754. /**
  26755. * Define if the texture is a cube texture or if false a 2d texture.
  26756. */
  26757. isCube: boolean;
  26758. /**
  26759. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26760. */
  26761. is3D: boolean;
  26762. /**
  26763. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26764. * HDR texture are usually stored in linear space.
  26765. * This only impacts the PBR and Background materials
  26766. */
  26767. gammaSpace: boolean;
  26768. /**
  26769. * Gets whether or not the texture contains RGBD data.
  26770. */
  26771. readonly isRGBD: boolean;
  26772. /**
  26773. * Is Z inverted in the texture (useful in a cube texture).
  26774. */
  26775. invertZ: boolean;
  26776. /**
  26777. * Are mip maps generated for this texture or not.
  26778. */
  26779. readonly noMipmap: boolean;
  26780. /**
  26781. * @hidden
  26782. */
  26783. lodLevelInAlpha: boolean;
  26784. /**
  26785. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26786. */
  26787. lodGenerationOffset: number;
  26788. /**
  26789. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26790. */
  26791. lodGenerationScale: number;
  26792. /**
  26793. * Define if the texture is a render target.
  26794. */
  26795. isRenderTarget: boolean;
  26796. /**
  26797. * Define the unique id of the texture in the scene.
  26798. */
  26799. readonly uid: string;
  26800. /**
  26801. * Return a string representation of the texture.
  26802. * @returns the texture as a string
  26803. */
  26804. toString(): string;
  26805. /**
  26806. * Get the class name of the texture.
  26807. * @returns "BaseTexture"
  26808. */
  26809. getClassName(): string;
  26810. /**
  26811. * Define the list of animation attached to the texture.
  26812. */
  26813. animations: import("babylonjs/Animations/animation").Animation[];
  26814. /**
  26815. * An event triggered when the texture is disposed.
  26816. */
  26817. onDisposeObservable: Observable<BaseTexture>;
  26818. private _onDisposeObserver;
  26819. /**
  26820. * Callback triggered when the texture has been disposed.
  26821. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26822. */
  26823. onDispose: () => void;
  26824. /**
  26825. * Define the current state of the loading sequence when in delayed load mode.
  26826. */
  26827. delayLoadState: number;
  26828. private _scene;
  26829. /** @hidden */
  26830. _texture: Nullable<InternalTexture>;
  26831. private _uid;
  26832. /**
  26833. * Define if the texture is preventinga material to render or not.
  26834. * If not and the texture is not ready, the engine will use a default black texture instead.
  26835. */
  26836. readonly isBlocking: boolean;
  26837. /**
  26838. * Instantiates a new BaseTexture.
  26839. * Base class of all the textures in babylon.
  26840. * It groups all the common properties the materials, post process, lights... might need
  26841. * in order to make a correct use of the texture.
  26842. * @param scene Define the scene the texture blongs to
  26843. */
  26844. constructor(scene: Nullable<Scene>);
  26845. /**
  26846. * Get the scene the texture belongs to.
  26847. * @returns the scene or null if undefined
  26848. */
  26849. getScene(): Nullable<Scene>;
  26850. /**
  26851. * Get the texture transform matrix used to offset tile the texture for istance.
  26852. * @returns the transformation matrix
  26853. */
  26854. getTextureMatrix(): Matrix;
  26855. /**
  26856. * Get the texture reflection matrix used to rotate/transform the reflection.
  26857. * @returns the reflection matrix
  26858. */
  26859. getReflectionTextureMatrix(): Matrix;
  26860. /**
  26861. * Get the underlying lower level texture from Babylon.
  26862. * @returns the insternal texture
  26863. */
  26864. getInternalTexture(): Nullable<InternalTexture>;
  26865. /**
  26866. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26867. * @returns true if ready or not blocking
  26868. */
  26869. isReadyOrNotBlocking(): boolean;
  26870. /**
  26871. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26872. * @returns true if fully ready
  26873. */
  26874. isReady(): boolean;
  26875. private _cachedSize;
  26876. /**
  26877. * Get the size of the texture.
  26878. * @returns the texture size.
  26879. */
  26880. getSize(): ISize;
  26881. /**
  26882. * Get the base size of the texture.
  26883. * It can be different from the size if the texture has been resized for POT for instance
  26884. * @returns the base size
  26885. */
  26886. getBaseSize(): ISize;
  26887. /**
  26888. * Update the sampling mode of the texture.
  26889. * Default is Trilinear mode.
  26890. *
  26891. * | Value | Type | Description |
  26892. * | ----- | ------------------ | ----------- |
  26893. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26894. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26895. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26896. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26897. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26898. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26899. * | 7 | NEAREST_LINEAR | |
  26900. * | 8 | NEAREST_NEAREST | |
  26901. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26902. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26903. * | 11 | LINEAR_LINEAR | |
  26904. * | 12 | LINEAR_NEAREST | |
  26905. *
  26906. * > _mag_: magnification filter (close to the viewer)
  26907. * > _min_: minification filter (far from the viewer)
  26908. * > _mip_: filter used between mip map levels
  26909. *@param samplingMode Define the new sampling mode of the texture
  26910. */
  26911. updateSamplingMode(samplingMode: number): void;
  26912. /**
  26913. * Scales the texture if is `canRescale()`
  26914. * @param ratio the resize factor we want to use to rescale
  26915. */
  26916. scale(ratio: number): void;
  26917. /**
  26918. * Get if the texture can rescale.
  26919. */
  26920. readonly canRescale: boolean;
  26921. /** @hidden */
  26922. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26923. /** @hidden */
  26924. _rebuild(): void;
  26925. /**
  26926. * Triggers the load sequence in delayed load mode.
  26927. */
  26928. delayLoad(): void;
  26929. /**
  26930. * Clones the texture.
  26931. * @returns the cloned texture
  26932. */
  26933. clone(): Nullable<BaseTexture>;
  26934. /**
  26935. * Get the texture underlying type (INT, FLOAT...)
  26936. */
  26937. readonly textureType: number;
  26938. /**
  26939. * Get the texture underlying format (RGB, RGBA...)
  26940. */
  26941. readonly textureFormat: number;
  26942. /**
  26943. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26944. * This will returns an RGBA array buffer containing either in values (0-255) or
  26945. * float values (0-1) depending of the underlying buffer type.
  26946. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26947. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26948. * @param buffer defines a user defined buffer to fill with data (can be null)
  26949. * @returns The Array buffer containing the pixels data.
  26950. */
  26951. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26952. /**
  26953. * Release and destroy the underlying lower level texture aka internalTexture.
  26954. */
  26955. releaseInternalTexture(): void;
  26956. /**
  26957. * Get the polynomial representation of the texture data.
  26958. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26959. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26960. */
  26961. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26962. /** @hidden */
  26963. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26964. /** @hidden */
  26965. readonly _lodTextureMid: Nullable<BaseTexture>;
  26966. /** @hidden */
  26967. readonly _lodTextureLow: Nullable<BaseTexture>;
  26968. /**
  26969. * Dispose the texture and release its associated resources.
  26970. */
  26971. dispose(): void;
  26972. /**
  26973. * Serialize the texture into a JSON representation that can be parsed later on.
  26974. * @returns the JSON representation of the texture
  26975. */
  26976. serialize(): any;
  26977. /**
  26978. * Helper function to be called back once a list of texture contains only ready textures.
  26979. * @param textures Define the list of textures to wait for
  26980. * @param callback Define the callback triggered once the entire list will be ready
  26981. */
  26982. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26983. }
  26984. }
  26985. declare module "babylonjs/Materials/uniformBuffer" {
  26986. import { Nullable, FloatArray } from "babylonjs/types";
  26987. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26988. import { Engine } from "babylonjs/Engines/engine";
  26989. import { Effect } from "babylonjs/Materials/effect";
  26990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26992. /**
  26993. * Uniform buffer objects.
  26994. *
  26995. * Handles blocks of uniform on the GPU.
  26996. *
  26997. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26998. *
  26999. * For more information, please refer to :
  27000. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27001. */
  27002. export class UniformBuffer {
  27003. private _engine;
  27004. private _buffer;
  27005. private _data;
  27006. private _bufferData;
  27007. private _dynamic?;
  27008. private _uniformLocations;
  27009. private _uniformSizes;
  27010. private _uniformLocationPointer;
  27011. private _needSync;
  27012. private _noUBO;
  27013. private _currentEffect;
  27014. private static _MAX_UNIFORM_SIZE;
  27015. private static _tempBuffer;
  27016. /**
  27017. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27018. * This is dynamic to allow compat with webgl 1 and 2.
  27019. * You will need to pass the name of the uniform as well as the value.
  27020. */
  27021. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27022. /**
  27023. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27024. * This is dynamic to allow compat with webgl 1 and 2.
  27025. * You will need to pass the name of the uniform as well as the value.
  27026. */
  27027. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27028. /**
  27029. * Lambda to Update a single float in a uniform buffer.
  27030. * This is dynamic to allow compat with webgl 1 and 2.
  27031. * You will need to pass the name of the uniform as well as the value.
  27032. */
  27033. updateFloat: (name: string, x: number) => void;
  27034. /**
  27035. * Lambda to Update a vec2 of float in a uniform buffer.
  27036. * This is dynamic to allow compat with webgl 1 and 2.
  27037. * You will need to pass the name of the uniform as well as the value.
  27038. */
  27039. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27040. /**
  27041. * Lambda to Update a vec3 of float in a uniform buffer.
  27042. * This is dynamic to allow compat with webgl 1 and 2.
  27043. * You will need to pass the name of the uniform as well as the value.
  27044. */
  27045. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27046. /**
  27047. * Lambda to Update a vec4 of float in a uniform buffer.
  27048. * This is dynamic to allow compat with webgl 1 and 2.
  27049. * You will need to pass the name of the uniform as well as the value.
  27050. */
  27051. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27052. /**
  27053. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27054. * This is dynamic to allow compat with webgl 1 and 2.
  27055. * You will need to pass the name of the uniform as well as the value.
  27056. */
  27057. updateMatrix: (name: string, mat: Matrix) => void;
  27058. /**
  27059. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27060. * This is dynamic to allow compat with webgl 1 and 2.
  27061. * You will need to pass the name of the uniform as well as the value.
  27062. */
  27063. updateVector3: (name: string, vector: Vector3) => void;
  27064. /**
  27065. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27066. * This is dynamic to allow compat with webgl 1 and 2.
  27067. * You will need to pass the name of the uniform as well as the value.
  27068. */
  27069. updateVector4: (name: string, vector: Vector4) => void;
  27070. /**
  27071. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27072. * This is dynamic to allow compat with webgl 1 and 2.
  27073. * You will need to pass the name of the uniform as well as the value.
  27074. */
  27075. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27076. /**
  27077. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27078. * This is dynamic to allow compat with webgl 1 and 2.
  27079. * You will need to pass the name of the uniform as well as the value.
  27080. */
  27081. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27082. /**
  27083. * Instantiates a new Uniform buffer objects.
  27084. *
  27085. * Handles blocks of uniform on the GPU.
  27086. *
  27087. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27088. *
  27089. * For more information, please refer to :
  27090. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27091. * @param engine Define the engine the buffer is associated with
  27092. * @param data Define the data contained in the buffer
  27093. * @param dynamic Define if the buffer is updatable
  27094. */
  27095. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27096. /**
  27097. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27098. * or just falling back on setUniformXXX calls.
  27099. */
  27100. readonly useUbo: boolean;
  27101. /**
  27102. * Indicates if the WebGL underlying uniform buffer is in sync
  27103. * with the javascript cache data.
  27104. */
  27105. readonly isSync: boolean;
  27106. /**
  27107. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27108. * Also, a dynamic UniformBuffer will disable cache verification and always
  27109. * update the underlying WebGL uniform buffer to the GPU.
  27110. * @returns if Dynamic, otherwise false
  27111. */
  27112. isDynamic(): boolean;
  27113. /**
  27114. * The data cache on JS side.
  27115. * @returns the underlying data as a float array
  27116. */
  27117. getData(): Float32Array;
  27118. /**
  27119. * The underlying WebGL Uniform buffer.
  27120. * @returns the webgl buffer
  27121. */
  27122. getBuffer(): Nullable<DataBuffer>;
  27123. /**
  27124. * std140 layout specifies how to align data within an UBO structure.
  27125. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27126. * for specs.
  27127. */
  27128. private _fillAlignment;
  27129. /**
  27130. * Adds an uniform in the buffer.
  27131. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27132. * for the layout to be correct !
  27133. * @param name Name of the uniform, as used in the uniform block in the shader.
  27134. * @param size Data size, or data directly.
  27135. */
  27136. addUniform(name: string, size: number | number[]): void;
  27137. /**
  27138. * Adds a Matrix 4x4 to the uniform buffer.
  27139. * @param name Name of the uniform, as used in the uniform block in the shader.
  27140. * @param mat A 4x4 matrix.
  27141. */
  27142. addMatrix(name: string, mat: Matrix): void;
  27143. /**
  27144. * Adds a vec2 to the uniform buffer.
  27145. * @param name Name of the uniform, as used in the uniform block in the shader.
  27146. * @param x Define the x component value of the vec2
  27147. * @param y Define the y component value of the vec2
  27148. */
  27149. addFloat2(name: string, x: number, y: number): void;
  27150. /**
  27151. * Adds a vec3 to the uniform buffer.
  27152. * @param name Name of the uniform, as used in the uniform block in the shader.
  27153. * @param x Define the x component value of the vec3
  27154. * @param y Define the y component value of the vec3
  27155. * @param z Define the z component value of the vec3
  27156. */
  27157. addFloat3(name: string, x: number, y: number, z: number): void;
  27158. /**
  27159. * Adds a vec3 to the uniform buffer.
  27160. * @param name Name of the uniform, as used in the uniform block in the shader.
  27161. * @param color Define the vec3 from a Color
  27162. */
  27163. addColor3(name: string, color: Color3): void;
  27164. /**
  27165. * Adds a vec4 to the uniform buffer.
  27166. * @param name Name of the uniform, as used in the uniform block in the shader.
  27167. * @param color Define the rgb components from a Color
  27168. * @param alpha Define the a component of the vec4
  27169. */
  27170. addColor4(name: string, color: Color3, alpha: number): void;
  27171. /**
  27172. * Adds a vec3 to the uniform buffer.
  27173. * @param name Name of the uniform, as used in the uniform block in the shader.
  27174. * @param vector Define the vec3 components from a Vector
  27175. */
  27176. addVector3(name: string, vector: Vector3): void;
  27177. /**
  27178. * Adds a Matrix 3x3 to the uniform buffer.
  27179. * @param name Name of the uniform, as used in the uniform block in the shader.
  27180. */
  27181. addMatrix3x3(name: string): void;
  27182. /**
  27183. * Adds a Matrix 2x2 to the uniform buffer.
  27184. * @param name Name of the uniform, as used in the uniform block in the shader.
  27185. */
  27186. addMatrix2x2(name: string): void;
  27187. /**
  27188. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27189. */
  27190. create(): void;
  27191. /** @hidden */
  27192. _rebuild(): void;
  27193. /**
  27194. * Updates the WebGL Uniform Buffer on the GPU.
  27195. * If the `dynamic` flag is set to true, no cache comparison is done.
  27196. * Otherwise, the buffer will be updated only if the cache differs.
  27197. */
  27198. update(): void;
  27199. /**
  27200. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27201. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27202. * @param data Define the flattened data
  27203. * @param size Define the size of the data.
  27204. */
  27205. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27206. private _updateMatrix3x3ForUniform;
  27207. private _updateMatrix3x3ForEffect;
  27208. private _updateMatrix2x2ForEffect;
  27209. private _updateMatrix2x2ForUniform;
  27210. private _updateFloatForEffect;
  27211. private _updateFloatForUniform;
  27212. private _updateFloat2ForEffect;
  27213. private _updateFloat2ForUniform;
  27214. private _updateFloat3ForEffect;
  27215. private _updateFloat3ForUniform;
  27216. private _updateFloat4ForEffect;
  27217. private _updateFloat4ForUniform;
  27218. private _updateMatrixForEffect;
  27219. private _updateMatrixForUniform;
  27220. private _updateVector3ForEffect;
  27221. private _updateVector3ForUniform;
  27222. private _updateVector4ForEffect;
  27223. private _updateVector4ForUniform;
  27224. private _updateColor3ForEffect;
  27225. private _updateColor3ForUniform;
  27226. private _updateColor4ForEffect;
  27227. private _updateColor4ForUniform;
  27228. /**
  27229. * Sets a sampler uniform on the effect.
  27230. * @param name Define the name of the sampler.
  27231. * @param texture Define the texture to set in the sampler
  27232. */
  27233. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27234. /**
  27235. * Directly updates the value of the uniform in the cache AND on the GPU.
  27236. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27237. * @param data Define the flattened data
  27238. */
  27239. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27240. /**
  27241. * Binds this uniform buffer to an effect.
  27242. * @param effect Define the effect to bind the buffer to
  27243. * @param name Name of the uniform block in the shader.
  27244. */
  27245. bindToEffect(effect: Effect, name: string): void;
  27246. /**
  27247. * Disposes the uniform buffer.
  27248. */
  27249. dispose(): void;
  27250. }
  27251. }
  27252. declare module "babylonjs/Audio/analyser" {
  27253. import { Scene } from "babylonjs/scene";
  27254. /**
  27255. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27257. */
  27258. export class Analyser {
  27259. /**
  27260. * Gets or sets the smoothing
  27261. * @ignorenaming
  27262. */
  27263. SMOOTHING: number;
  27264. /**
  27265. * Gets or sets the FFT table size
  27266. * @ignorenaming
  27267. */
  27268. FFT_SIZE: number;
  27269. /**
  27270. * Gets or sets the bar graph amplitude
  27271. * @ignorenaming
  27272. */
  27273. BARGRAPHAMPLITUDE: number;
  27274. /**
  27275. * Gets or sets the position of the debug canvas
  27276. * @ignorenaming
  27277. */
  27278. DEBUGCANVASPOS: {
  27279. x: number;
  27280. y: number;
  27281. };
  27282. /**
  27283. * Gets or sets the debug canvas size
  27284. * @ignorenaming
  27285. */
  27286. DEBUGCANVASSIZE: {
  27287. width: number;
  27288. height: number;
  27289. };
  27290. private _byteFreqs;
  27291. private _byteTime;
  27292. private _floatFreqs;
  27293. private _webAudioAnalyser;
  27294. private _debugCanvas;
  27295. private _debugCanvasContext;
  27296. private _scene;
  27297. private _registerFunc;
  27298. private _audioEngine;
  27299. /**
  27300. * Creates a new analyser
  27301. * @param scene defines hosting scene
  27302. */
  27303. constructor(scene: Scene);
  27304. /**
  27305. * Get the number of data values you will have to play with for the visualization
  27306. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27307. * @returns a number
  27308. */
  27309. getFrequencyBinCount(): number;
  27310. /**
  27311. * Gets the current frequency data as a byte array
  27312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27313. * @returns a Uint8Array
  27314. */
  27315. getByteFrequencyData(): Uint8Array;
  27316. /**
  27317. * Gets the current waveform as a byte array
  27318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27319. * @returns a Uint8Array
  27320. */
  27321. getByteTimeDomainData(): Uint8Array;
  27322. /**
  27323. * Gets the current frequency data as a float array
  27324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27325. * @returns a Float32Array
  27326. */
  27327. getFloatFrequencyData(): Float32Array;
  27328. /**
  27329. * Renders the debug canvas
  27330. */
  27331. drawDebugCanvas(): void;
  27332. /**
  27333. * Stops rendering the debug canvas and removes it
  27334. */
  27335. stopDebugCanvas(): void;
  27336. /**
  27337. * Connects two audio nodes
  27338. * @param inputAudioNode defines first node to connect
  27339. * @param outputAudioNode defines second node to connect
  27340. */
  27341. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. dispose(): void;
  27346. }
  27347. }
  27348. declare module "babylonjs/Audio/audioEngine" {
  27349. import { IDisposable } from "babylonjs/scene";
  27350. import { Analyser } from "babylonjs/Audio/analyser";
  27351. import { Nullable } from "babylonjs/types";
  27352. import { Observable } from "babylonjs/Misc/observable";
  27353. /**
  27354. * This represents an audio engine and it is responsible
  27355. * to play, synchronize and analyse sounds throughout the application.
  27356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27357. */
  27358. export interface IAudioEngine extends IDisposable {
  27359. /**
  27360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27361. */
  27362. readonly canUseWebAudio: boolean;
  27363. /**
  27364. * Gets the current AudioContext if available.
  27365. */
  27366. readonly audioContext: Nullable<AudioContext>;
  27367. /**
  27368. * The master gain node defines the global audio volume of your audio engine.
  27369. */
  27370. readonly masterGain: GainNode;
  27371. /**
  27372. * Gets whether or not mp3 are supported by your browser.
  27373. */
  27374. readonly isMP3supported: boolean;
  27375. /**
  27376. * Gets whether or not ogg are supported by your browser.
  27377. */
  27378. readonly isOGGsupported: boolean;
  27379. /**
  27380. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27381. * @ignoreNaming
  27382. */
  27383. WarnedWebAudioUnsupported: boolean;
  27384. /**
  27385. * Defines if the audio engine relies on a custom unlocked button.
  27386. * In this case, the embedded button will not be displayed.
  27387. */
  27388. useCustomUnlockedButton: boolean;
  27389. /**
  27390. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27391. */
  27392. readonly unlocked: boolean;
  27393. /**
  27394. * Event raised when audio has been unlocked on the browser.
  27395. */
  27396. onAudioUnlockedObservable: Observable<AudioEngine>;
  27397. /**
  27398. * Event raised when audio has been locked on the browser.
  27399. */
  27400. onAudioLockedObservable: Observable<AudioEngine>;
  27401. /**
  27402. * Flags the audio engine in Locked state.
  27403. * This happens due to new browser policies preventing audio to autoplay.
  27404. */
  27405. lock(): void;
  27406. /**
  27407. * Unlocks the audio engine once a user action has been done on the dom.
  27408. * This is helpful to resume play once browser policies have been satisfied.
  27409. */
  27410. unlock(): void;
  27411. }
  27412. /**
  27413. * This represents the default audio engine used in babylon.
  27414. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27416. */
  27417. export class AudioEngine implements IAudioEngine {
  27418. private _audioContext;
  27419. private _audioContextInitialized;
  27420. private _muteButton;
  27421. private _hostElement;
  27422. /**
  27423. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27424. */
  27425. canUseWebAudio: boolean;
  27426. /**
  27427. * The master gain node defines the global audio volume of your audio engine.
  27428. */
  27429. masterGain: GainNode;
  27430. /**
  27431. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27432. * @ignoreNaming
  27433. */
  27434. WarnedWebAudioUnsupported: boolean;
  27435. /**
  27436. * Gets whether or not mp3 are supported by your browser.
  27437. */
  27438. isMP3supported: boolean;
  27439. /**
  27440. * Gets whether or not ogg are supported by your browser.
  27441. */
  27442. isOGGsupported: boolean;
  27443. /**
  27444. * Gets whether audio has been unlocked on the device.
  27445. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27446. * a user interaction has happened.
  27447. */
  27448. unlocked: boolean;
  27449. /**
  27450. * Defines if the audio engine relies on a custom unlocked button.
  27451. * In this case, the embedded button will not be displayed.
  27452. */
  27453. useCustomUnlockedButton: boolean;
  27454. /**
  27455. * Event raised when audio has been unlocked on the browser.
  27456. */
  27457. onAudioUnlockedObservable: Observable<AudioEngine>;
  27458. /**
  27459. * Event raised when audio has been locked on the browser.
  27460. */
  27461. onAudioLockedObservable: Observable<AudioEngine>;
  27462. /**
  27463. * Gets the current AudioContext if available.
  27464. */
  27465. readonly audioContext: Nullable<AudioContext>;
  27466. private _connectedAnalyser;
  27467. /**
  27468. * Instantiates a new audio engine.
  27469. *
  27470. * There should be only one per page as some browsers restrict the number
  27471. * of audio contexts you can create.
  27472. * @param hostElement defines the host element where to display the mute icon if necessary
  27473. */
  27474. constructor(hostElement?: Nullable<HTMLElement>);
  27475. /**
  27476. * Flags the audio engine in Locked state.
  27477. * This happens due to new browser policies preventing audio to autoplay.
  27478. */
  27479. lock(): void;
  27480. /**
  27481. * Unlocks the audio engine once a user action has been done on the dom.
  27482. * This is helpful to resume play once browser policies have been satisfied.
  27483. */
  27484. unlock(): void;
  27485. private _resumeAudioContext;
  27486. private _initializeAudioContext;
  27487. private _tryToRun;
  27488. private _triggerRunningState;
  27489. private _triggerSuspendedState;
  27490. private _displayMuteButton;
  27491. private _moveButtonToTopLeft;
  27492. private _onResize;
  27493. private _hideMuteButton;
  27494. /**
  27495. * Destroy and release the resources associated with the audio ccontext.
  27496. */
  27497. dispose(): void;
  27498. /**
  27499. * Gets the global volume sets on the master gain.
  27500. * @returns the global volume if set or -1 otherwise
  27501. */
  27502. getGlobalVolume(): number;
  27503. /**
  27504. * Sets the global volume of your experience (sets on the master gain).
  27505. * @param newVolume Defines the new global volume of the application
  27506. */
  27507. setGlobalVolume(newVolume: number): void;
  27508. /**
  27509. * Connect the audio engine to an audio analyser allowing some amazing
  27510. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27512. * @param analyser The analyser to connect to the engine
  27513. */
  27514. connectToAnalyser(analyser: Analyser): void;
  27515. }
  27516. }
  27517. declare module "babylonjs/Loading/loadingScreen" {
  27518. /**
  27519. * Interface used to present a loading screen while loading a scene
  27520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27521. */
  27522. export interface ILoadingScreen {
  27523. /**
  27524. * Function called to display the loading screen
  27525. */
  27526. displayLoadingUI: () => void;
  27527. /**
  27528. * Function called to hide the loading screen
  27529. */
  27530. hideLoadingUI: () => void;
  27531. /**
  27532. * Gets or sets the color to use for the background
  27533. */
  27534. loadingUIBackgroundColor: string;
  27535. /**
  27536. * Gets or sets the text to display while loading
  27537. */
  27538. loadingUIText: string;
  27539. }
  27540. /**
  27541. * Class used for the default loading screen
  27542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27543. */
  27544. export class DefaultLoadingScreen implements ILoadingScreen {
  27545. private _renderingCanvas;
  27546. private _loadingText;
  27547. private _loadingDivBackgroundColor;
  27548. private _loadingDiv;
  27549. private _loadingTextDiv;
  27550. /**
  27551. * Creates a new default loading screen
  27552. * @param _renderingCanvas defines the canvas used to render the scene
  27553. * @param _loadingText defines the default text to display
  27554. * @param _loadingDivBackgroundColor defines the default background color
  27555. */
  27556. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27557. /**
  27558. * Function called to display the loading screen
  27559. */
  27560. displayLoadingUI(): void;
  27561. /**
  27562. * Function called to hide the loading screen
  27563. */
  27564. hideLoadingUI(): void;
  27565. /**
  27566. * Gets or sets the text to display while loading
  27567. */
  27568. loadingUIText: string;
  27569. /**
  27570. * Gets or sets the color to use for the background
  27571. */
  27572. loadingUIBackgroundColor: string;
  27573. private _resizeLoadingUI;
  27574. }
  27575. }
  27576. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27577. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27578. import { Engine } from "babylonjs/Engines/engine";
  27579. import { Nullable } from "babylonjs/types";
  27580. /** @hidden */
  27581. export class WebGLPipelineContext implements IPipelineContext {
  27582. engine: Engine;
  27583. program: Nullable<WebGLProgram>;
  27584. context?: WebGLRenderingContext;
  27585. vertexShader?: WebGLShader;
  27586. fragmentShader?: WebGLShader;
  27587. isParallelCompiled: boolean;
  27588. onCompiled?: () => void;
  27589. transformFeedback?: WebGLTransformFeedback | null;
  27590. readonly isAsync: boolean;
  27591. readonly isReady: boolean;
  27592. }
  27593. }
  27594. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27595. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27596. /** @hidden */
  27597. export class WebGLDataBuffer extends DataBuffer {
  27598. private _buffer;
  27599. constructor(resource: WebGLBuffer);
  27600. readonly underlyingResource: any;
  27601. }
  27602. }
  27603. declare module "babylonjs/Materials/Textures/videoTexture" {
  27604. import { Observable } from "babylonjs/Misc/observable";
  27605. import { Nullable } from "babylonjs/types";
  27606. import { Scene } from "babylonjs/scene";
  27607. import { Texture } from "babylonjs/Materials/Textures/texture";
  27608. /**
  27609. * Settings for finer control over video usage
  27610. */
  27611. export interface VideoTextureSettings {
  27612. /**
  27613. * Applies `autoplay` to video, if specified
  27614. */
  27615. autoPlay?: boolean;
  27616. /**
  27617. * Applies `loop` to video, if specified
  27618. */
  27619. loop?: boolean;
  27620. /**
  27621. * Automatically updates internal texture from video at every frame in the render loop
  27622. */
  27623. autoUpdateTexture: boolean;
  27624. /**
  27625. * Image src displayed during the video loading or until the user interacts with the video.
  27626. */
  27627. poster?: string;
  27628. }
  27629. /**
  27630. * If you want to display a video in your scene, this is the special texture for that.
  27631. * This special texture works similar to other textures, with the exception of a few parameters.
  27632. * @see https://doc.babylonjs.com/how_to/video_texture
  27633. */
  27634. export class VideoTexture extends Texture {
  27635. /**
  27636. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27637. */
  27638. readonly autoUpdateTexture: boolean;
  27639. /**
  27640. * The video instance used by the texture internally
  27641. */
  27642. readonly video: HTMLVideoElement;
  27643. private _onUserActionRequestedObservable;
  27644. /**
  27645. * Event triggerd when a dom action is required by the user to play the video.
  27646. * This happens due to recent changes in browser policies preventing video to auto start.
  27647. */
  27648. readonly onUserActionRequestedObservable: Observable<Texture>;
  27649. private _generateMipMaps;
  27650. private _engine;
  27651. private _stillImageCaptured;
  27652. private _displayingPosterTexture;
  27653. private _settings;
  27654. private _createInternalTextureOnEvent;
  27655. /**
  27656. * Creates a video texture.
  27657. * If you want to display a video in your scene, this is the special texture for that.
  27658. * This special texture works similar to other textures, with the exception of a few parameters.
  27659. * @see https://doc.babylonjs.com/how_to/video_texture
  27660. * @param name optional name, will detect from video source, if not defined
  27661. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27662. * @param scene is obviously the current scene.
  27663. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27664. * @param invertY is false by default but can be used to invert video on Y axis
  27665. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27666. * @param settings allows finer control over video usage
  27667. */
  27668. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27669. private _getName;
  27670. private _getVideo;
  27671. private _createInternalTexture;
  27672. private reset;
  27673. /**
  27674. * @hidden Internal method to initiate `update`.
  27675. */
  27676. _rebuild(): void;
  27677. /**
  27678. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27679. */
  27680. update(): void;
  27681. /**
  27682. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27683. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27684. */
  27685. updateTexture(isVisible: boolean): void;
  27686. protected _updateInternalTexture: () => void;
  27687. /**
  27688. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27689. * @param url New url.
  27690. */
  27691. updateURL(url: string): void;
  27692. /**
  27693. * Dispose the texture and release its associated resources.
  27694. */
  27695. dispose(): void;
  27696. /**
  27697. * Creates a video texture straight from a stream.
  27698. * @param scene Define the scene the texture should be created in
  27699. * @param stream Define the stream the texture should be created from
  27700. * @returns The created video texture as a promise
  27701. */
  27702. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27703. /**
  27704. * Creates a video texture straight from your WebCam video feed.
  27705. * @param scene Define the scene the texture should be created in
  27706. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27707. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27708. * @returns The created video texture as a promise
  27709. */
  27710. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27711. minWidth: number;
  27712. maxWidth: number;
  27713. minHeight: number;
  27714. maxHeight: number;
  27715. deviceId: string;
  27716. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27717. /**
  27718. * Creates a video texture straight from your WebCam video feed.
  27719. * @param scene Define the scene the texture should be created in
  27720. * @param onReady Define a callback to triggered once the texture will be ready
  27721. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27722. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27723. */
  27724. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27725. minWidth: number;
  27726. maxWidth: number;
  27727. minHeight: number;
  27728. maxHeight: number;
  27729. deviceId: string;
  27730. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27731. }
  27732. }
  27733. declare module "babylonjs/Engines/engine" {
  27734. import { Observable } from "babylonjs/Misc/observable";
  27735. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27736. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27737. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27738. import { Camera } from "babylonjs/Cameras/camera";
  27739. import { Scene } from "babylonjs/scene";
  27740. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27741. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27742. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27743. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27744. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27745. import { Material } from "babylonjs/Materials/material";
  27746. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27749. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27750. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27751. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27752. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27753. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27754. import { WebRequest } from "babylonjs/Misc/webRequest";
  27755. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27756. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27757. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27758. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27759. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27760. /**
  27761. * Interface for attribute information associated with buffer instanciation
  27762. */
  27763. export class InstancingAttributeInfo {
  27764. /**
  27765. * Index/offset of the attribute in the vertex shader
  27766. */
  27767. index: number;
  27768. /**
  27769. * size of the attribute, 1, 2, 3 or 4
  27770. */
  27771. attributeSize: number;
  27772. /**
  27773. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27774. * default is FLOAT
  27775. */
  27776. attribyteType: number;
  27777. /**
  27778. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27779. */
  27780. normalized: boolean;
  27781. /**
  27782. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27783. */
  27784. offset: number;
  27785. /**
  27786. * Name of the GLSL attribute, for debugging purpose only
  27787. */
  27788. attributeName: string;
  27789. }
  27790. /**
  27791. * Define options used to create a depth texture
  27792. */
  27793. export class DepthTextureCreationOptions {
  27794. /** Specifies whether or not a stencil should be allocated in the texture */
  27795. generateStencil?: boolean;
  27796. /** Specifies whether or not bilinear filtering is enable on the texture */
  27797. bilinearFiltering?: boolean;
  27798. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27799. comparisonFunction?: number;
  27800. /** Specifies if the created texture is a cube texture */
  27801. isCube?: boolean;
  27802. }
  27803. /**
  27804. * Class used to describe the capabilities of the engine relatively to the current browser
  27805. */
  27806. export class EngineCapabilities {
  27807. /** Maximum textures units per fragment shader */
  27808. maxTexturesImageUnits: number;
  27809. /** Maximum texture units per vertex shader */
  27810. maxVertexTextureImageUnits: number;
  27811. /** Maximum textures units in the entire pipeline */
  27812. maxCombinedTexturesImageUnits: number;
  27813. /** Maximum texture size */
  27814. maxTextureSize: number;
  27815. /** Maximum cube texture size */
  27816. maxCubemapTextureSize: number;
  27817. /** Maximum render texture size */
  27818. maxRenderTextureSize: number;
  27819. /** Maximum number of vertex attributes */
  27820. maxVertexAttribs: number;
  27821. /** Maximum number of varyings */
  27822. maxVaryingVectors: number;
  27823. /** Maximum number of uniforms per vertex shader */
  27824. maxVertexUniformVectors: number;
  27825. /** Maximum number of uniforms per fragment shader */
  27826. maxFragmentUniformVectors: number;
  27827. /** Defines if standard derivates (dx/dy) are supported */
  27828. standardDerivatives: boolean;
  27829. /** Defines if s3tc texture compression is supported */
  27830. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27831. /** Defines if pvrtc texture compression is supported */
  27832. pvrtc: any;
  27833. /** Defines if etc1 texture compression is supported */
  27834. etc1: any;
  27835. /** Defines if etc2 texture compression is supported */
  27836. etc2: any;
  27837. /** Defines if astc texture compression is supported */
  27838. astc: any;
  27839. /** Defines if float textures are supported */
  27840. textureFloat: boolean;
  27841. /** Defines if vertex array objects are supported */
  27842. vertexArrayObject: boolean;
  27843. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27844. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27845. /** Gets the maximum level of anisotropy supported */
  27846. maxAnisotropy: number;
  27847. /** Defines if instancing is supported */
  27848. instancedArrays: boolean;
  27849. /** Defines if 32 bits indices are supported */
  27850. uintIndices: boolean;
  27851. /** Defines if high precision shaders are supported */
  27852. highPrecisionShaderSupported: boolean;
  27853. /** Defines if depth reading in the fragment shader is supported */
  27854. fragmentDepthSupported: boolean;
  27855. /** Defines if float texture linear filtering is supported*/
  27856. textureFloatLinearFiltering: boolean;
  27857. /** Defines if rendering to float textures is supported */
  27858. textureFloatRender: boolean;
  27859. /** Defines if half float textures are supported*/
  27860. textureHalfFloat: boolean;
  27861. /** Defines if half float texture linear filtering is supported*/
  27862. textureHalfFloatLinearFiltering: boolean;
  27863. /** Defines if rendering to half float textures is supported */
  27864. textureHalfFloatRender: boolean;
  27865. /** Defines if textureLOD shader command is supported */
  27866. textureLOD: boolean;
  27867. /** Defines if draw buffers extension is supported */
  27868. drawBuffersExtension: boolean;
  27869. /** Defines if depth textures are supported */
  27870. depthTextureExtension: boolean;
  27871. /** Defines if float color buffer are supported */
  27872. colorBufferFloat: boolean;
  27873. /** Gets disjoint timer query extension (null if not supported) */
  27874. timerQuery: EXT_disjoint_timer_query;
  27875. /** Defines if timestamp can be used with timer query */
  27876. canUseTimestampForTimerQuery: boolean;
  27877. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27878. multiview: any;
  27879. /** Function used to let the system compiles shaders in background */
  27880. parallelShaderCompile: {
  27881. COMPLETION_STATUS_KHR: number;
  27882. };
  27883. }
  27884. /** Interface defining initialization parameters for Engine class */
  27885. export interface EngineOptions extends WebGLContextAttributes {
  27886. /**
  27887. * Defines if the engine should no exceed a specified device ratio
  27888. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27889. */
  27890. limitDeviceRatio?: number;
  27891. /**
  27892. * Defines if webvr should be enabled automatically
  27893. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27894. */
  27895. autoEnableWebVR?: boolean;
  27896. /**
  27897. * Defines if webgl2 should be turned off even if supported
  27898. * @see http://doc.babylonjs.com/features/webgl2
  27899. */
  27900. disableWebGL2Support?: boolean;
  27901. /**
  27902. * Defines if webaudio should be initialized as well
  27903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27904. */
  27905. audioEngine?: boolean;
  27906. /**
  27907. * Defines if animations should run using a deterministic lock step
  27908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27909. */
  27910. deterministicLockstep?: boolean;
  27911. /** Defines the maximum steps to use with deterministic lock step mode */
  27912. lockstepMaxSteps?: number;
  27913. /**
  27914. * Defines that engine should ignore context lost events
  27915. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27916. */
  27917. doNotHandleContextLost?: boolean;
  27918. /**
  27919. * Defines that engine should ignore modifying touch action attribute and style
  27920. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27921. */
  27922. doNotHandleTouchAction?: boolean;
  27923. /**
  27924. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27925. */
  27926. useHighPrecisionFloats?: boolean;
  27927. }
  27928. /**
  27929. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27930. */
  27931. export class Engine {
  27932. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27933. static ExceptionList: ({
  27934. key: string;
  27935. capture: string;
  27936. captureConstraint: number;
  27937. targets: string[];
  27938. } | {
  27939. key: string;
  27940. capture: null;
  27941. captureConstraint: null;
  27942. targets: string[];
  27943. })[];
  27944. /** Gets the list of created engines */
  27945. static readonly Instances: Engine[];
  27946. /**
  27947. * Gets the latest created engine
  27948. */
  27949. static readonly LastCreatedEngine: Nullable<Engine>;
  27950. /**
  27951. * Gets the latest created scene
  27952. */
  27953. static readonly LastCreatedScene: Nullable<Scene>;
  27954. /**
  27955. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27956. * @param flag defines which part of the materials must be marked as dirty
  27957. * @param predicate defines a predicate used to filter which materials should be affected
  27958. */
  27959. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27960. /**
  27961. * Hidden
  27962. */
  27963. static _TextureLoaders: IInternalTextureLoader[];
  27964. /** Defines that alpha blending is disabled */
  27965. static readonly ALPHA_DISABLE: number;
  27966. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27967. static readonly ALPHA_ADD: number;
  27968. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27969. static readonly ALPHA_COMBINE: number;
  27970. /** Defines that alpha blending to DEST - SRC * DEST */
  27971. static readonly ALPHA_SUBTRACT: number;
  27972. /** Defines that alpha blending to SRC * DEST */
  27973. static readonly ALPHA_MULTIPLY: number;
  27974. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27975. static readonly ALPHA_MAXIMIZED: number;
  27976. /** Defines that alpha blending to SRC + DEST */
  27977. static readonly ALPHA_ONEONE: number;
  27978. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27979. static readonly ALPHA_PREMULTIPLIED: number;
  27980. /**
  27981. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27982. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27983. */
  27984. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27985. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27986. static readonly ALPHA_INTERPOLATE: number;
  27987. /**
  27988. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27989. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27990. */
  27991. static readonly ALPHA_SCREENMODE: number;
  27992. /** Defines that the ressource is not delayed*/
  27993. static readonly DELAYLOADSTATE_NONE: number;
  27994. /** Defines that the ressource was successfully delay loaded */
  27995. static readonly DELAYLOADSTATE_LOADED: number;
  27996. /** Defines that the ressource is currently delay loading */
  27997. static readonly DELAYLOADSTATE_LOADING: number;
  27998. /** Defines that the ressource is delayed and has not started loading */
  27999. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28000. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28001. static readonly NEVER: number;
  28002. /** 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 */
  28003. static readonly ALWAYS: number;
  28004. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28005. static readonly LESS: number;
  28006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28007. static readonly EQUAL: number;
  28008. /** 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 */
  28009. static readonly LEQUAL: number;
  28010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28011. static readonly GREATER: number;
  28012. /** 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 */
  28013. static readonly GEQUAL: number;
  28014. /** 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 */
  28015. static readonly NOTEQUAL: number;
  28016. /** Passed to stencilOperation to specify that stencil value must be kept */
  28017. static readonly KEEP: number;
  28018. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28019. static readonly REPLACE: number;
  28020. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28021. static readonly INCR: number;
  28022. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28023. static readonly DECR: number;
  28024. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28025. static readonly INVERT: number;
  28026. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28027. static readonly INCR_WRAP: number;
  28028. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28029. static readonly DECR_WRAP: number;
  28030. /** Texture is not repeating outside of 0..1 UVs */
  28031. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28032. /** Texture is repeating outside of 0..1 UVs */
  28033. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28034. /** Texture is repeating and mirrored */
  28035. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28036. /** ALPHA */
  28037. static readonly TEXTUREFORMAT_ALPHA: number;
  28038. /** LUMINANCE */
  28039. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28040. /** LUMINANCE_ALPHA */
  28041. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28042. /** RGB */
  28043. static readonly TEXTUREFORMAT_RGB: number;
  28044. /** RGBA */
  28045. static readonly TEXTUREFORMAT_RGBA: number;
  28046. /** RED */
  28047. static readonly TEXTUREFORMAT_RED: number;
  28048. /** RED (2nd reference) */
  28049. static readonly TEXTUREFORMAT_R: number;
  28050. /** RG */
  28051. static readonly TEXTUREFORMAT_RG: number;
  28052. /** RED_INTEGER */
  28053. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28054. /** RED_INTEGER (2nd reference) */
  28055. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28056. /** RG_INTEGER */
  28057. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28058. /** RGB_INTEGER */
  28059. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28060. /** RGBA_INTEGER */
  28061. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28062. /** UNSIGNED_BYTE */
  28063. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28064. /** UNSIGNED_BYTE (2nd reference) */
  28065. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28066. /** FLOAT */
  28067. static readonly TEXTURETYPE_FLOAT: number;
  28068. /** HALF_FLOAT */
  28069. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28070. /** BYTE */
  28071. static readonly TEXTURETYPE_BYTE: number;
  28072. /** SHORT */
  28073. static readonly TEXTURETYPE_SHORT: number;
  28074. /** UNSIGNED_SHORT */
  28075. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28076. /** INT */
  28077. static readonly TEXTURETYPE_INT: number;
  28078. /** UNSIGNED_INT */
  28079. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28080. /** UNSIGNED_SHORT_4_4_4_4 */
  28081. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28082. /** UNSIGNED_SHORT_5_5_5_1 */
  28083. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28084. /** UNSIGNED_SHORT_5_6_5 */
  28085. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28086. /** UNSIGNED_INT_2_10_10_10_REV */
  28087. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28088. /** UNSIGNED_INT_24_8 */
  28089. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28090. /** UNSIGNED_INT_10F_11F_11F_REV */
  28091. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28092. /** UNSIGNED_INT_5_9_9_9_REV */
  28093. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28094. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28095. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28096. /** nearest is mag = nearest and min = nearest and mip = linear */
  28097. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28098. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28099. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28100. /** Trilinear is mag = linear and min = linear and mip = linear */
  28101. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28102. /** nearest is mag = nearest and min = nearest and mip = linear */
  28103. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28104. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28105. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28106. /** Trilinear is mag = linear and min = linear and mip = linear */
  28107. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28108. /** mag = nearest and min = nearest and mip = nearest */
  28109. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28110. /** mag = nearest and min = linear and mip = nearest */
  28111. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28112. /** mag = nearest and min = linear and mip = linear */
  28113. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28114. /** mag = nearest and min = linear and mip = none */
  28115. static readonly TEXTURE_NEAREST_LINEAR: number;
  28116. /** mag = nearest and min = nearest and mip = none */
  28117. static readonly TEXTURE_NEAREST_NEAREST: number;
  28118. /** mag = linear and min = nearest and mip = nearest */
  28119. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28120. /** mag = linear and min = nearest and mip = linear */
  28121. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28122. /** mag = linear and min = linear and mip = none */
  28123. static readonly TEXTURE_LINEAR_LINEAR: number;
  28124. /** mag = linear and min = nearest and mip = none */
  28125. static readonly TEXTURE_LINEAR_NEAREST: number;
  28126. /** Explicit coordinates mode */
  28127. static readonly TEXTURE_EXPLICIT_MODE: number;
  28128. /** Spherical coordinates mode */
  28129. static readonly TEXTURE_SPHERICAL_MODE: number;
  28130. /** Planar coordinates mode */
  28131. static readonly TEXTURE_PLANAR_MODE: number;
  28132. /** Cubic coordinates mode */
  28133. static readonly TEXTURE_CUBIC_MODE: number;
  28134. /** Projection coordinates mode */
  28135. static readonly TEXTURE_PROJECTION_MODE: number;
  28136. /** Skybox coordinates mode */
  28137. static readonly TEXTURE_SKYBOX_MODE: number;
  28138. /** Inverse Cubic coordinates mode */
  28139. static readonly TEXTURE_INVCUBIC_MODE: number;
  28140. /** Equirectangular coordinates mode */
  28141. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28142. /** Equirectangular Fixed coordinates mode */
  28143. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28144. /** Equirectangular Fixed Mirrored coordinates mode */
  28145. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28146. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28147. static readonly SCALEMODE_FLOOR: number;
  28148. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28149. static readonly SCALEMODE_NEAREST: number;
  28150. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28151. static readonly SCALEMODE_CEILING: number;
  28152. /**
  28153. * Returns the current npm package of the sdk
  28154. */
  28155. static readonly NpmPackage: string;
  28156. /**
  28157. * Returns the current version of the framework
  28158. */
  28159. static readonly Version: string;
  28160. /**
  28161. * Returns a string describing the current engine
  28162. */
  28163. readonly description: string;
  28164. /**
  28165. * Gets or sets the epsilon value used by collision engine
  28166. */
  28167. static CollisionsEpsilon: number;
  28168. /**
  28169. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28170. */
  28171. static ShadersRepository: string;
  28172. /**
  28173. * Method called to create the default loading screen.
  28174. * This can be overriden in your own app.
  28175. * @param canvas The rendering canvas element
  28176. * @returns The loading screen
  28177. */
  28178. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28179. /**
  28180. * Method called to create the default rescale post process on each engine.
  28181. */
  28182. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28183. /**
  28184. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28185. */
  28186. forcePOTTextures: boolean;
  28187. /**
  28188. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28189. */
  28190. isFullscreen: boolean;
  28191. /**
  28192. * Gets a boolean indicating if the pointer is currently locked
  28193. */
  28194. isPointerLock: boolean;
  28195. /**
  28196. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28197. */
  28198. cullBackFaces: boolean;
  28199. /**
  28200. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28201. */
  28202. renderEvenInBackground: boolean;
  28203. /**
  28204. * Gets or sets a boolean indicating that cache can be kept between frames
  28205. */
  28206. preventCacheWipeBetweenFrames: boolean;
  28207. /**
  28208. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28209. **/
  28210. enableOfflineSupport: boolean;
  28211. /**
  28212. * 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)
  28213. **/
  28214. disableManifestCheck: boolean;
  28215. /**
  28216. * Gets the list of created scenes
  28217. */
  28218. scenes: Scene[];
  28219. /**
  28220. * Event raised when a new scene is created
  28221. */
  28222. onNewSceneAddedObservable: Observable<Scene>;
  28223. /**
  28224. * Gets the list of created postprocesses
  28225. */
  28226. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28227. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28228. validateShaderPrograms: boolean;
  28229. /**
  28230. * Observable event triggered each time the rendering canvas is resized
  28231. */
  28232. onResizeObservable: Observable<Engine>;
  28233. /**
  28234. * Observable event triggered each time the canvas loses focus
  28235. */
  28236. onCanvasBlurObservable: Observable<Engine>;
  28237. /**
  28238. * Observable event triggered each time the canvas gains focus
  28239. */
  28240. onCanvasFocusObservable: Observable<Engine>;
  28241. /**
  28242. * Observable event triggered each time the canvas receives pointerout event
  28243. */
  28244. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28245. /**
  28246. * Observable event triggered before each texture is initialized
  28247. */
  28248. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28249. /**
  28250. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28251. */
  28252. disableUniformBuffers: boolean;
  28253. /** @hidden */
  28254. _uniformBuffers: UniformBuffer[];
  28255. /**
  28256. * Gets a boolean indicating that the engine supports uniform buffers
  28257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28258. */
  28259. readonly supportsUniformBuffers: boolean;
  28260. /**
  28261. * Observable raised when the engine begins a new frame
  28262. */
  28263. onBeginFrameObservable: Observable<Engine>;
  28264. /**
  28265. * If set, will be used to request the next animation frame for the render loop
  28266. */
  28267. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28268. /**
  28269. * Observable raised when the engine ends the current frame
  28270. */
  28271. onEndFrameObservable: Observable<Engine>;
  28272. /**
  28273. * Observable raised when the engine is about to compile a shader
  28274. */
  28275. onBeforeShaderCompilationObservable: Observable<Engine>;
  28276. /**
  28277. * Observable raised when the engine has jsut compiled a shader
  28278. */
  28279. onAfterShaderCompilationObservable: Observable<Engine>;
  28280. /** @hidden */
  28281. _gl: WebGLRenderingContext;
  28282. private _renderingCanvas;
  28283. private _windowIsBackground;
  28284. private _webGLVersion;
  28285. protected _highPrecisionShadersAllowed: boolean;
  28286. /** @hidden */
  28287. readonly _shouldUseHighPrecisionShader: boolean;
  28288. /**
  28289. * Gets a boolean indicating that only power of 2 textures are supported
  28290. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28291. */
  28292. readonly needPOTTextures: boolean;
  28293. /** @hidden */
  28294. _badOS: boolean;
  28295. /** @hidden */
  28296. _badDesktopOS: boolean;
  28297. /**
  28298. * Gets the audio engine
  28299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28300. * @ignorenaming
  28301. */
  28302. static audioEngine: IAudioEngine;
  28303. /**
  28304. * Default AudioEngine factory responsible of creating the Audio Engine.
  28305. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28306. */
  28307. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28308. /**
  28309. * Default offline support factory responsible of creating a tool used to store data locally.
  28310. * By default, this will create a Database object if the workload has been embedded.
  28311. */
  28312. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28313. private _onFocus;
  28314. private _onBlur;
  28315. private _onCanvasPointerOut;
  28316. private _onCanvasBlur;
  28317. private _onCanvasFocus;
  28318. private _onFullscreenChange;
  28319. private _onPointerLockChange;
  28320. private _hardwareScalingLevel;
  28321. /** @hidden */
  28322. _caps: EngineCapabilities;
  28323. private _pointerLockRequested;
  28324. private _isStencilEnable;
  28325. private _colorWrite;
  28326. private _loadingScreen;
  28327. /** @hidden */
  28328. _drawCalls: PerfCounter;
  28329. private _glVersion;
  28330. private _glRenderer;
  28331. private _glVendor;
  28332. private _videoTextureSupported;
  28333. private _renderingQueueLaunched;
  28334. private _activeRenderLoops;
  28335. private _deterministicLockstep;
  28336. private _lockstepMaxSteps;
  28337. /**
  28338. * Observable signaled when a context lost event is raised
  28339. */
  28340. onContextLostObservable: Observable<Engine>;
  28341. /**
  28342. * Observable signaled when a context restored event is raised
  28343. */
  28344. onContextRestoredObservable: Observable<Engine>;
  28345. private _onContextLost;
  28346. private _onContextRestored;
  28347. private _contextWasLost;
  28348. /** @hidden */
  28349. _doNotHandleContextLost: boolean;
  28350. /**
  28351. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28353. */
  28354. doNotHandleContextLost: boolean;
  28355. private _performanceMonitor;
  28356. private _fps;
  28357. private _deltaTime;
  28358. /**
  28359. * Turn this value on if you want to pause FPS computation when in background
  28360. */
  28361. disablePerformanceMonitorInBackground: boolean;
  28362. /**
  28363. * Gets the performance monitor attached to this engine
  28364. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28365. */
  28366. readonly performanceMonitor: PerformanceMonitor;
  28367. /**
  28368. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28369. */
  28370. disableVertexArrayObjects: boolean;
  28371. /** @hidden */
  28372. protected _depthCullingState: _DepthCullingState;
  28373. /** @hidden */
  28374. protected _stencilState: _StencilState;
  28375. /** @hidden */
  28376. protected _alphaState: _AlphaState;
  28377. /** @hidden */
  28378. protected _alphaMode: number;
  28379. /** @hidden */
  28380. _internalTexturesCache: InternalTexture[];
  28381. /** @hidden */
  28382. protected _activeChannel: number;
  28383. private _currentTextureChannel;
  28384. /** @hidden */
  28385. protected _boundTexturesCache: {
  28386. [key: string]: Nullable<InternalTexture>;
  28387. };
  28388. /** @hidden */
  28389. protected _currentEffect: Nullable<Effect>;
  28390. /** @hidden */
  28391. protected _currentProgram: Nullable<WebGLProgram>;
  28392. private _compiledEffects;
  28393. private _vertexAttribArraysEnabled;
  28394. /** @hidden */
  28395. protected _cachedViewport: Nullable<Viewport>;
  28396. private _cachedVertexArrayObject;
  28397. /** @hidden */
  28398. protected _cachedVertexBuffers: any;
  28399. /** @hidden */
  28400. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28401. /** @hidden */
  28402. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28403. /** @hidden */
  28404. _currentRenderTarget: Nullable<InternalTexture>;
  28405. private _uintIndicesCurrentlySet;
  28406. private _currentBoundBuffer;
  28407. /** @hidden */
  28408. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28409. private _currentBufferPointers;
  28410. private _currentInstanceLocations;
  28411. private _currentInstanceBuffers;
  28412. private _textureUnits;
  28413. /** @hidden */
  28414. _workingCanvas: Nullable<HTMLCanvasElement>;
  28415. /** @hidden */
  28416. _workingContext: Nullable<CanvasRenderingContext2D>;
  28417. private _rescalePostProcess;
  28418. private _dummyFramebuffer;
  28419. private _externalData;
  28420. /** @hidden */
  28421. _bindedRenderFunction: any;
  28422. private _vaoRecordInProgress;
  28423. private _mustWipeVertexAttributes;
  28424. private _emptyTexture;
  28425. private _emptyCubeTexture;
  28426. private _emptyTexture3D;
  28427. /** @hidden */
  28428. _frameHandler: number;
  28429. private _nextFreeTextureSlots;
  28430. private _maxSimultaneousTextures;
  28431. private _activeRequests;
  28432. private _texturesSupported;
  28433. /** @hidden */
  28434. _textureFormatInUse: Nullable<string>;
  28435. /**
  28436. * Gets the list of texture formats supported
  28437. */
  28438. readonly texturesSupported: Array<string>;
  28439. /**
  28440. * Gets the list of texture formats in use
  28441. */
  28442. readonly textureFormatInUse: Nullable<string>;
  28443. /**
  28444. * Gets the current viewport
  28445. */
  28446. readonly currentViewport: Nullable<Viewport>;
  28447. /**
  28448. * Gets the default empty texture
  28449. */
  28450. readonly emptyTexture: InternalTexture;
  28451. /**
  28452. * Gets the default empty 3D texture
  28453. */
  28454. readonly emptyTexture3D: InternalTexture;
  28455. /**
  28456. * Gets the default empty cube texture
  28457. */
  28458. readonly emptyCubeTexture: InternalTexture;
  28459. /**
  28460. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28461. */
  28462. readonly premultipliedAlpha: boolean;
  28463. /**
  28464. * Creates a new engine
  28465. * @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
  28466. * @param antialias defines enable antialiasing (default: false)
  28467. * @param options defines further options to be sent to the getContext() function
  28468. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28469. */
  28470. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28471. /**
  28472. * Initializes a webVR display and starts listening to display change events
  28473. * The onVRDisplayChangedObservable will be notified upon these changes
  28474. * @returns The onVRDisplayChangedObservable
  28475. */
  28476. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28477. /** @hidden */
  28478. _prepareVRComponent(): void;
  28479. /** @hidden */
  28480. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28481. /** @hidden */
  28482. _submitVRFrame(): void;
  28483. /**
  28484. * Call this function to leave webVR mode
  28485. * Will do nothing if webVR is not supported or if there is no webVR device
  28486. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28487. */
  28488. disableVR(): void;
  28489. /**
  28490. * Gets a boolean indicating that the system is in VR mode and is presenting
  28491. * @returns true if VR mode is engaged
  28492. */
  28493. isVRPresenting(): boolean;
  28494. /** @hidden */
  28495. _requestVRFrame(): void;
  28496. private _disableTouchAction;
  28497. private _rebuildInternalTextures;
  28498. private _rebuildEffects;
  28499. /**
  28500. * Gets a boolean indicating if all created effects are ready
  28501. * @returns true if all effects are ready
  28502. */
  28503. areAllEffectsReady(): boolean;
  28504. private _rebuildBuffers;
  28505. private _initGLContext;
  28506. /**
  28507. * Gets version of the current webGL context
  28508. */
  28509. readonly webGLVersion: number;
  28510. /**
  28511. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28512. */
  28513. readonly isStencilEnable: boolean;
  28514. /** @hidden */
  28515. _prepareWorkingCanvas(): void;
  28516. /**
  28517. * Reset the texture cache to empty state
  28518. */
  28519. resetTextureCache(): void;
  28520. /**
  28521. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28523. * @returns true if engine is in deterministic lock step mode
  28524. */
  28525. isDeterministicLockStep(): boolean;
  28526. /**
  28527. * Gets the max steps when engine is running in deterministic lock step
  28528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28529. * @returns the max steps
  28530. */
  28531. getLockstepMaxSteps(): number;
  28532. /**
  28533. * Gets an object containing information about the current webGL context
  28534. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28535. */
  28536. getGlInfo(): {
  28537. vendor: string;
  28538. renderer: string;
  28539. version: string;
  28540. };
  28541. /**
  28542. * Gets current aspect ratio
  28543. * @param camera defines the camera to use to get the aspect ratio
  28544. * @param useScreen defines if screen size must be used (or the current render target if any)
  28545. * @returns a number defining the aspect ratio
  28546. */
  28547. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28548. /**
  28549. * Gets current screen aspect ratio
  28550. * @returns a number defining the aspect ratio
  28551. */
  28552. getScreenAspectRatio(): number;
  28553. /**
  28554. * Gets the current render width
  28555. * @param useScreen defines if screen size must be used (or the current render target if any)
  28556. * @returns a number defining the current render width
  28557. */
  28558. getRenderWidth(useScreen?: boolean): number;
  28559. /**
  28560. * Gets the current render height
  28561. * @param useScreen defines if screen size must be used (or the current render target if any)
  28562. * @returns a number defining the current render height
  28563. */
  28564. getRenderHeight(useScreen?: boolean): number;
  28565. /**
  28566. * Gets the HTML canvas attached with the current webGL context
  28567. * @returns a HTML canvas
  28568. */
  28569. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28570. /**
  28571. * Gets the client rect of the HTML canvas attached with the current webGL context
  28572. * @returns a client rectanglee
  28573. */
  28574. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28575. /**
  28576. * Defines the hardware scaling level.
  28577. * By default the hardware scaling level is computed from the window device ratio.
  28578. * 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.
  28579. * @param level defines the level to use
  28580. */
  28581. setHardwareScalingLevel(level: number): void;
  28582. /**
  28583. * Gets the current hardware scaling level.
  28584. * By default the hardware scaling level is computed from the window device ratio.
  28585. * 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.
  28586. * @returns a number indicating the current hardware scaling level
  28587. */
  28588. getHardwareScalingLevel(): number;
  28589. /**
  28590. * Gets the list of loaded textures
  28591. * @returns an array containing all loaded textures
  28592. */
  28593. getLoadedTexturesCache(): InternalTexture[];
  28594. /**
  28595. * Gets the object containing all engine capabilities
  28596. * @returns the EngineCapabilities object
  28597. */
  28598. getCaps(): EngineCapabilities;
  28599. /**
  28600. * Gets the current depth function
  28601. * @returns a number defining the depth function
  28602. */
  28603. getDepthFunction(): Nullable<number>;
  28604. /**
  28605. * Sets the current depth function
  28606. * @param depthFunc defines the function to use
  28607. */
  28608. setDepthFunction(depthFunc: number): void;
  28609. /**
  28610. * Sets the current depth function to GREATER
  28611. */
  28612. setDepthFunctionToGreater(): void;
  28613. /**
  28614. * Sets the current depth function to GEQUAL
  28615. */
  28616. setDepthFunctionToGreaterOrEqual(): void;
  28617. /**
  28618. * Sets the current depth function to LESS
  28619. */
  28620. setDepthFunctionToLess(): void;
  28621. private _cachedStencilBuffer;
  28622. private _cachedStencilFunction;
  28623. private _cachedStencilMask;
  28624. private _cachedStencilOperationPass;
  28625. private _cachedStencilOperationFail;
  28626. private _cachedStencilOperationDepthFail;
  28627. private _cachedStencilReference;
  28628. /**
  28629. * Caches the the state of the stencil buffer
  28630. */
  28631. cacheStencilState(): void;
  28632. /**
  28633. * Restores the state of the stencil buffer
  28634. */
  28635. restoreStencilState(): void;
  28636. /**
  28637. * Sets the current depth function to LEQUAL
  28638. */
  28639. setDepthFunctionToLessOrEqual(): void;
  28640. /**
  28641. * Gets a boolean indicating if stencil buffer is enabled
  28642. * @returns the current stencil buffer state
  28643. */
  28644. getStencilBuffer(): boolean;
  28645. /**
  28646. * Enable or disable the stencil buffer
  28647. * @param enable defines if the stencil buffer must be enabled or disabled
  28648. */
  28649. setStencilBuffer(enable: boolean): void;
  28650. /**
  28651. * Gets the current stencil mask
  28652. * @returns a number defining the new stencil mask to use
  28653. */
  28654. getStencilMask(): number;
  28655. /**
  28656. * Sets the current stencil mask
  28657. * @param mask defines the new stencil mask to use
  28658. */
  28659. setStencilMask(mask: number): void;
  28660. /**
  28661. * Gets the current stencil function
  28662. * @returns a number defining the stencil function to use
  28663. */
  28664. getStencilFunction(): number;
  28665. /**
  28666. * Gets the current stencil reference value
  28667. * @returns a number defining the stencil reference value to use
  28668. */
  28669. getStencilFunctionReference(): number;
  28670. /**
  28671. * Gets the current stencil mask
  28672. * @returns a number defining the stencil mask to use
  28673. */
  28674. getStencilFunctionMask(): number;
  28675. /**
  28676. * Sets the current stencil function
  28677. * @param stencilFunc defines the new stencil function to use
  28678. */
  28679. setStencilFunction(stencilFunc: number): void;
  28680. /**
  28681. * Sets the current stencil reference
  28682. * @param reference defines the new stencil reference to use
  28683. */
  28684. setStencilFunctionReference(reference: number): void;
  28685. /**
  28686. * Sets the current stencil mask
  28687. * @param mask defines the new stencil mask to use
  28688. */
  28689. setStencilFunctionMask(mask: number): void;
  28690. /**
  28691. * Gets the current stencil operation when stencil fails
  28692. * @returns a number defining stencil operation to use when stencil fails
  28693. */
  28694. getStencilOperationFail(): number;
  28695. /**
  28696. * Gets the current stencil operation when depth fails
  28697. * @returns a number defining stencil operation to use when depth fails
  28698. */
  28699. getStencilOperationDepthFail(): number;
  28700. /**
  28701. * Gets the current stencil operation when stencil passes
  28702. * @returns a number defining stencil operation to use when stencil passes
  28703. */
  28704. getStencilOperationPass(): number;
  28705. /**
  28706. * Sets the stencil operation to use when stencil fails
  28707. * @param operation defines the stencil operation to use when stencil fails
  28708. */
  28709. setStencilOperationFail(operation: number): void;
  28710. /**
  28711. * Sets the stencil operation to use when depth fails
  28712. * @param operation defines the stencil operation to use when depth fails
  28713. */
  28714. setStencilOperationDepthFail(operation: number): void;
  28715. /**
  28716. * Sets the stencil operation to use when stencil passes
  28717. * @param operation defines the stencil operation to use when stencil passes
  28718. */
  28719. setStencilOperationPass(operation: number): void;
  28720. /**
  28721. * Sets a boolean indicating if the dithering state is enabled or disabled
  28722. * @param value defines the dithering state
  28723. */
  28724. setDitheringState(value: boolean): void;
  28725. /**
  28726. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28727. * @param value defines the rasterizer state
  28728. */
  28729. setRasterizerState(value: boolean): void;
  28730. /**
  28731. * stop executing a render loop function and remove it from the execution array
  28732. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28733. */
  28734. stopRenderLoop(renderFunction?: () => void): void;
  28735. /** @hidden */
  28736. _renderLoop(): void;
  28737. /**
  28738. * Register and execute a render loop. The engine can have more than one render function
  28739. * @param renderFunction defines the function to continuously execute
  28740. */
  28741. runRenderLoop(renderFunction: () => void): void;
  28742. /**
  28743. * Toggle full screen mode
  28744. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28745. */
  28746. switchFullscreen(requestPointerLock: boolean): void;
  28747. /**
  28748. * Enters full screen mode
  28749. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28750. */
  28751. enterFullscreen(requestPointerLock: boolean): void;
  28752. /**
  28753. * Exits full screen mode
  28754. */
  28755. exitFullscreen(): void;
  28756. /**
  28757. * Clear the current render buffer or the current render target (if any is set up)
  28758. * @param color defines the color to use
  28759. * @param backBuffer defines if the back buffer must be cleared
  28760. * @param depth defines if the depth buffer must be cleared
  28761. * @param stencil defines if the stencil buffer must be cleared
  28762. */
  28763. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28764. /**
  28765. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28766. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28767. * @param y defines the y-coordinate of the corner of the clear rectangle
  28768. * @param width defines the width of the clear rectangle
  28769. * @param height defines the height of the clear rectangle
  28770. * @param clearColor defines the clear color
  28771. */
  28772. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28773. /**
  28774. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28775. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28776. * @param y defines the y-coordinate of the corner of the clear rectangle
  28777. * @param width defines the width of the clear rectangle
  28778. * @param height defines the height of the clear rectangle
  28779. */
  28780. enableScissor(x: number, y: number, width: number, height: number): void;
  28781. /**
  28782. * Disable previously set scissor test rectangle
  28783. */
  28784. disableScissor(): void;
  28785. private _viewportCached;
  28786. /** @hidden */
  28787. _viewport(x: number, y: number, width: number, height: number): void;
  28788. /**
  28789. * Set the WebGL's viewport
  28790. * @param viewport defines the viewport element to be used
  28791. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28792. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28793. */
  28794. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28795. /**
  28796. * Directly set the WebGL Viewport
  28797. * @param x defines the x coordinate of the viewport (in screen space)
  28798. * @param y defines the y coordinate of the viewport (in screen space)
  28799. * @param width defines the width of the viewport (in screen space)
  28800. * @param height defines the height of the viewport (in screen space)
  28801. * @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
  28802. */
  28803. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28804. /**
  28805. * Begin a new frame
  28806. */
  28807. beginFrame(): void;
  28808. /**
  28809. * Enf the current frame
  28810. */
  28811. endFrame(): void;
  28812. /**
  28813. * Resize the view according to the canvas' size
  28814. */
  28815. resize(): void;
  28816. /**
  28817. * Force a specific size of the canvas
  28818. * @param width defines the new canvas' width
  28819. * @param height defines the new canvas' height
  28820. */
  28821. setSize(width: number, height: number): void;
  28822. /**
  28823. * Binds the frame buffer to the specified texture.
  28824. * @param texture The texture to render to or null for the default canvas
  28825. * @param faceIndex The face of the texture to render to in case of cube texture
  28826. * @param requiredWidth The width of the target to render to
  28827. * @param requiredHeight The height of the target to render to
  28828. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28829. * @param depthStencilTexture The depth stencil texture to use to render
  28830. * @param lodLevel defines le lod level to bind to the frame buffer
  28831. */
  28832. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28833. /** @hidden */
  28834. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28835. /**
  28836. * Unbind the current render target texture from the webGL context
  28837. * @param texture defines the render target texture to unbind
  28838. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28839. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28840. */
  28841. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28842. /**
  28843. * Force the mipmap generation for the given render target texture
  28844. * @param texture defines the render target texture to use
  28845. */
  28846. generateMipMapsForCubemap(texture: InternalTexture): void;
  28847. /**
  28848. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28849. */
  28850. flushFramebuffer(): void;
  28851. /**
  28852. * Unbind the current render target and bind the default framebuffer
  28853. */
  28854. restoreDefaultFramebuffer(): void;
  28855. /**
  28856. * Create an uniform buffer
  28857. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28858. * @param elements defines the content of the uniform buffer
  28859. * @returns the webGL uniform buffer
  28860. */
  28861. createUniformBuffer(elements: FloatArray): DataBuffer;
  28862. /**
  28863. * Create a dynamic uniform buffer
  28864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28865. * @param elements defines the content of the uniform buffer
  28866. * @returns the webGL uniform buffer
  28867. */
  28868. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28869. /**
  28870. * Update an existing uniform buffer
  28871. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28872. * @param uniformBuffer defines the target uniform buffer
  28873. * @param elements defines the content to update
  28874. * @param offset defines the offset in the uniform buffer where update should start
  28875. * @param count defines the size of the data to update
  28876. */
  28877. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28878. private _resetVertexBufferBinding;
  28879. /**
  28880. * Creates a vertex buffer
  28881. * @param data the data for the vertex buffer
  28882. * @returns the new WebGL static buffer
  28883. */
  28884. createVertexBuffer(data: DataArray): DataBuffer;
  28885. /**
  28886. * Creates a dynamic vertex buffer
  28887. * @param data the data for the dynamic vertex buffer
  28888. * @returns the new WebGL dynamic buffer
  28889. */
  28890. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28891. /**
  28892. * Update a dynamic index buffer
  28893. * @param indexBuffer defines the target index buffer
  28894. * @param indices defines the data to update
  28895. * @param offset defines the offset in the target index buffer where update should start
  28896. */
  28897. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28898. /**
  28899. * Updates a dynamic vertex buffer.
  28900. * @param vertexBuffer the vertex buffer to update
  28901. * @param data the data used to update the vertex buffer
  28902. * @param byteOffset the byte offset of the data
  28903. * @param byteLength the byte length of the data
  28904. */
  28905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28906. private _resetIndexBufferBinding;
  28907. /**
  28908. * Creates a new index buffer
  28909. * @param indices defines the content of the index buffer
  28910. * @param updatable defines if the index buffer must be updatable
  28911. * @returns a new webGL buffer
  28912. */
  28913. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28914. /**
  28915. * Bind a webGL buffer to the webGL context
  28916. * @param buffer defines the buffer to bind
  28917. */
  28918. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28919. /**
  28920. * Bind an uniform buffer to the current webGL context
  28921. * @param buffer defines the buffer to bind
  28922. */
  28923. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28924. /**
  28925. * Bind a buffer to the current webGL context at a given location
  28926. * @param buffer defines the buffer to bind
  28927. * @param location defines the index where to bind the buffer
  28928. */
  28929. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28930. /**
  28931. * Bind a specific block at a given index in a specific shader program
  28932. * @param pipelineContext defines the pipeline context to use
  28933. * @param blockName defines the block name
  28934. * @param index defines the index where to bind the block
  28935. */
  28936. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28937. private bindIndexBuffer;
  28938. private bindBuffer;
  28939. /**
  28940. * update the bound buffer with the given data
  28941. * @param data defines the data to update
  28942. */
  28943. updateArrayBuffer(data: Float32Array): void;
  28944. private _vertexAttribPointer;
  28945. private _bindIndexBufferWithCache;
  28946. private _bindVertexBuffersAttributes;
  28947. /**
  28948. * Records a vertex array object
  28949. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28950. * @param vertexBuffers defines the list of vertex buffers to store
  28951. * @param indexBuffer defines the index buffer to store
  28952. * @param effect defines the effect to store
  28953. * @returns the new vertex array object
  28954. */
  28955. recordVertexArrayObject(vertexBuffers: {
  28956. [key: string]: VertexBuffer;
  28957. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28958. /**
  28959. * Bind a specific vertex array object
  28960. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28961. * @param vertexArrayObject defines the vertex array object to bind
  28962. * @param indexBuffer defines the index buffer to bind
  28963. */
  28964. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28965. /**
  28966. * Bind webGl buffers directly to the webGL context
  28967. * @param vertexBuffer defines the vertex buffer to bind
  28968. * @param indexBuffer defines the index buffer to bind
  28969. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28970. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28971. * @param effect defines the effect associated with the vertex buffer
  28972. */
  28973. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28974. private _unbindVertexArrayObject;
  28975. /**
  28976. * Bind a list of vertex buffers to the webGL context
  28977. * @param vertexBuffers defines the list of vertex buffers to bind
  28978. * @param indexBuffer defines the index buffer to bind
  28979. * @param effect defines the effect associated with the vertex buffers
  28980. */
  28981. bindBuffers(vertexBuffers: {
  28982. [key: string]: Nullable<VertexBuffer>;
  28983. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28984. /**
  28985. * Unbind all instance attributes
  28986. */
  28987. unbindInstanceAttributes(): void;
  28988. /**
  28989. * Release and free the memory of a vertex array object
  28990. * @param vao defines the vertex array object to delete
  28991. */
  28992. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28993. /** @hidden */
  28994. _releaseBuffer(buffer: DataBuffer): boolean;
  28995. /**
  28996. * Creates a webGL buffer to use with instanciation
  28997. * @param capacity defines the size of the buffer
  28998. * @returns the webGL buffer
  28999. */
  29000. createInstancesBuffer(capacity: number): DataBuffer;
  29001. /**
  29002. * Delete a webGL buffer used with instanciation
  29003. * @param buffer defines the webGL buffer to delete
  29004. */
  29005. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29006. /**
  29007. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29008. * @param instancesBuffer defines the webGL buffer to update and bind
  29009. * @param data defines the data to store in the buffer
  29010. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29011. */
  29012. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29013. /**
  29014. * Apply all cached states (depth, culling, stencil and alpha)
  29015. */
  29016. applyStates(): void;
  29017. /**
  29018. * Send a draw order
  29019. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29020. * @param indexStart defines the starting index
  29021. * @param indexCount defines the number of index to draw
  29022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29023. */
  29024. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29025. /**
  29026. * Draw a list of points
  29027. * @param verticesStart defines the index of first vertex to draw
  29028. * @param verticesCount defines the count of vertices to draw
  29029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29030. */
  29031. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29032. /**
  29033. * Draw a list of unindexed primitives
  29034. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29035. * @param verticesStart defines the index of first vertex to draw
  29036. * @param verticesCount defines the count of vertices to draw
  29037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29038. */
  29039. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29040. /**
  29041. * Draw a list of indexed primitives
  29042. * @param fillMode defines the primitive to use
  29043. * @param indexStart defines the starting index
  29044. * @param indexCount defines the number of index to draw
  29045. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29046. */
  29047. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29048. /**
  29049. * Draw a list of unindexed primitives
  29050. * @param fillMode defines the primitive to use
  29051. * @param verticesStart defines the index of first vertex to draw
  29052. * @param verticesCount defines the count of vertices to draw
  29053. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29054. */
  29055. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29056. private _drawMode;
  29057. /** @hidden */
  29058. _releaseEffect(effect: Effect): void;
  29059. /** @hidden */
  29060. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29061. /**
  29062. * Create a new effect (used to store vertex/fragment shaders)
  29063. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29064. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29065. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29066. * @param samplers defines an array of string used to represent textures
  29067. * @param defines defines the string containing the defines to use to compile the shaders
  29068. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29069. * @param onCompiled defines a function to call when the effect creation is successful
  29070. * @param onError defines a function to call when the effect creation has failed
  29071. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29072. * @returns the new Effect
  29073. */
  29074. 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;
  29075. private _compileShader;
  29076. private _compileRawShader;
  29077. /**
  29078. * Directly creates a webGL program
  29079. * @param pipelineContext defines the pipeline context to attach to
  29080. * @param vertexCode defines the vertex shader code to use
  29081. * @param fragmentCode defines the fragment shader code to use
  29082. * @param context defines the webGL context to use (if not set, the current one will be used)
  29083. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29084. * @returns the new webGL program
  29085. */
  29086. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29087. /**
  29088. * Creates a webGL program
  29089. * @param pipelineContext defines the pipeline context to attach to
  29090. * @param vertexCode defines the vertex shader code to use
  29091. * @param fragmentCode defines the fragment shader code to use
  29092. * @param defines defines the string containing the defines to use to compile the shaders
  29093. * @param context defines the webGL context to use (if not set, the current one will be used)
  29094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29095. * @returns the new webGL program
  29096. */
  29097. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29098. /**
  29099. * Creates a new pipeline context
  29100. * @returns the new pipeline
  29101. */
  29102. createPipelineContext(): WebGLPipelineContext;
  29103. private _createShaderProgram;
  29104. private _finalizePipelineContext;
  29105. /** @hidden */
  29106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29107. /** @hidden */
  29108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29109. /** @hidden */
  29110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29111. /**
  29112. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29113. * @param pipelineContext defines the pipeline context to use
  29114. * @param uniformsNames defines the list of uniform names
  29115. * @returns an array of webGL uniform locations
  29116. */
  29117. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29118. /**
  29119. * Gets the lsit of active attributes for a given webGL program
  29120. * @param pipelineContext defines the pipeline context to use
  29121. * @param attributesNames defines the list of attribute names to get
  29122. * @returns an array of indices indicating the offset of each attribute
  29123. */
  29124. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29125. /**
  29126. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29127. * @param effect defines the effect to activate
  29128. */
  29129. enableEffect(effect: Nullable<Effect>): void;
  29130. /**
  29131. * Set the value of an uniform to an array of int32
  29132. * @param uniform defines the webGL uniform location where to store the value
  29133. * @param array defines the array of int32 to store
  29134. */
  29135. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29136. /**
  29137. * Set the value of an uniform to an array of int32 (stored as vec2)
  29138. * @param uniform defines the webGL uniform location where to store the value
  29139. * @param array defines the array of int32 to store
  29140. */
  29141. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29142. /**
  29143. * Set the value of an uniform to an array of int32 (stored as vec3)
  29144. * @param uniform defines the webGL uniform location where to store the value
  29145. * @param array defines the array of int32 to store
  29146. */
  29147. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29148. /**
  29149. * Set the value of an uniform to an array of int32 (stored as vec4)
  29150. * @param uniform defines the webGL uniform location where to store the value
  29151. * @param array defines the array of int32 to store
  29152. */
  29153. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29154. /**
  29155. * Set the value of an uniform to an array of float32
  29156. * @param uniform defines the webGL uniform location where to store the value
  29157. * @param array defines the array of float32 to store
  29158. */
  29159. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29160. /**
  29161. * Set the value of an uniform to an array of float32 (stored as vec2)
  29162. * @param uniform defines the webGL uniform location where to store the value
  29163. * @param array defines the array of float32 to store
  29164. */
  29165. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29166. /**
  29167. * Set the value of an uniform to an array of float32 (stored as vec3)
  29168. * @param uniform defines the webGL uniform location where to store the value
  29169. * @param array defines the array of float32 to store
  29170. */
  29171. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29172. /**
  29173. * Set the value of an uniform to an array of float32 (stored as vec4)
  29174. * @param uniform defines the webGL uniform location where to store the value
  29175. * @param array defines the array of float32 to store
  29176. */
  29177. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29178. /**
  29179. * Set the value of an uniform to an array of number
  29180. * @param uniform defines the webGL uniform location where to store the value
  29181. * @param array defines the array of number to store
  29182. */
  29183. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29184. /**
  29185. * Set the value of an uniform to an array of number (stored as vec2)
  29186. * @param uniform defines the webGL uniform location where to store the value
  29187. * @param array defines the array of number to store
  29188. */
  29189. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29190. /**
  29191. * Set the value of an uniform to an array of number (stored as vec3)
  29192. * @param uniform defines the webGL uniform location where to store the value
  29193. * @param array defines the array of number to store
  29194. */
  29195. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29196. /**
  29197. * Set the value of an uniform to an array of number (stored as vec4)
  29198. * @param uniform defines the webGL uniform location where to store the value
  29199. * @param array defines the array of number to store
  29200. */
  29201. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29202. /**
  29203. * Set the value of an uniform to an array of float32 (stored as matrices)
  29204. * @param uniform defines the webGL uniform location where to store the value
  29205. * @param matrices defines the array of float32 to store
  29206. */
  29207. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29208. /**
  29209. * Set the value of an uniform to a matrix
  29210. * @param uniform defines the webGL uniform location where to store the value
  29211. * @param matrix defines the matrix to store
  29212. */
  29213. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29214. /**
  29215. * Set the value of an uniform to a matrix (3x3)
  29216. * @param uniform defines the webGL uniform location where to store the value
  29217. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29218. */
  29219. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29220. /**
  29221. * Set the value of an uniform to a matrix (2x2)
  29222. * @param uniform defines the webGL uniform location where to store the value
  29223. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29224. */
  29225. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29226. /**
  29227. * Set the value of an uniform to a number (int)
  29228. * @param uniform defines the webGL uniform location where to store the value
  29229. * @param value defines the int number to store
  29230. */
  29231. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29232. /**
  29233. * Set the value of an uniform to a number (float)
  29234. * @param uniform defines the webGL uniform location where to store the value
  29235. * @param value defines the float number to store
  29236. */
  29237. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29238. /**
  29239. * Set the value of an uniform to a vec2
  29240. * @param uniform defines the webGL uniform location where to store the value
  29241. * @param x defines the 1st component of the value
  29242. * @param y defines the 2nd component of the value
  29243. */
  29244. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29245. /**
  29246. * Set the value of an uniform to a vec3
  29247. * @param uniform defines the webGL uniform location where to store the value
  29248. * @param x defines the 1st component of the value
  29249. * @param y defines the 2nd component of the value
  29250. * @param z defines the 3rd component of the value
  29251. */
  29252. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29253. /**
  29254. * Set the value of an uniform to a boolean
  29255. * @param uniform defines the webGL uniform location where to store the value
  29256. * @param bool defines the boolean to store
  29257. */
  29258. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29259. /**
  29260. * Set the value of an uniform to a vec4
  29261. * @param uniform defines the webGL uniform location where to store the value
  29262. * @param x defines the 1st component of the value
  29263. * @param y defines the 2nd component of the value
  29264. * @param z defines the 3rd component of the value
  29265. * @param w defines the 4th component of the value
  29266. */
  29267. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29268. /**
  29269. * Set the value of an uniform to a Color3
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param color3 defines the color to store
  29272. */
  29273. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29274. /**
  29275. * Set the value of an uniform to a Color3 and an alpha value
  29276. * @param uniform defines the webGL uniform location where to store the value
  29277. * @param color3 defines the color to store
  29278. * @param alpha defines the alpha component to store
  29279. */
  29280. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29281. /**
  29282. * Sets a Color4 on a uniform variable
  29283. * @param uniform defines the uniform location
  29284. * @param color4 defines the value to be set
  29285. */
  29286. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29287. /**
  29288. * Set various states to the webGL context
  29289. * @param culling defines backface culling state
  29290. * @param zOffset defines the value to apply to zOffset (0 by default)
  29291. * @param force defines if states must be applied even if cache is up to date
  29292. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29293. */
  29294. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29295. /**
  29296. * Set the z offset to apply to current rendering
  29297. * @param value defines the offset to apply
  29298. */
  29299. setZOffset(value: number): void;
  29300. /**
  29301. * Gets the current value of the zOffset
  29302. * @returns the current zOffset state
  29303. */
  29304. getZOffset(): number;
  29305. /**
  29306. * Enable or disable depth buffering
  29307. * @param enable defines the state to set
  29308. */
  29309. setDepthBuffer(enable: boolean): void;
  29310. /**
  29311. * Gets a boolean indicating if depth writing is enabled
  29312. * @returns the current depth writing state
  29313. */
  29314. getDepthWrite(): boolean;
  29315. /**
  29316. * Enable or disable depth writing
  29317. * @param enable defines the state to set
  29318. */
  29319. setDepthWrite(enable: boolean): void;
  29320. /**
  29321. * Enable or disable color writing
  29322. * @param enable defines the state to set
  29323. */
  29324. setColorWrite(enable: boolean): void;
  29325. /**
  29326. * Gets a boolean indicating if color writing is enabled
  29327. * @returns the current color writing state
  29328. */
  29329. getColorWrite(): boolean;
  29330. /**
  29331. * Sets alpha constants used by some alpha blending modes
  29332. * @param r defines the red component
  29333. * @param g defines the green component
  29334. * @param b defines the blue component
  29335. * @param a defines the alpha component
  29336. */
  29337. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29338. /**
  29339. * Sets the current alpha mode
  29340. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29341. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29342. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29343. */
  29344. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29345. /**
  29346. * Gets the current alpha mode
  29347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29348. * @returns the current alpha mode
  29349. */
  29350. getAlphaMode(): number;
  29351. /**
  29352. * Clears the list of texture accessible through engine.
  29353. * This can help preventing texture load conflict due to name collision.
  29354. */
  29355. clearInternalTexturesCache(): void;
  29356. /**
  29357. * Force the entire cache to be cleared
  29358. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29359. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29360. */
  29361. wipeCaches(bruteForce?: boolean): void;
  29362. /**
  29363. * Set the compressed texture format to use, based on the formats you have, and the formats
  29364. * supported by the hardware / browser.
  29365. *
  29366. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29367. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29368. * to API arguments needed to compressed textures. This puts the burden on the container
  29369. * generator to house the arcane code for determining these for current & future formats.
  29370. *
  29371. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29372. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29373. *
  29374. * Note: The result of this call is not taken into account when a texture is base64.
  29375. *
  29376. * @param formatsAvailable defines the list of those format families you have created
  29377. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29378. *
  29379. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29380. * @returns The extension selected.
  29381. */
  29382. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29383. /** @hidden */
  29384. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29385. min: number;
  29386. mag: number;
  29387. };
  29388. /** @hidden */
  29389. _createTexture(): WebGLTexture;
  29390. /**
  29391. * Usually called from Texture.ts.
  29392. * Passed information to create a WebGLTexture
  29393. * @param urlArg defines a value which contains one of the following:
  29394. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29395. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29396. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29397. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29398. * @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)
  29399. * @param scene needed for loading to the correct scene
  29400. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29401. * @param onLoad optional callback to be called upon successful completion
  29402. * @param onError optional callback to be called upon failure
  29403. * @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
  29404. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29405. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29406. * @param forcedExtension defines the extension to use to pick the right loader
  29407. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29408. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29409. */
  29410. 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;
  29411. private _rescaleTexture;
  29412. private _unpackFlipYCached;
  29413. /**
  29414. * In case you are sharing the context with other applications, it might
  29415. * be interested to not cache the unpack flip y state to ensure a consistent
  29416. * value would be set.
  29417. */
  29418. enableUnpackFlipYCached: boolean;
  29419. /** @hidden */
  29420. _unpackFlipY(value: boolean): void;
  29421. /** @hidden */
  29422. _getUnpackAlignement(): number;
  29423. /**
  29424. * Creates a dynamic texture
  29425. * @param width defines the width of the texture
  29426. * @param height defines the height of the texture
  29427. * @param generateMipMaps defines if the engine should generate the mip levels
  29428. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29429. * @returns the dynamic texture inside an InternalTexture
  29430. */
  29431. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29432. /**
  29433. * Update the sampling mode of a given texture
  29434. * @param samplingMode defines the required sampling mode
  29435. * @param texture defines the texture to update
  29436. */
  29437. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29438. /**
  29439. * Update the content of a dynamic texture
  29440. * @param texture defines the texture to update
  29441. * @param canvas defines the canvas containing the source
  29442. * @param invertY defines if data must be stored with Y axis inverted
  29443. * @param premulAlpha defines if alpha is stored as premultiplied
  29444. * @param format defines the format of the data
  29445. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29446. */
  29447. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29448. /**
  29449. * Update a video texture
  29450. * @param texture defines the texture to update
  29451. * @param video defines the video element to use
  29452. * @param invertY defines if data must be stored with Y axis inverted
  29453. */
  29454. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29455. /**
  29456. * Updates a depth texture Comparison Mode and Function.
  29457. * If the comparison Function is equal to 0, the mode will be set to none.
  29458. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29459. * @param texture The texture to set the comparison function for
  29460. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29461. */
  29462. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29463. /** @hidden */
  29464. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29465. width: number;
  29466. height: number;
  29467. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29468. /**
  29469. * Creates a depth stencil texture.
  29470. * This is only available in WebGL 2 or with the depth texture extension available.
  29471. * @param size The size of face edge in the texture.
  29472. * @param options The options defining the texture.
  29473. * @returns The texture
  29474. */
  29475. createDepthStencilTexture(size: number | {
  29476. width: number;
  29477. height: number;
  29478. }, options: DepthTextureCreationOptions): InternalTexture;
  29479. /**
  29480. * Creates a depth stencil texture.
  29481. * This is only available in WebGL 2 or with the depth texture extension available.
  29482. * @param size The size of face edge in the texture.
  29483. * @param options The options defining the texture.
  29484. * @returns The texture
  29485. */
  29486. private _createDepthStencilTexture;
  29487. /**
  29488. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29489. * @param renderTarget The render target to set the frame buffer for
  29490. */
  29491. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29492. /**
  29493. * Creates a new render target texture
  29494. * @param size defines the size of the texture
  29495. * @param options defines the options used to create the texture
  29496. * @returns a new render target texture stored in an InternalTexture
  29497. */
  29498. createRenderTargetTexture(size: number | {
  29499. width: number;
  29500. height: number;
  29501. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29502. /** @hidden */
  29503. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29504. /**
  29505. * Updates the sample count of a render target texture
  29506. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29507. * @param texture defines the texture to update
  29508. * @param samples defines the sample count to set
  29509. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29510. */
  29511. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29512. /** @hidden */
  29513. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29514. /** @hidden */
  29515. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29516. /** @hidden */
  29517. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29518. /** @hidden */
  29519. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29520. /**
  29521. * @hidden
  29522. */
  29523. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29524. private _prepareWebGLTextureContinuation;
  29525. private _prepareWebGLTexture;
  29526. /** @hidden */
  29527. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29528. /** @hidden */
  29529. _releaseFramebufferObjects(texture: InternalTexture): void;
  29530. /** @hidden */
  29531. _releaseTexture(texture: InternalTexture): void;
  29532. private setProgram;
  29533. private _boundUniforms;
  29534. /**
  29535. * Binds an effect to the webGL context
  29536. * @param effect defines the effect to bind
  29537. */
  29538. bindSamplers(effect: Effect): void;
  29539. private _activateCurrentTexture;
  29540. /** @hidden */
  29541. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29542. /** @hidden */
  29543. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29544. /**
  29545. * Sets a texture to the webGL context from a postprocess
  29546. * @param channel defines the channel to use
  29547. * @param postProcess defines the source postprocess
  29548. */
  29549. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29550. /**
  29551. * Binds the output of the passed in post process to the texture channel specified
  29552. * @param channel The channel the texture should be bound to
  29553. * @param postProcess The post process which's output should be bound
  29554. */
  29555. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29556. /**
  29557. * Unbind all textures from the webGL context
  29558. */
  29559. unbindAllTextures(): void;
  29560. /**
  29561. * Sets a texture to the according uniform.
  29562. * @param channel The texture channel
  29563. * @param uniform The uniform to set
  29564. * @param texture The texture to apply
  29565. */
  29566. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29567. /**
  29568. * Sets a depth stencil texture from a render target to the according uniform.
  29569. * @param channel The texture channel
  29570. * @param uniform The uniform to set
  29571. * @param texture The render target texture containing the depth stencil texture to apply
  29572. */
  29573. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29574. private _bindSamplerUniformToChannel;
  29575. private _getTextureWrapMode;
  29576. private _setTexture;
  29577. /**
  29578. * Sets an array of texture to the webGL context
  29579. * @param channel defines the channel where the texture array must be set
  29580. * @param uniform defines the associated uniform location
  29581. * @param textures defines the array of textures to bind
  29582. */
  29583. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29584. /** @hidden */
  29585. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29586. private _setTextureParameterFloat;
  29587. private _setTextureParameterInteger;
  29588. /**
  29589. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29590. * @param x defines the x coordinate of the rectangle where pixels must be read
  29591. * @param y defines the y coordinate of the rectangle where pixels must be read
  29592. * @param width defines the width of the rectangle where pixels must be read
  29593. * @param height defines the height of the rectangle where pixels must be read
  29594. * @returns a Uint8Array containing RGBA colors
  29595. */
  29596. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29597. /**
  29598. * Add an externaly attached data from its key.
  29599. * This method call will fail and return false, if such key already exists.
  29600. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29601. * @param key the unique key that identifies the data
  29602. * @param data the data object to associate to the key for this Engine instance
  29603. * @return true if no such key were already present and the data was added successfully, false otherwise
  29604. */
  29605. addExternalData<T>(key: string, data: T): boolean;
  29606. /**
  29607. * Get an externaly attached data from its key
  29608. * @param key the unique key that identifies the data
  29609. * @return the associated data, if present (can be null), or undefined if not present
  29610. */
  29611. getExternalData<T>(key: string): T;
  29612. /**
  29613. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29614. * @param key the unique key that identifies the data
  29615. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29616. * @return the associated data, can be null if the factory returned null.
  29617. */
  29618. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29619. /**
  29620. * Remove an externaly attached data from the Engine instance
  29621. * @param key the unique key that identifies the data
  29622. * @return true if the data was successfully removed, false if it doesn't exist
  29623. */
  29624. removeExternalData(key: string): boolean;
  29625. /**
  29626. * Unbind all vertex attributes from the webGL context
  29627. */
  29628. unbindAllAttributes(): void;
  29629. /**
  29630. * 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
  29631. */
  29632. releaseEffects(): void;
  29633. /**
  29634. * Dispose and release all associated resources
  29635. */
  29636. dispose(): void;
  29637. /**
  29638. * Display the loading screen
  29639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29640. */
  29641. displayLoadingUI(): void;
  29642. /**
  29643. * Hide the loading screen
  29644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29645. */
  29646. hideLoadingUI(): void;
  29647. /**
  29648. * Gets the current loading screen object
  29649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29650. */
  29651. /**
  29652. * Sets the current loading screen object
  29653. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29654. */
  29655. loadingScreen: ILoadingScreen;
  29656. /**
  29657. * Sets the current loading screen text
  29658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29659. */
  29660. loadingUIText: string;
  29661. /**
  29662. * Sets the current loading screen background color
  29663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29664. */
  29665. loadingUIBackgroundColor: string;
  29666. /**
  29667. * Attach a new callback raised when context lost event is fired
  29668. * @param callback defines the callback to call
  29669. */
  29670. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29671. /**
  29672. * Attach a new callback raised when context restored event is fired
  29673. * @param callback defines the callback to call
  29674. */
  29675. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29676. /**
  29677. * Gets the source code of the vertex shader associated with a specific webGL program
  29678. * @param program defines the program to use
  29679. * @returns a string containing the source code of the vertex shader associated with the program
  29680. */
  29681. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29682. /**
  29683. * Gets the source code of the fragment shader associated with a specific webGL program
  29684. * @param program defines the program to use
  29685. * @returns a string containing the source code of the fragment shader associated with the program
  29686. */
  29687. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29688. /**
  29689. * Get the current error code of the webGL context
  29690. * @returns the error code
  29691. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29692. */
  29693. getError(): number;
  29694. /**
  29695. * Gets the current framerate
  29696. * @returns a number representing the framerate
  29697. */
  29698. getFps(): number;
  29699. /**
  29700. * Gets the time spent between current and previous frame
  29701. * @returns a number representing the delta time in ms
  29702. */
  29703. getDeltaTime(): number;
  29704. private _measureFps;
  29705. /** @hidden */
  29706. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29707. private _canRenderToFloatFramebuffer;
  29708. private _canRenderToHalfFloatFramebuffer;
  29709. private _canRenderToFramebuffer;
  29710. /** @hidden */
  29711. _getWebGLTextureType(type: number): number;
  29712. /** @hidden */
  29713. _getInternalFormat(format: number): number;
  29714. /** @hidden */
  29715. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29716. /** @hidden */
  29717. _getRGBAMultiSampleBufferFormat(type: number): number;
  29718. /** @hidden */
  29719. _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;
  29720. /** @hidden */
  29721. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29722. /**
  29723. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29724. * @returns true if the engine can be created
  29725. * @ignorenaming
  29726. */
  29727. static isSupported(): boolean;
  29728. }
  29729. }
  29730. declare module "babylonjs/Materials/effect" {
  29731. import { Observable } from "babylonjs/Misc/observable";
  29732. import { Nullable } from "babylonjs/types";
  29733. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29734. import { IDisposable } from "babylonjs/scene";
  29735. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29736. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29737. import { Engine } from "babylonjs/Engines/engine";
  29738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29741. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29743. /**
  29744. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29745. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29746. */
  29747. export class EffectFallbacks {
  29748. private _defines;
  29749. private _currentRank;
  29750. private _maxRank;
  29751. private _mesh;
  29752. /**
  29753. * Removes the fallback from the bound mesh.
  29754. */
  29755. unBindMesh(): void;
  29756. /**
  29757. * Adds a fallback on the specified property.
  29758. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29759. * @param define The name of the define in the shader
  29760. */
  29761. addFallback(rank: number, define: string): void;
  29762. /**
  29763. * Sets the mesh to use CPU skinning when needing to fallback.
  29764. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29765. * @param mesh The mesh to use the fallbacks.
  29766. */
  29767. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29768. /**
  29769. * Checks to see if more fallbacks are still availible.
  29770. */
  29771. readonly isMoreFallbacks: boolean;
  29772. /**
  29773. * Removes the defines that shoould be removed when falling back.
  29774. * @param currentDefines defines the current define statements for the shader.
  29775. * @param effect defines the current effect we try to compile
  29776. * @returns The resulting defines with defines of the current rank removed.
  29777. */
  29778. reduce(currentDefines: string, effect: Effect): string;
  29779. }
  29780. /**
  29781. * Options to be used when creating an effect.
  29782. */
  29783. export class EffectCreationOptions {
  29784. /**
  29785. * Atrributes that will be used in the shader.
  29786. */
  29787. attributes: string[];
  29788. /**
  29789. * Uniform varible names that will be set in the shader.
  29790. */
  29791. uniformsNames: string[];
  29792. /**
  29793. * Uniform buffer varible names that will be set in the shader.
  29794. */
  29795. uniformBuffersNames: string[];
  29796. /**
  29797. * Sampler texture variable names that will be set in the shader.
  29798. */
  29799. samplers: string[];
  29800. /**
  29801. * Define statements that will be set in the shader.
  29802. */
  29803. defines: any;
  29804. /**
  29805. * Possible fallbacks for this effect to improve performance when needed.
  29806. */
  29807. fallbacks: Nullable<EffectFallbacks>;
  29808. /**
  29809. * Callback that will be called when the shader is compiled.
  29810. */
  29811. onCompiled: Nullable<(effect: Effect) => void>;
  29812. /**
  29813. * Callback that will be called if an error occurs during shader compilation.
  29814. */
  29815. onError: Nullable<(effect: Effect, errors: string) => void>;
  29816. /**
  29817. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29818. */
  29819. indexParameters: any;
  29820. /**
  29821. * Max number of lights that can be used in the shader.
  29822. */
  29823. maxSimultaneousLights: number;
  29824. /**
  29825. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29826. */
  29827. transformFeedbackVaryings: Nullable<string[]>;
  29828. }
  29829. /**
  29830. * Effect containing vertex and fragment shader that can be executed on an object.
  29831. */
  29832. export class Effect implements IDisposable {
  29833. /**
  29834. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29835. */
  29836. static ShadersRepository: string;
  29837. /**
  29838. * Name of the effect.
  29839. */
  29840. name: any;
  29841. /**
  29842. * String container all the define statements that should be set on the shader.
  29843. */
  29844. defines: string;
  29845. /**
  29846. * Callback that will be called when the shader is compiled.
  29847. */
  29848. onCompiled: Nullable<(effect: Effect) => void>;
  29849. /**
  29850. * Callback that will be called if an error occurs during shader compilation.
  29851. */
  29852. onError: Nullable<(effect: Effect, errors: string) => void>;
  29853. /**
  29854. * Callback that will be called when effect is bound.
  29855. */
  29856. onBind: Nullable<(effect: Effect) => void>;
  29857. /**
  29858. * Unique ID of the effect.
  29859. */
  29860. uniqueId: number;
  29861. /**
  29862. * Observable that will be called when the shader is compiled.
  29863. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29864. */
  29865. onCompileObservable: Observable<Effect>;
  29866. /**
  29867. * Observable that will be called if an error occurs during shader compilation.
  29868. */
  29869. onErrorObservable: Observable<Effect>;
  29870. /** @hidden */
  29871. _onBindObservable: Nullable<Observable<Effect>>;
  29872. /**
  29873. * Observable that will be called when effect is bound.
  29874. */
  29875. readonly onBindObservable: Observable<Effect>;
  29876. /** @hidden */
  29877. _bonesComputationForcedToCPU: boolean;
  29878. private static _uniqueIdSeed;
  29879. private _engine;
  29880. private _uniformBuffersNames;
  29881. private _uniformsNames;
  29882. private _samplerList;
  29883. private _samplers;
  29884. private _isReady;
  29885. private _compilationError;
  29886. private _attributesNames;
  29887. private _attributes;
  29888. private _uniforms;
  29889. /**
  29890. * Key for the effect.
  29891. * @hidden
  29892. */
  29893. _key: string;
  29894. private _indexParameters;
  29895. private _fallbacks;
  29896. private _vertexSourceCode;
  29897. private _fragmentSourceCode;
  29898. private _vertexSourceCodeOverride;
  29899. private _fragmentSourceCodeOverride;
  29900. private _transformFeedbackVaryings;
  29901. /**
  29902. * Compiled shader to webGL program.
  29903. * @hidden
  29904. */
  29905. _pipelineContext: IPipelineContext;
  29906. private _valueCache;
  29907. private static _baseCache;
  29908. /**
  29909. * Instantiates an effect.
  29910. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29911. * @param baseName Name of the effect.
  29912. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29913. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29914. * @param samplers List of sampler variables that will be passed to the shader.
  29915. * @param engine Engine to be used to render the effect
  29916. * @param defines Define statements to be added to the shader.
  29917. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29918. * @param onCompiled Callback that will be called when the shader is compiled.
  29919. * @param onError Callback that will be called if an error occurs during shader compilation.
  29920. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29921. */
  29922. 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);
  29923. /**
  29924. * Unique key for this effect
  29925. */
  29926. readonly key: string;
  29927. /**
  29928. * If the effect has been compiled and prepared.
  29929. * @returns if the effect is compiled and prepared.
  29930. */
  29931. isReady(): boolean;
  29932. /**
  29933. * The engine the effect was initialized with.
  29934. * @returns the engine.
  29935. */
  29936. getEngine(): Engine;
  29937. /**
  29938. * The pipeline context for this effect
  29939. * @returns the associated pipeline context
  29940. */
  29941. getPipelineContext(): IPipelineContext;
  29942. /**
  29943. * The set of names of attribute variables for the shader.
  29944. * @returns An array of attribute names.
  29945. */
  29946. getAttributesNames(): string[];
  29947. /**
  29948. * Returns the attribute at the given index.
  29949. * @param index The index of the attribute.
  29950. * @returns The location of the attribute.
  29951. */
  29952. getAttributeLocation(index: number): number;
  29953. /**
  29954. * Returns the attribute based on the name of the variable.
  29955. * @param name of the attribute to look up.
  29956. * @returns the attribute location.
  29957. */
  29958. getAttributeLocationByName(name: string): number;
  29959. /**
  29960. * The number of attributes.
  29961. * @returns the numnber of attributes.
  29962. */
  29963. getAttributesCount(): number;
  29964. /**
  29965. * Gets the index of a uniform variable.
  29966. * @param uniformName of the uniform to look up.
  29967. * @returns the index.
  29968. */
  29969. getUniformIndex(uniformName: string): number;
  29970. /**
  29971. * Returns the attribute based on the name of the variable.
  29972. * @param uniformName of the uniform to look up.
  29973. * @returns the location of the uniform.
  29974. */
  29975. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29976. /**
  29977. * Returns an array of sampler variable names
  29978. * @returns The array of sampler variable neames.
  29979. */
  29980. getSamplers(): string[];
  29981. /**
  29982. * The error from the last compilation.
  29983. * @returns the error string.
  29984. */
  29985. getCompilationError(): string;
  29986. /**
  29987. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29988. * @param func The callback to be used.
  29989. */
  29990. executeWhenCompiled(func: (effect: Effect) => void): void;
  29991. private _checkIsReady;
  29992. /** @hidden */
  29993. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29994. /** @hidden */
  29995. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29996. /** @hidden */
  29997. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29998. private _processShaderConversion;
  29999. private _processIncludes;
  30000. private _processPrecision;
  30001. /**
  30002. * Recompiles the webGL program
  30003. * @param vertexSourceCode The source code for the vertex shader.
  30004. * @param fragmentSourceCode The source code for the fragment shader.
  30005. * @param onCompiled Callback called when completed.
  30006. * @param onError Callback called on error.
  30007. * @hidden
  30008. */
  30009. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30010. /**
  30011. * Prepares the effect
  30012. * @hidden
  30013. */
  30014. _prepareEffect(): void;
  30015. /**
  30016. * Checks if the effect is supported. (Must be called after compilation)
  30017. */
  30018. readonly isSupported: boolean;
  30019. /**
  30020. * Binds a texture to the engine to be used as output of the shader.
  30021. * @param channel Name of the output variable.
  30022. * @param texture Texture to bind.
  30023. * @hidden
  30024. */
  30025. _bindTexture(channel: string, texture: InternalTexture): void;
  30026. /**
  30027. * Sets a texture on the engine to be used in the shader.
  30028. * @param channel Name of the sampler variable.
  30029. * @param texture Texture to set.
  30030. */
  30031. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30032. /**
  30033. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30034. * @param channel Name of the sampler variable.
  30035. * @param texture Texture to set.
  30036. */
  30037. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30038. /**
  30039. * Sets an array of textures on the engine to be used in the shader.
  30040. * @param channel Name of the variable.
  30041. * @param textures Textures to set.
  30042. */
  30043. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30044. /**
  30045. * 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)
  30046. * @param channel Name of the sampler variable.
  30047. * @param postProcess Post process to get the input texture from.
  30048. */
  30049. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30050. /**
  30051. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30052. * 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)
  30053. * @param channel Name of the sampler variable.
  30054. * @param postProcess Post process to get the output texture from.
  30055. */
  30056. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30057. /** @hidden */
  30058. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30059. /** @hidden */
  30060. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30061. /** @hidden */
  30062. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30063. /** @hidden */
  30064. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30065. /**
  30066. * Binds a buffer to a uniform.
  30067. * @param buffer Buffer to bind.
  30068. * @param name Name of the uniform variable to bind to.
  30069. */
  30070. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30071. /**
  30072. * Binds block to a uniform.
  30073. * @param blockName Name of the block to bind.
  30074. * @param index Index to bind.
  30075. */
  30076. bindUniformBlock(blockName: string, index: number): void;
  30077. /**
  30078. * Sets an interger value on a uniform variable.
  30079. * @param uniformName Name of the variable.
  30080. * @param value Value to be set.
  30081. * @returns this effect.
  30082. */
  30083. setInt(uniformName: string, value: number): Effect;
  30084. /**
  30085. * Sets an int array on a uniform variable.
  30086. * @param uniformName Name of the variable.
  30087. * @param array array to be set.
  30088. * @returns this effect.
  30089. */
  30090. setIntArray(uniformName: string, array: Int32Array): Effect;
  30091. /**
  30092. * 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)
  30093. * @param uniformName Name of the variable.
  30094. * @param array array to be set.
  30095. * @returns this effect.
  30096. */
  30097. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30098. /**
  30099. * 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)
  30100. * @param uniformName Name of the variable.
  30101. * @param array array to be set.
  30102. * @returns this effect.
  30103. */
  30104. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30105. /**
  30106. * 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)
  30107. * @param uniformName Name of the variable.
  30108. * @param array array to be set.
  30109. * @returns this effect.
  30110. */
  30111. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30112. /**
  30113. * Sets an float array on a uniform variable.
  30114. * @param uniformName Name of the variable.
  30115. * @param array array to be set.
  30116. * @returns this effect.
  30117. */
  30118. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30119. /**
  30120. * 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)
  30121. * @param uniformName Name of the variable.
  30122. * @param array array to be set.
  30123. * @returns this effect.
  30124. */
  30125. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30126. /**
  30127. * 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)
  30128. * @param uniformName Name of the variable.
  30129. * @param array array to be set.
  30130. * @returns this effect.
  30131. */
  30132. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30133. /**
  30134. * 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)
  30135. * @param uniformName Name of the variable.
  30136. * @param array array to be set.
  30137. * @returns this effect.
  30138. */
  30139. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30140. /**
  30141. * Sets an array on a uniform variable.
  30142. * @param uniformName Name of the variable.
  30143. * @param array array to be set.
  30144. * @returns this effect.
  30145. */
  30146. setArray(uniformName: string, array: number[]): Effect;
  30147. /**
  30148. * 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)
  30149. * @param uniformName Name of the variable.
  30150. * @param array array to be set.
  30151. * @returns this effect.
  30152. */
  30153. setArray2(uniformName: string, array: number[]): Effect;
  30154. /**
  30155. * 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)
  30156. * @param uniformName Name of the variable.
  30157. * @param array array to be set.
  30158. * @returns this effect.
  30159. */
  30160. setArray3(uniformName: string, array: number[]): Effect;
  30161. /**
  30162. * 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)
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setArray4(uniformName: string, array: number[]): Effect;
  30168. /**
  30169. * Sets matrices on a uniform variable.
  30170. * @param uniformName Name of the variable.
  30171. * @param matrices matrices to be set.
  30172. * @returns this effect.
  30173. */
  30174. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30175. /**
  30176. * Sets matrix on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param matrix matrix to be set.
  30179. * @returns this effect.
  30180. */
  30181. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30182. /**
  30183. * 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)
  30184. * @param uniformName Name of the variable.
  30185. * @param matrix matrix to be set.
  30186. * @returns this effect.
  30187. */
  30188. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30189. /**
  30190. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30191. * @param uniformName Name of the variable.
  30192. * @param matrix matrix to be set.
  30193. * @returns this effect.
  30194. */
  30195. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30196. /**
  30197. * Sets a float on a uniform variable.
  30198. * @param uniformName Name of the variable.
  30199. * @param value value to be set.
  30200. * @returns this effect.
  30201. */
  30202. setFloat(uniformName: string, value: number): Effect;
  30203. /**
  30204. * Sets a boolean on a uniform variable.
  30205. * @param uniformName Name of the variable.
  30206. * @param bool value to be set.
  30207. * @returns this effect.
  30208. */
  30209. setBool(uniformName: string, bool: boolean): Effect;
  30210. /**
  30211. * Sets a Vector2 on a uniform variable.
  30212. * @param uniformName Name of the variable.
  30213. * @param vector2 vector2 to be set.
  30214. * @returns this effect.
  30215. */
  30216. setVector2(uniformName: string, vector2: Vector2): Effect;
  30217. /**
  30218. * Sets a float2 on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param x First float in float2.
  30221. * @param y Second float in float2.
  30222. * @returns this effect.
  30223. */
  30224. setFloat2(uniformName: string, x: number, y: number): Effect;
  30225. /**
  30226. * Sets a Vector3 on a uniform variable.
  30227. * @param uniformName Name of the variable.
  30228. * @param vector3 Value to be set.
  30229. * @returns this effect.
  30230. */
  30231. setVector3(uniformName: string, vector3: Vector3): Effect;
  30232. /**
  30233. * Sets a float3 on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param x First float in float3.
  30236. * @param y Second float in float3.
  30237. * @param z Third float in float3.
  30238. * @returns this effect.
  30239. */
  30240. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30241. /**
  30242. * Sets a Vector4 on a uniform variable.
  30243. * @param uniformName Name of the variable.
  30244. * @param vector4 Value to be set.
  30245. * @returns this effect.
  30246. */
  30247. setVector4(uniformName: string, vector4: Vector4): Effect;
  30248. /**
  30249. * Sets a float4 on a uniform variable.
  30250. * @param uniformName Name of the variable.
  30251. * @param x First float in float4.
  30252. * @param y Second float in float4.
  30253. * @param z Third float in float4.
  30254. * @param w Fourth float in float4.
  30255. * @returns this effect.
  30256. */
  30257. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30258. /**
  30259. * Sets a Color3 on a uniform variable.
  30260. * @param uniformName Name of the variable.
  30261. * @param color3 Value to be set.
  30262. * @returns this effect.
  30263. */
  30264. setColor3(uniformName: string, color3: Color3): Effect;
  30265. /**
  30266. * Sets a Color4 on a uniform variable.
  30267. * @param uniformName Name of the variable.
  30268. * @param color3 Value to be set.
  30269. * @param alpha Alpha value to be set.
  30270. * @returns this effect.
  30271. */
  30272. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30273. /**
  30274. * Sets a Color4 on a uniform variable
  30275. * @param uniformName defines the name of the variable
  30276. * @param color4 defines the value to be set
  30277. * @returns this effect.
  30278. */
  30279. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30280. /** Release all associated resources */
  30281. dispose(): void;
  30282. /**
  30283. * This function will add a new shader to the shader store
  30284. * @param name the name of the shader
  30285. * @param pixelShader optional pixel shader content
  30286. * @param vertexShader optional vertex shader content
  30287. */
  30288. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30289. /**
  30290. * Store of each shader (The can be looked up using effect.key)
  30291. */
  30292. static ShadersStore: {
  30293. [key: string]: string;
  30294. };
  30295. /**
  30296. * Store of each included file for a shader (The can be looked up using effect.key)
  30297. */
  30298. static IncludesShadersStore: {
  30299. [key: string]: string;
  30300. };
  30301. /**
  30302. * Resets the cache of effects.
  30303. */
  30304. static ResetCache(): void;
  30305. }
  30306. }
  30307. declare module "babylonjs/Materials/colorCurves" {
  30308. import { Effect } from "babylonjs/Materials/effect";
  30309. /**
  30310. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30311. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30312. * 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;
  30313. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30314. */
  30315. export class ColorCurves {
  30316. private _dirty;
  30317. private _tempColor;
  30318. private _globalCurve;
  30319. private _highlightsCurve;
  30320. private _midtonesCurve;
  30321. private _shadowsCurve;
  30322. private _positiveCurve;
  30323. private _negativeCurve;
  30324. private _globalHue;
  30325. private _globalDensity;
  30326. private _globalSaturation;
  30327. private _globalExposure;
  30328. /**
  30329. * Gets the global Hue value.
  30330. * 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).
  30331. */
  30332. /**
  30333. * Sets the global Hue value.
  30334. * 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).
  30335. */
  30336. globalHue: number;
  30337. /**
  30338. * Gets the global Density value.
  30339. * 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.
  30340. * Values less than zero provide a filter of opposite hue.
  30341. */
  30342. /**
  30343. * Sets the global Density value.
  30344. * 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.
  30345. * Values less than zero provide a filter of opposite hue.
  30346. */
  30347. globalDensity: number;
  30348. /**
  30349. * Gets the global Saturation value.
  30350. * 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.
  30351. */
  30352. /**
  30353. * Sets the global Saturation value.
  30354. * 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.
  30355. */
  30356. globalSaturation: number;
  30357. /**
  30358. * Gets the global Exposure value.
  30359. * 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.
  30360. */
  30361. /**
  30362. * Sets the global Exposure value.
  30363. * 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.
  30364. */
  30365. globalExposure: number;
  30366. private _highlightsHue;
  30367. private _highlightsDensity;
  30368. private _highlightsSaturation;
  30369. private _highlightsExposure;
  30370. /**
  30371. * Gets the highlights Hue value.
  30372. * 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).
  30373. */
  30374. /**
  30375. * Sets the highlights Hue value.
  30376. * 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).
  30377. */
  30378. highlightsHue: number;
  30379. /**
  30380. * Gets the highlights Density value.
  30381. * 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.
  30382. * Values less than zero provide a filter of opposite hue.
  30383. */
  30384. /**
  30385. * Sets the highlights Density value.
  30386. * 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.
  30387. * Values less than zero provide a filter of opposite hue.
  30388. */
  30389. highlightsDensity: number;
  30390. /**
  30391. * Gets the highlights Saturation value.
  30392. * 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.
  30393. */
  30394. /**
  30395. * Sets the highlights Saturation value.
  30396. * 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.
  30397. */
  30398. highlightsSaturation: number;
  30399. /**
  30400. * Gets the highlights Exposure value.
  30401. * 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.
  30402. */
  30403. /**
  30404. * Sets the highlights Exposure value.
  30405. * 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.
  30406. */
  30407. highlightsExposure: number;
  30408. private _midtonesHue;
  30409. private _midtonesDensity;
  30410. private _midtonesSaturation;
  30411. private _midtonesExposure;
  30412. /**
  30413. * Gets the midtones Hue value.
  30414. * 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).
  30415. */
  30416. /**
  30417. * Sets the midtones Hue value.
  30418. * 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).
  30419. */
  30420. midtonesHue: number;
  30421. /**
  30422. * Gets the midtones Density value.
  30423. * 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.
  30424. * Values less than zero provide a filter of opposite hue.
  30425. */
  30426. /**
  30427. * Sets the midtones Density value.
  30428. * 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.
  30429. * Values less than zero provide a filter of opposite hue.
  30430. */
  30431. midtonesDensity: number;
  30432. /**
  30433. * Gets the midtones Saturation value.
  30434. * 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.
  30435. */
  30436. /**
  30437. * Sets the midtones Saturation value.
  30438. * 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.
  30439. */
  30440. midtonesSaturation: number;
  30441. /**
  30442. * Gets the midtones Exposure value.
  30443. * 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.
  30444. */
  30445. /**
  30446. * Sets the midtones Exposure value.
  30447. * 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.
  30448. */
  30449. midtonesExposure: number;
  30450. private _shadowsHue;
  30451. private _shadowsDensity;
  30452. private _shadowsSaturation;
  30453. private _shadowsExposure;
  30454. /**
  30455. * Gets the shadows Hue value.
  30456. * 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).
  30457. */
  30458. /**
  30459. * Sets the shadows Hue value.
  30460. * 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).
  30461. */
  30462. shadowsHue: number;
  30463. /**
  30464. * Gets the shadows Density value.
  30465. * 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.
  30466. * Values less than zero provide a filter of opposite hue.
  30467. */
  30468. /**
  30469. * Sets the shadows Density value.
  30470. * 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.
  30471. * Values less than zero provide a filter of opposite hue.
  30472. */
  30473. shadowsDensity: number;
  30474. /**
  30475. * Gets the shadows Saturation value.
  30476. * 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.
  30477. */
  30478. /**
  30479. * Sets the shadows Saturation value.
  30480. * 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.
  30481. */
  30482. shadowsSaturation: number;
  30483. /**
  30484. * Gets the shadows Exposure value.
  30485. * 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.
  30486. */
  30487. /**
  30488. * Sets the shadows Exposure value.
  30489. * 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.
  30490. */
  30491. shadowsExposure: number;
  30492. /**
  30493. * Returns the class name
  30494. * @returns The class name
  30495. */
  30496. getClassName(): string;
  30497. /**
  30498. * Binds the color curves to the shader.
  30499. * @param colorCurves The color curve to bind
  30500. * @param effect The effect to bind to
  30501. * @param positiveUniform The positive uniform shader parameter
  30502. * @param neutralUniform The neutral uniform shader parameter
  30503. * @param negativeUniform The negative uniform shader parameter
  30504. */
  30505. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30506. /**
  30507. * Prepare the list of uniforms associated with the ColorCurves effects.
  30508. * @param uniformsList The list of uniforms used in the effect
  30509. */
  30510. static PrepareUniforms(uniformsList: string[]): void;
  30511. /**
  30512. * Returns color grading data based on a hue, density, saturation and exposure value.
  30513. * @param filterHue The hue of the color filter.
  30514. * @param filterDensity The density of the color filter.
  30515. * @param saturation The saturation.
  30516. * @param exposure The exposure.
  30517. * @param result The result data container.
  30518. */
  30519. private getColorGradingDataToRef;
  30520. /**
  30521. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30522. * @param value The input slider value in range [-100,100].
  30523. * @returns Adjusted value.
  30524. */
  30525. private static applyColorGradingSliderNonlinear;
  30526. /**
  30527. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30528. * @param hue The hue (H) input.
  30529. * @param saturation The saturation (S) input.
  30530. * @param brightness The brightness (B) input.
  30531. * @result An RGBA color represented as Vector4.
  30532. */
  30533. private static fromHSBToRef;
  30534. /**
  30535. * Returns a value clamped between min and max
  30536. * @param value The value to clamp
  30537. * @param min The minimum of value
  30538. * @param max The maximum of value
  30539. * @returns The clamped value.
  30540. */
  30541. private static clamp;
  30542. /**
  30543. * Clones the current color curve instance.
  30544. * @return The cloned curves
  30545. */
  30546. clone(): ColorCurves;
  30547. /**
  30548. * Serializes the current color curve instance to a json representation.
  30549. * @return a JSON representation
  30550. */
  30551. serialize(): any;
  30552. /**
  30553. * Parses the color curve from a json representation.
  30554. * @param source the JSON source to parse
  30555. * @return The parsed curves
  30556. */
  30557. static Parse(source: any): ColorCurves;
  30558. }
  30559. }
  30560. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30561. import { Observable } from "babylonjs/Misc/observable";
  30562. import { Nullable } from "babylonjs/types";
  30563. import { Color4 } from "babylonjs/Maths/math";
  30564. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30565. import { Effect } from "babylonjs/Materials/effect";
  30566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30567. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30568. /**
  30569. * Interface to follow in your material defines to integrate easily the
  30570. * Image proccessing functions.
  30571. * @hidden
  30572. */
  30573. export interface IImageProcessingConfigurationDefines {
  30574. IMAGEPROCESSING: boolean;
  30575. VIGNETTE: boolean;
  30576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30577. VIGNETTEBLENDMODEOPAQUE: boolean;
  30578. TONEMAPPING: boolean;
  30579. TONEMAPPING_ACES: boolean;
  30580. CONTRAST: boolean;
  30581. EXPOSURE: boolean;
  30582. COLORCURVES: boolean;
  30583. COLORGRADING: boolean;
  30584. COLORGRADING3D: boolean;
  30585. SAMPLER3DGREENDEPTH: boolean;
  30586. SAMPLER3DBGRMAP: boolean;
  30587. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30588. }
  30589. /**
  30590. * @hidden
  30591. */
  30592. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30593. IMAGEPROCESSING: boolean;
  30594. VIGNETTE: boolean;
  30595. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30596. VIGNETTEBLENDMODEOPAQUE: boolean;
  30597. TONEMAPPING: boolean;
  30598. TONEMAPPING_ACES: boolean;
  30599. CONTRAST: boolean;
  30600. COLORCURVES: boolean;
  30601. COLORGRADING: boolean;
  30602. COLORGRADING3D: boolean;
  30603. SAMPLER3DGREENDEPTH: boolean;
  30604. SAMPLER3DBGRMAP: boolean;
  30605. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30606. EXPOSURE: boolean;
  30607. constructor();
  30608. }
  30609. /**
  30610. * This groups together the common properties used for image processing either in direct forward pass
  30611. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30612. * or not.
  30613. */
  30614. export class ImageProcessingConfiguration {
  30615. /**
  30616. * Default tone mapping applied in BabylonJS.
  30617. */
  30618. static readonly TONEMAPPING_STANDARD: number;
  30619. /**
  30620. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30621. * to other engines rendering to increase portability.
  30622. */
  30623. static readonly TONEMAPPING_ACES: number;
  30624. /**
  30625. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30626. */
  30627. colorCurves: Nullable<ColorCurves>;
  30628. private _colorCurvesEnabled;
  30629. /**
  30630. * Gets wether the color curves effect is enabled.
  30631. */
  30632. /**
  30633. * Sets wether the color curves effect is enabled.
  30634. */
  30635. colorCurvesEnabled: boolean;
  30636. private _colorGradingTexture;
  30637. /**
  30638. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30639. */
  30640. /**
  30641. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30642. */
  30643. colorGradingTexture: Nullable<BaseTexture>;
  30644. private _colorGradingEnabled;
  30645. /**
  30646. * Gets wether the color grading effect is enabled.
  30647. */
  30648. /**
  30649. * Sets wether the color grading effect is enabled.
  30650. */
  30651. colorGradingEnabled: boolean;
  30652. private _colorGradingWithGreenDepth;
  30653. /**
  30654. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30655. */
  30656. /**
  30657. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30658. */
  30659. colorGradingWithGreenDepth: boolean;
  30660. private _colorGradingBGR;
  30661. /**
  30662. * Gets wether the color grading texture contains BGR values.
  30663. */
  30664. /**
  30665. * Sets wether the color grading texture contains BGR values.
  30666. */
  30667. colorGradingBGR: boolean;
  30668. /** @hidden */
  30669. _exposure: number;
  30670. /**
  30671. * Gets the Exposure used in the effect.
  30672. */
  30673. /**
  30674. * Sets the Exposure used in the effect.
  30675. */
  30676. exposure: number;
  30677. private _toneMappingEnabled;
  30678. /**
  30679. * Gets wether the tone mapping effect is enabled.
  30680. */
  30681. /**
  30682. * Sets wether the tone mapping effect is enabled.
  30683. */
  30684. toneMappingEnabled: boolean;
  30685. private _toneMappingType;
  30686. /**
  30687. * Gets the type of tone mapping effect.
  30688. */
  30689. /**
  30690. * Sets the type of tone mapping effect used in BabylonJS.
  30691. */
  30692. toneMappingType: number;
  30693. protected _contrast: number;
  30694. /**
  30695. * Gets the contrast used in the effect.
  30696. */
  30697. /**
  30698. * Sets the contrast used in the effect.
  30699. */
  30700. contrast: number;
  30701. /**
  30702. * Vignette stretch size.
  30703. */
  30704. vignetteStretch: number;
  30705. /**
  30706. * Vignette centre X Offset.
  30707. */
  30708. vignetteCentreX: number;
  30709. /**
  30710. * Vignette centre Y Offset.
  30711. */
  30712. vignetteCentreY: number;
  30713. /**
  30714. * Vignette weight or intensity of the vignette effect.
  30715. */
  30716. vignetteWeight: number;
  30717. /**
  30718. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30719. * if vignetteEnabled is set to true.
  30720. */
  30721. vignetteColor: Color4;
  30722. /**
  30723. * Camera field of view used by the Vignette effect.
  30724. */
  30725. vignetteCameraFov: number;
  30726. private _vignetteBlendMode;
  30727. /**
  30728. * Gets the vignette blend mode allowing different kind of effect.
  30729. */
  30730. /**
  30731. * Sets the vignette blend mode allowing different kind of effect.
  30732. */
  30733. vignetteBlendMode: number;
  30734. private _vignetteEnabled;
  30735. /**
  30736. * Gets wether the vignette effect is enabled.
  30737. */
  30738. /**
  30739. * Sets wether the vignette effect is enabled.
  30740. */
  30741. vignetteEnabled: boolean;
  30742. private _applyByPostProcess;
  30743. /**
  30744. * Gets wether the image processing is applied through a post process or not.
  30745. */
  30746. /**
  30747. * Sets wether the image processing is applied through a post process or not.
  30748. */
  30749. applyByPostProcess: boolean;
  30750. private _isEnabled;
  30751. /**
  30752. * Gets wether the image processing is enabled or not.
  30753. */
  30754. /**
  30755. * Sets wether the image processing is enabled or not.
  30756. */
  30757. isEnabled: boolean;
  30758. /**
  30759. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30760. */
  30761. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30762. /**
  30763. * Method called each time the image processing information changes requires to recompile the effect.
  30764. */
  30765. protected _updateParameters(): void;
  30766. /**
  30767. * Gets the current class name.
  30768. * @return "ImageProcessingConfiguration"
  30769. */
  30770. getClassName(): string;
  30771. /**
  30772. * Prepare the list of uniforms associated with the Image Processing effects.
  30773. * @param uniforms The list of uniforms used in the effect
  30774. * @param defines the list of defines currently in use
  30775. */
  30776. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30777. /**
  30778. * Prepare the list of samplers associated with the Image Processing effects.
  30779. * @param samplersList The list of uniforms used in the effect
  30780. * @param defines the list of defines currently in use
  30781. */
  30782. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30783. /**
  30784. * Prepare the list of defines associated to the shader.
  30785. * @param defines the list of defines to complete
  30786. * @param forPostProcess Define if we are currently in post process mode or not
  30787. */
  30788. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30789. /**
  30790. * Returns true if all the image processing information are ready.
  30791. * @returns True if ready, otherwise, false
  30792. */
  30793. isReady(): boolean;
  30794. /**
  30795. * Binds the image processing to the shader.
  30796. * @param effect The effect to bind to
  30797. * @param aspectRatio Define the current aspect ratio of the effect
  30798. */
  30799. bind(effect: Effect, aspectRatio?: number): void;
  30800. /**
  30801. * Clones the current image processing instance.
  30802. * @return The cloned image processing
  30803. */
  30804. clone(): ImageProcessingConfiguration;
  30805. /**
  30806. * Serializes the current image processing instance to a json representation.
  30807. * @return a JSON representation
  30808. */
  30809. serialize(): any;
  30810. /**
  30811. * Parses the image processing from a json representation.
  30812. * @param source the JSON source to parse
  30813. * @return The parsed image processing
  30814. */
  30815. static Parse(source: any): ImageProcessingConfiguration;
  30816. private static _VIGNETTEMODE_MULTIPLY;
  30817. private static _VIGNETTEMODE_OPAQUE;
  30818. /**
  30819. * Used to apply the vignette as a mix with the pixel color.
  30820. */
  30821. static readonly VIGNETTEMODE_MULTIPLY: number;
  30822. /**
  30823. * Used to apply the vignette as a replacement of the pixel color.
  30824. */
  30825. static readonly VIGNETTEMODE_OPAQUE: number;
  30826. }
  30827. }
  30828. declare module "babylonjs/Materials/fresnelParameters" {
  30829. import { Color3 } from "babylonjs/Maths/math";
  30830. /**
  30831. * This represents all the required information to add a fresnel effect on a material:
  30832. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30833. */
  30834. export class FresnelParameters {
  30835. private _isEnabled;
  30836. /**
  30837. * Define if the fresnel effect is enable or not.
  30838. */
  30839. isEnabled: boolean;
  30840. /**
  30841. * Define the color used on edges (grazing angle)
  30842. */
  30843. leftColor: Color3;
  30844. /**
  30845. * Define the color used on center
  30846. */
  30847. rightColor: Color3;
  30848. /**
  30849. * Define bias applied to computed fresnel term
  30850. */
  30851. bias: number;
  30852. /**
  30853. * Defined the power exponent applied to fresnel term
  30854. */
  30855. power: number;
  30856. /**
  30857. * Clones the current fresnel and its valuues
  30858. * @returns a clone fresnel configuration
  30859. */
  30860. clone(): FresnelParameters;
  30861. /**
  30862. * Serializes the current fresnel parameters to a JSON representation.
  30863. * @return the JSON serialization
  30864. */
  30865. serialize(): any;
  30866. /**
  30867. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30868. * @param parsedFresnelParameters Define the JSON representation
  30869. * @returns the parsed parameters
  30870. */
  30871. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30872. }
  30873. }
  30874. declare module "babylonjs/Misc/decorators" {
  30875. import { Nullable } from "babylonjs/types";
  30876. import { Scene } from "babylonjs/scene";
  30877. import { IAnimatable } from "babylonjs/Misc/tools";
  30878. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30879. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30880. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30881. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30882. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30883. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30884. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30885. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30886. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. /**
  30892. * Decorator used to define property that can be serialized as reference to a camera
  30893. * @param sourceName defines the name of the property to decorate
  30894. */
  30895. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. /**
  30897. * Class used to help serialization objects
  30898. */
  30899. export class SerializationHelper {
  30900. /** hidden */
  30901. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30902. /** hidden */
  30903. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30904. /** hidden */
  30905. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30906. /** hidden */
  30907. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30908. /**
  30909. * Appends the serialized animations from the source animations
  30910. * @param source Source containing the animations
  30911. * @param destination Target to store the animations
  30912. */
  30913. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30914. /**
  30915. * Static function used to serialized a specific entity
  30916. * @param entity defines the entity to serialize
  30917. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30918. * @returns a JSON compatible object representing the serialization of the entity
  30919. */
  30920. static Serialize<T>(entity: T, serializationObject?: any): any;
  30921. /**
  30922. * Creates a new entity from a serialization data object
  30923. * @param creationFunction defines a function used to instanciated the new entity
  30924. * @param source defines the source serialization data
  30925. * @param scene defines the hosting scene
  30926. * @param rootUrl defines the root url for resources
  30927. * @returns a new entity
  30928. */
  30929. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30930. /**
  30931. * Clones an object
  30932. * @param creationFunction defines the function used to instanciate the new object
  30933. * @param source defines the source object
  30934. * @returns the cloned object
  30935. */
  30936. static Clone<T>(creationFunction: () => T, source: T): T;
  30937. /**
  30938. * Instanciates a new object based on a source one (some data will be shared between both object)
  30939. * @param creationFunction defines the function used to instanciate the new object
  30940. * @param source defines the source object
  30941. * @returns the new object
  30942. */
  30943. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30944. }
  30945. }
  30946. declare module "babylonjs/Cameras/camera" {
  30947. import { SmartArray } from "babylonjs/Misc/smartArray";
  30948. import { Observable } from "babylonjs/Misc/observable";
  30949. import { Nullable } from "babylonjs/types";
  30950. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30951. import { Scene } from "babylonjs/scene";
  30952. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30953. import { Node } from "babylonjs/node";
  30954. import { Mesh } from "babylonjs/Meshes/mesh";
  30955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30956. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30959. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30960. import { Ray } from "babylonjs/Culling/ray";
  30961. /**
  30962. * This is the base class of all the camera used in the application.
  30963. * @see http://doc.babylonjs.com/features/cameras
  30964. */
  30965. export class Camera extends Node {
  30966. /** @hidden */
  30967. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30968. /**
  30969. * This is the default projection mode used by the cameras.
  30970. * It helps recreating a feeling of perspective and better appreciate depth.
  30971. * This is the best way to simulate real life cameras.
  30972. */
  30973. static readonly PERSPECTIVE_CAMERA: number;
  30974. /**
  30975. * This helps creating camera with an orthographic mode.
  30976. * 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.
  30977. */
  30978. static readonly ORTHOGRAPHIC_CAMERA: number;
  30979. /**
  30980. * This is the default FOV mode for perspective cameras.
  30981. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30982. */
  30983. static readonly FOVMODE_VERTICAL_FIXED: number;
  30984. /**
  30985. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30986. */
  30987. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30988. /**
  30989. * This specifies ther is no need for a camera rig.
  30990. * Basically only one eye is rendered corresponding to the camera.
  30991. */
  30992. static readonly RIG_MODE_NONE: number;
  30993. /**
  30994. * Simulates a camera Rig with one blue eye and one red eye.
  30995. * This can be use with 3d blue and red glasses.
  30996. */
  30997. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30998. /**
  30999. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31000. */
  31001. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31002. /**
  31003. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31004. */
  31005. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31006. /**
  31007. * Defines that both eyes of the camera will be rendered over under each other.
  31008. */
  31009. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31010. /**
  31011. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31012. */
  31013. static readonly RIG_MODE_VR: number;
  31014. /**
  31015. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31016. */
  31017. static readonly RIG_MODE_WEBVR: number;
  31018. /**
  31019. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31020. */
  31021. static readonly RIG_MODE_CUSTOM: number;
  31022. /**
  31023. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31024. */
  31025. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31026. /**
  31027. * Define the input manager associated with the camera.
  31028. */
  31029. inputs: CameraInputsManager<Camera>;
  31030. /** @hidden */
  31031. _position: Vector3;
  31032. /**
  31033. * Define the current local position of the camera in the scene
  31034. */
  31035. position: Vector3;
  31036. /**
  31037. * The vector the camera should consider as up.
  31038. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31039. */
  31040. upVector: Vector3;
  31041. /**
  31042. * Define the current limit on the left side for an orthographic camera
  31043. * In scene unit
  31044. */
  31045. orthoLeft: Nullable<number>;
  31046. /**
  31047. * Define the current limit on the right side for an orthographic camera
  31048. * In scene unit
  31049. */
  31050. orthoRight: Nullable<number>;
  31051. /**
  31052. * Define the current limit on the bottom side for an orthographic camera
  31053. * In scene unit
  31054. */
  31055. orthoBottom: Nullable<number>;
  31056. /**
  31057. * Define the current limit on the top side for an orthographic camera
  31058. * In scene unit
  31059. */
  31060. orthoTop: Nullable<number>;
  31061. /**
  31062. * Field Of View is set in Radians. (default is 0.8)
  31063. */
  31064. fov: number;
  31065. /**
  31066. * Define the minimum distance the camera can see from.
  31067. * This is important to note that the depth buffer are not infinite and the closer it starts
  31068. * the more your scene might encounter depth fighting issue.
  31069. */
  31070. minZ: number;
  31071. /**
  31072. * Define the maximum distance the camera can see to.
  31073. * This is important to note that the depth buffer are not infinite and the further it end
  31074. * the more your scene might encounter depth fighting issue.
  31075. */
  31076. maxZ: number;
  31077. /**
  31078. * Define the default inertia of the camera.
  31079. * This helps giving a smooth feeling to the camera movement.
  31080. */
  31081. inertia: number;
  31082. /**
  31083. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31084. */
  31085. mode: number;
  31086. /**
  31087. * Define wether the camera is intermediate.
  31088. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31089. */
  31090. isIntermediate: boolean;
  31091. /**
  31092. * Define the viewport of the camera.
  31093. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31094. */
  31095. viewport: Viewport;
  31096. /**
  31097. * Restricts the camera to viewing objects with the same layerMask.
  31098. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31099. */
  31100. layerMask: number;
  31101. /**
  31102. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31103. */
  31104. fovMode: number;
  31105. /**
  31106. * Rig mode of the camera.
  31107. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31108. * This is normally controlled byt the camera themselves as internal use.
  31109. */
  31110. cameraRigMode: number;
  31111. /**
  31112. * Defines the distance between both "eyes" in case of a RIG
  31113. */
  31114. interaxialDistance: number;
  31115. /**
  31116. * Defines if stereoscopic rendering is done side by side or over under.
  31117. */
  31118. isStereoscopicSideBySide: boolean;
  31119. /**
  31120. * 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
  31121. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31122. * else in the scene.
  31123. */
  31124. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31125. /**
  31126. * When set, the camera will render to this render target instead of the default canvas
  31127. */
  31128. outputRenderTarget: Nullable<RenderTargetTexture>;
  31129. /**
  31130. * Observable triggered when the camera view matrix has changed.
  31131. */
  31132. onViewMatrixChangedObservable: Observable<Camera>;
  31133. /**
  31134. * Observable triggered when the camera Projection matrix has changed.
  31135. */
  31136. onProjectionMatrixChangedObservable: Observable<Camera>;
  31137. /**
  31138. * Observable triggered when the inputs have been processed.
  31139. */
  31140. onAfterCheckInputsObservable: Observable<Camera>;
  31141. /**
  31142. * Observable triggered when reset has been called and applied to the camera.
  31143. */
  31144. onRestoreStateObservable: Observable<Camera>;
  31145. /** @hidden */
  31146. _cameraRigParams: any;
  31147. /** @hidden */
  31148. _rigCameras: Camera[];
  31149. /** @hidden */
  31150. _rigPostProcess: Nullable<PostProcess>;
  31151. protected _webvrViewMatrix: Matrix;
  31152. /** @hidden */
  31153. _skipRendering: boolean;
  31154. /** @hidden */
  31155. _projectionMatrix: Matrix;
  31156. /** @hidden */
  31157. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31158. /** @hidden */
  31159. _activeMeshes: SmartArray<AbstractMesh>;
  31160. protected _globalPosition: Vector3;
  31161. /** hidden */
  31162. _computedViewMatrix: Matrix;
  31163. private _doNotComputeProjectionMatrix;
  31164. private _transformMatrix;
  31165. private _frustumPlanes;
  31166. private _refreshFrustumPlanes;
  31167. private _storedFov;
  31168. private _stateStored;
  31169. /**
  31170. * Instantiates a new camera object.
  31171. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31172. * @see http://doc.babylonjs.com/features/cameras
  31173. * @param name Defines the name of the camera in the scene
  31174. * @param position Defines the position of the camera
  31175. * @param scene Defines the scene the camera belongs too
  31176. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31177. */
  31178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31179. /**
  31180. * Store current camera state (fov, position, etc..)
  31181. * @returns the camera
  31182. */
  31183. storeState(): Camera;
  31184. /**
  31185. * Restores the camera state values if it has been stored. You must call storeState() first
  31186. */
  31187. protected _restoreStateValues(): boolean;
  31188. /**
  31189. * Restored camera state. You must call storeState() first.
  31190. * @returns true if restored and false otherwise
  31191. */
  31192. restoreState(): boolean;
  31193. /**
  31194. * Gets the class name of the camera.
  31195. * @returns the class name
  31196. */
  31197. getClassName(): string;
  31198. /** @hidden */
  31199. readonly _isCamera: boolean;
  31200. /**
  31201. * Gets a string representation of the camera useful for debug purpose.
  31202. * @param fullDetails Defines that a more verboe level of logging is required
  31203. * @returns the string representation
  31204. */
  31205. toString(fullDetails?: boolean): string;
  31206. /**
  31207. * Gets the current world space position of the camera.
  31208. */
  31209. readonly globalPosition: Vector3;
  31210. /**
  31211. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31212. * @returns the active meshe list
  31213. */
  31214. getActiveMeshes(): SmartArray<AbstractMesh>;
  31215. /**
  31216. * Check wether a mesh is part of the current active mesh list of the camera
  31217. * @param mesh Defines the mesh to check
  31218. * @returns true if active, false otherwise
  31219. */
  31220. isActiveMesh(mesh: Mesh): boolean;
  31221. /**
  31222. * Is this camera ready to be used/rendered
  31223. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31224. * @return true if the camera is ready
  31225. */
  31226. isReady(completeCheck?: boolean): boolean;
  31227. /** @hidden */
  31228. _initCache(): void;
  31229. /** @hidden */
  31230. _updateCache(ignoreParentClass?: boolean): void;
  31231. /** @hidden */
  31232. _isSynchronized(): boolean;
  31233. /** @hidden */
  31234. _isSynchronizedViewMatrix(): boolean;
  31235. /** @hidden */
  31236. _isSynchronizedProjectionMatrix(): boolean;
  31237. /**
  31238. * Attach the input controls to a specific dom element to get the input from.
  31239. * @param element Defines the element the controls should be listened from
  31240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31241. */
  31242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31243. /**
  31244. * Detach the current controls from the specified dom element.
  31245. * @param element Defines the element to stop listening the inputs from
  31246. */
  31247. detachControl(element: HTMLElement): void;
  31248. /**
  31249. * Update the camera state according to the different inputs gathered during the frame.
  31250. */
  31251. update(): void;
  31252. /** @hidden */
  31253. _checkInputs(): void;
  31254. /** @hidden */
  31255. readonly rigCameras: Camera[];
  31256. /**
  31257. * Gets the post process used by the rig cameras
  31258. */
  31259. readonly rigPostProcess: Nullable<PostProcess>;
  31260. /**
  31261. * Internal, gets the first post proces.
  31262. * @returns the first post process to be run on this camera.
  31263. */
  31264. _getFirstPostProcess(): Nullable<PostProcess>;
  31265. private _cascadePostProcessesToRigCams;
  31266. /**
  31267. * Attach a post process to the camera.
  31268. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31269. * @param postProcess The post process to attach to the camera
  31270. * @param insertAt The position of the post process in case several of them are in use in the scene
  31271. * @returns the position the post process has been inserted at
  31272. */
  31273. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31274. /**
  31275. * Detach a post process to the camera.
  31276. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31277. * @param postProcess The post process to detach from the camera
  31278. */
  31279. detachPostProcess(postProcess: PostProcess): void;
  31280. /**
  31281. * Gets the current world matrix of the camera
  31282. */
  31283. getWorldMatrix(): Matrix;
  31284. /** @hidden */
  31285. _getViewMatrix(): Matrix;
  31286. /**
  31287. * Gets the current view matrix of the camera.
  31288. * @param force forces the camera to recompute the matrix without looking at the cached state
  31289. * @returns the view matrix
  31290. */
  31291. getViewMatrix(force?: boolean): Matrix;
  31292. /**
  31293. * Freeze the projection matrix.
  31294. * It will prevent the cache check of the camera projection compute and can speed up perf
  31295. * if no parameter of the camera are meant to change
  31296. * @param projection Defines manually a projection if necessary
  31297. */
  31298. freezeProjectionMatrix(projection?: Matrix): void;
  31299. /**
  31300. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31301. */
  31302. unfreezeProjectionMatrix(): void;
  31303. /**
  31304. * Gets the current projection matrix of the camera.
  31305. * @param force forces the camera to recompute the matrix without looking at the cached state
  31306. * @returns the projection matrix
  31307. */
  31308. getProjectionMatrix(force?: boolean): Matrix;
  31309. /**
  31310. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31311. * @returns a Matrix
  31312. */
  31313. getTransformationMatrix(): Matrix;
  31314. private _updateFrustumPlanes;
  31315. /**
  31316. * Checks if a cullable object (mesh...) is in the camera frustum
  31317. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31318. * @param target The object to check
  31319. * @returns true if the object is in frustum otherwise false
  31320. */
  31321. isInFrustum(target: ICullable): boolean;
  31322. /**
  31323. * Checks if a cullable object (mesh...) is in the camera frustum
  31324. * Unlike isInFrustum this cheks the full bounding box
  31325. * @param target The object to check
  31326. * @returns true if the object is in frustum otherwise false
  31327. */
  31328. isCompletelyInFrustum(target: ICullable): boolean;
  31329. /**
  31330. * Gets a ray in the forward direction from the camera.
  31331. * @param length Defines the length of the ray to create
  31332. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31333. * @param origin Defines the start point of the ray which defaults to the camera position
  31334. * @returns the forward ray
  31335. */
  31336. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31337. /**
  31338. * Releases resources associated with this node.
  31339. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31340. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31341. */
  31342. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31343. /** @hidden */
  31344. _isLeftCamera: boolean;
  31345. /**
  31346. * Gets the left camera of a rig setup in case of Rigged Camera
  31347. */
  31348. readonly isLeftCamera: boolean;
  31349. /** @hidden */
  31350. _isRightCamera: boolean;
  31351. /**
  31352. * Gets the right camera of a rig setup in case of Rigged Camera
  31353. */
  31354. readonly isRightCamera: boolean;
  31355. /**
  31356. * Gets the left camera of a rig setup in case of Rigged Camera
  31357. */
  31358. readonly leftCamera: Nullable<FreeCamera>;
  31359. /**
  31360. * Gets the right camera of a rig setup in case of Rigged Camera
  31361. */
  31362. readonly rightCamera: Nullable<FreeCamera>;
  31363. /**
  31364. * Gets the left camera target of a rig setup in case of Rigged Camera
  31365. * @returns the target position
  31366. */
  31367. getLeftTarget(): Nullable<Vector3>;
  31368. /**
  31369. * Gets the right camera target of a rig setup in case of Rigged Camera
  31370. * @returns the target position
  31371. */
  31372. getRightTarget(): Nullable<Vector3>;
  31373. /**
  31374. * @hidden
  31375. */
  31376. setCameraRigMode(mode: number, rigParams: any): void;
  31377. /** @hidden */
  31378. static _setStereoscopicRigMode(camera: Camera): void;
  31379. /** @hidden */
  31380. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31381. /** @hidden */
  31382. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31383. /** @hidden */
  31384. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31385. /** @hidden */
  31386. _getVRProjectionMatrix(): Matrix;
  31387. protected _updateCameraRotationMatrix(): void;
  31388. protected _updateWebVRCameraRotationMatrix(): void;
  31389. /**
  31390. * This function MUST be overwritten by the different WebVR cameras available.
  31391. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31392. * @hidden
  31393. */
  31394. _getWebVRProjectionMatrix(): Matrix;
  31395. /**
  31396. * This function MUST be overwritten by the different WebVR cameras available.
  31397. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31398. * @hidden
  31399. */
  31400. _getWebVRViewMatrix(): Matrix;
  31401. /** @hidden */
  31402. setCameraRigParameter(name: string, value: any): void;
  31403. /**
  31404. * needs to be overridden by children so sub has required properties to be copied
  31405. * @hidden
  31406. */
  31407. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31408. /**
  31409. * May need to be overridden by children
  31410. * @hidden
  31411. */
  31412. _updateRigCameras(): void;
  31413. /** @hidden */
  31414. _setupInputs(): void;
  31415. /**
  31416. * Serialiaze the camera setup to a json represention
  31417. * @returns the JSON representation
  31418. */
  31419. serialize(): any;
  31420. /**
  31421. * Clones the current camera.
  31422. * @param name The cloned camera name
  31423. * @returns the cloned camera
  31424. */
  31425. clone(name: string): Camera;
  31426. /**
  31427. * Gets the direction of the camera relative to a given local axis.
  31428. * @param localAxis Defines the reference axis to provide a relative direction.
  31429. * @return the direction
  31430. */
  31431. getDirection(localAxis: Vector3): Vector3;
  31432. /**
  31433. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31434. * @param localAxis Defines the reference axis to provide a relative direction.
  31435. * @param result Defines the vector to store the result in
  31436. */
  31437. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31438. /**
  31439. * Gets a camera constructor for a given camera type
  31440. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31441. * @param name The name of the camera the result will be able to instantiate
  31442. * @param scene The scene the result will construct the camera in
  31443. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31444. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31445. * @returns a factory method to construc the camera
  31446. */
  31447. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31448. /**
  31449. * Compute the world matrix of the camera.
  31450. * @returns the camera workd matrix
  31451. */
  31452. computeWorldMatrix(): Matrix;
  31453. /**
  31454. * Parse a JSON and creates the camera from the parsed information
  31455. * @param parsedCamera The JSON to parse
  31456. * @param scene The scene to instantiate the camera in
  31457. * @returns the newly constructed camera
  31458. */
  31459. static Parse(parsedCamera: any, scene: Scene): Camera;
  31460. }
  31461. }
  31462. declare module "babylonjs/Misc/tools" {
  31463. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31464. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31466. import { Observable } from "babylonjs/Misc/observable";
  31467. import { DomManagement } from "babylonjs/Misc/domManagement";
  31468. import { WebRequest } from "babylonjs/Misc/webRequest";
  31469. import { Camera } from "babylonjs/Cameras/camera";
  31470. import { Engine } from "babylonjs/Engines/engine";
  31471. import { Animation } from "babylonjs/Animations/animation";
  31472. /**
  31473. * Interface for any object that can request an animation frame
  31474. */
  31475. export interface ICustomAnimationFrameRequester {
  31476. /**
  31477. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31478. */
  31479. renderFunction?: Function;
  31480. /**
  31481. * Called to request the next frame to render to
  31482. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31483. */
  31484. requestAnimationFrame: Function;
  31485. /**
  31486. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31487. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31488. */
  31489. requestID?: number;
  31490. }
  31491. /**
  31492. * Interface containing an array of animations
  31493. */
  31494. export interface IAnimatable {
  31495. /**
  31496. * Array of animations
  31497. */
  31498. animations: Nullable<Array<Animation>>;
  31499. }
  31500. /** Interface used by value gradients (color, factor, ...) */
  31501. export interface IValueGradient {
  31502. /**
  31503. * Gets or sets the gradient value (between 0 and 1)
  31504. */
  31505. gradient: number;
  31506. }
  31507. /** Class used to store color4 gradient */
  31508. export class ColorGradient implements IValueGradient {
  31509. /**
  31510. * Gets or sets the gradient value (between 0 and 1)
  31511. */
  31512. gradient: number;
  31513. /**
  31514. * Gets or sets first associated color
  31515. */
  31516. color1: Color4;
  31517. /**
  31518. * Gets or sets second associated color
  31519. */
  31520. color2?: Color4;
  31521. /**
  31522. * Will get a color picked randomly between color1 and color2.
  31523. * If color2 is undefined then color1 will be used
  31524. * @param result defines the target Color4 to store the result in
  31525. */
  31526. getColorToRef(result: Color4): void;
  31527. }
  31528. /** Class used to store color 3 gradient */
  31529. export class Color3Gradient implements IValueGradient {
  31530. /**
  31531. * Gets or sets the gradient value (between 0 and 1)
  31532. */
  31533. gradient: number;
  31534. /**
  31535. * Gets or sets the associated color
  31536. */
  31537. color: Color3;
  31538. }
  31539. /** Class used to store factor gradient */
  31540. export class FactorGradient implements IValueGradient {
  31541. /**
  31542. * Gets or sets the gradient value (between 0 and 1)
  31543. */
  31544. gradient: number;
  31545. /**
  31546. * Gets or sets first associated factor
  31547. */
  31548. factor1: number;
  31549. /**
  31550. * Gets or sets second associated factor
  31551. */
  31552. factor2?: number;
  31553. /**
  31554. * Will get a number picked randomly between factor1 and factor2.
  31555. * If factor2 is undefined then factor1 will be used
  31556. * @returns the picked number
  31557. */
  31558. getFactor(): number;
  31559. }
  31560. /**
  31561. * @ignore
  31562. * Application error to support additional information when loading a file
  31563. */
  31564. export class LoadFileError extends Error {
  31565. /** defines the optional web request */
  31566. request?: WebRequest | undefined;
  31567. private static _setPrototypeOf;
  31568. /**
  31569. * Creates a new LoadFileError
  31570. * @param message defines the message of the error
  31571. * @param request defines the optional web request
  31572. */
  31573. constructor(message: string,
  31574. /** defines the optional web request */
  31575. request?: WebRequest | undefined);
  31576. }
  31577. /**
  31578. * Class used to define a retry strategy when error happens while loading assets
  31579. */
  31580. export class RetryStrategy {
  31581. /**
  31582. * Function used to defines an exponential back off strategy
  31583. * @param maxRetries defines the maximum number of retries (3 by default)
  31584. * @param baseInterval defines the interval between retries
  31585. * @returns the strategy function to use
  31586. */
  31587. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31588. }
  31589. /**
  31590. * File request interface
  31591. */
  31592. export interface IFileRequest {
  31593. /**
  31594. * Raised when the request is complete (success or error).
  31595. */
  31596. onCompleteObservable: Observable<IFileRequest>;
  31597. /**
  31598. * Aborts the request for a file.
  31599. */
  31600. abort: () => void;
  31601. }
  31602. /**
  31603. * Class containing a set of static utilities functions
  31604. */
  31605. export class Tools {
  31606. /**
  31607. * Gets or sets the base URL to use to load assets
  31608. */
  31609. static BaseUrl: string;
  31610. /**
  31611. * Enable/Disable Custom HTTP Request Headers globally.
  31612. * default = false
  31613. * @see CustomRequestHeaders
  31614. */
  31615. static UseCustomRequestHeaders: boolean;
  31616. /**
  31617. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31618. * i.e. when loading files, where the server/service expects an Authorization header
  31619. */
  31620. static CustomRequestHeaders: {
  31621. [key: string]: string;
  31622. };
  31623. /**
  31624. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31625. */
  31626. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31627. /**
  31628. * Default behaviour for cors in the application.
  31629. * It can be a string if the expected behavior is identical in the entire app.
  31630. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31631. */
  31632. static CorsBehavior: string | ((url: string | string[]) => string);
  31633. /**
  31634. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31635. * @ignorenaming
  31636. */
  31637. static UseFallbackTexture: boolean;
  31638. /**
  31639. * Use this object to register external classes like custom textures or material
  31640. * to allow the laoders to instantiate them
  31641. */
  31642. static RegisteredExternalClasses: {
  31643. [key: string]: Object;
  31644. };
  31645. /**
  31646. * Texture content used if a texture cannot loaded
  31647. * @ignorenaming
  31648. */
  31649. static fallbackTexture: string;
  31650. /**
  31651. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31652. * @param u defines the coordinate on X axis
  31653. * @param v defines the coordinate on Y axis
  31654. * @param width defines the width of the source data
  31655. * @param height defines the height of the source data
  31656. * @param pixels defines the source byte array
  31657. * @param color defines the output color
  31658. */
  31659. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31660. /**
  31661. * Interpolates between a and b via alpha
  31662. * @param a The lower value (returned when alpha = 0)
  31663. * @param b The upper value (returned when alpha = 1)
  31664. * @param alpha The interpolation-factor
  31665. * @return The mixed value
  31666. */
  31667. static Mix(a: number, b: number, alpha: number): number;
  31668. /**
  31669. * Tries to instantiate a new object from a given class name
  31670. * @param className defines the class name to instantiate
  31671. * @returns the new object or null if the system was not able to do the instantiation
  31672. */
  31673. static Instantiate(className: string): any;
  31674. /**
  31675. * Provides a slice function that will work even on IE
  31676. * @param data defines the array to slice
  31677. * @param start defines the start of the data (optional)
  31678. * @param end defines the end of the data (optional)
  31679. * @returns the new sliced array
  31680. */
  31681. static Slice<T>(data: T, start?: number, end?: number): T;
  31682. /**
  31683. * Polyfill for setImmediate
  31684. * @param action defines the action to execute after the current execution block
  31685. */
  31686. static SetImmediate(action: () => void): void;
  31687. /**
  31688. * Function indicating if a number is an exponent of 2
  31689. * @param value defines the value to test
  31690. * @returns true if the value is an exponent of 2
  31691. */
  31692. static IsExponentOfTwo(value: number): boolean;
  31693. private static _tmpFloatArray;
  31694. /**
  31695. * Returns the nearest 32-bit single precision float representation of a Number
  31696. * @param value A Number. If the parameter is of a different type, it will get converted
  31697. * to a number or to NaN if it cannot be converted
  31698. * @returns number
  31699. */
  31700. static FloatRound(value: number): number;
  31701. /**
  31702. * Find the next highest power of two.
  31703. * @param x Number to start search from.
  31704. * @return Next highest power of two.
  31705. */
  31706. static CeilingPOT(x: number): number;
  31707. /**
  31708. * Find the next lowest power of two.
  31709. * @param x Number to start search from.
  31710. * @return Next lowest power of two.
  31711. */
  31712. static FloorPOT(x: number): number;
  31713. /**
  31714. * Find the nearest power of two.
  31715. * @param x Number to start search from.
  31716. * @return Next nearest power of two.
  31717. */
  31718. static NearestPOT(x: number): number;
  31719. /**
  31720. * Get the closest exponent of two
  31721. * @param value defines the value to approximate
  31722. * @param max defines the maximum value to return
  31723. * @param mode defines how to define the closest value
  31724. * @returns closest exponent of two of the given value
  31725. */
  31726. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31727. /**
  31728. * Extracts the filename from a path
  31729. * @param path defines the path to use
  31730. * @returns the filename
  31731. */
  31732. static GetFilename(path: string): string;
  31733. /**
  31734. * Extracts the "folder" part of a path (everything before the filename).
  31735. * @param uri The URI to extract the info from
  31736. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31737. * @returns The "folder" part of the path
  31738. */
  31739. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31740. /**
  31741. * Extracts text content from a DOM element hierarchy
  31742. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31743. */
  31744. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31745. /**
  31746. * Convert an angle in radians to degrees
  31747. * @param angle defines the angle to convert
  31748. * @returns the angle in degrees
  31749. */
  31750. static ToDegrees(angle: number): number;
  31751. /**
  31752. * Convert an angle in degrees to radians
  31753. * @param angle defines the angle to convert
  31754. * @returns the angle in radians
  31755. */
  31756. static ToRadians(angle: number): number;
  31757. /**
  31758. * Encode a buffer to a base64 string
  31759. * @param buffer defines the buffer to encode
  31760. * @returns the encoded string
  31761. */
  31762. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31763. /**
  31764. * Extracts minimum and maximum values from a list of indexed positions
  31765. * @param positions defines the positions to use
  31766. * @param indices defines the indices to the positions
  31767. * @param indexStart defines the start index
  31768. * @param indexCount defines the end index
  31769. * @param bias defines bias value to add to the result
  31770. * @return minimum and maximum values
  31771. */
  31772. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31773. minimum: Vector3;
  31774. maximum: Vector3;
  31775. };
  31776. /**
  31777. * Extracts minimum and maximum values from a list of positions
  31778. * @param positions defines the positions to use
  31779. * @param start defines the start index in the positions array
  31780. * @param count defines the number of positions to handle
  31781. * @param bias defines bias value to add to the result
  31782. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31783. * @return minimum and maximum values
  31784. */
  31785. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31786. minimum: Vector3;
  31787. maximum: Vector3;
  31788. };
  31789. /**
  31790. * Returns an array if obj is not an array
  31791. * @param obj defines the object to evaluate as an array
  31792. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31793. * @returns either obj directly if obj is an array or a new array containing obj
  31794. */
  31795. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31796. /**
  31797. * Gets the pointer prefix to use
  31798. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31799. */
  31800. static GetPointerPrefix(): string;
  31801. /**
  31802. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31803. * @param func - the function to be called
  31804. * @param requester - the object that will request the next frame. Falls back to window.
  31805. * @returns frame number
  31806. */
  31807. static QueueNewFrame(func: () => void, requester?: any): number;
  31808. /**
  31809. * Ask the browser to promote the current element to fullscreen rendering mode
  31810. * @param element defines the DOM element to promote
  31811. */
  31812. static RequestFullscreen(element: HTMLElement): void;
  31813. /**
  31814. * Asks the browser to exit fullscreen mode
  31815. */
  31816. static ExitFullscreen(): void;
  31817. /**
  31818. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31819. * @param url define the url we are trying
  31820. * @param element define the dom element where to configure the cors policy
  31821. */
  31822. static SetCorsBehavior(url: string | string[], element: {
  31823. crossOrigin: string | null;
  31824. }): void;
  31825. /**
  31826. * Removes unwanted characters from an url
  31827. * @param url defines the url to clean
  31828. * @returns the cleaned url
  31829. */
  31830. static CleanUrl(url: string): string;
  31831. /**
  31832. * Gets or sets a function used to pre-process url before using them to load assets
  31833. */
  31834. static PreprocessUrl: (url: string) => string;
  31835. /**
  31836. * Loads an image as an HTMLImageElement.
  31837. * @param input url string, ArrayBuffer, or Blob to load
  31838. * @param onLoad callback called when the image successfully loads
  31839. * @param onError callback called when the image fails to load
  31840. * @param offlineProvider offline provider for caching
  31841. * @returns the HTMLImageElement of the loaded image
  31842. */
  31843. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31844. /**
  31845. * Loads a file
  31846. * @param url url string, ArrayBuffer, or Blob to load
  31847. * @param onSuccess callback called when the file successfully loads
  31848. * @param onProgress callback called while file is loading (if the server supports this mode)
  31849. * @param offlineProvider defines the offline provider for caching
  31850. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31851. * @param onError callback called when the file fails to load
  31852. * @returns a file request object
  31853. */
  31854. 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;
  31855. /**
  31856. * Load a script (identified by an url). When the url returns, the
  31857. * content of this file is added into a new script element, attached to the DOM (body element)
  31858. * @param scriptUrl defines the url of the script to laod
  31859. * @param onSuccess defines the callback called when the script is loaded
  31860. * @param onError defines the callback to call if an error occurs
  31861. * @param scriptId defines the id of the script element
  31862. */
  31863. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31864. /**
  31865. * Load an asynchronous script (identified by an url). When the url returns, the
  31866. * content of this file is added into a new script element, attached to the DOM (body element)
  31867. * @param scriptUrl defines the url of the script to laod
  31868. * @param scriptId defines the id of the script element
  31869. * @returns a promise request object
  31870. */
  31871. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31872. /**
  31873. * Loads a file from a blob
  31874. * @param fileToLoad defines the blob to use
  31875. * @param callback defines the callback to call when data is loaded
  31876. * @param progressCallback defines the callback to call during loading process
  31877. * @returns a file request object
  31878. */
  31879. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31880. /**
  31881. * Loads a file
  31882. * @param fileToLoad defines the file to load
  31883. * @param callback defines the callback to call when data is loaded
  31884. * @param progressCallBack defines the callback to call during loading process
  31885. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31886. * @returns a file request object
  31887. */
  31888. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31889. /**
  31890. * Creates a data url from a given string content
  31891. * @param content defines the content to convert
  31892. * @returns the new data url link
  31893. */
  31894. static FileAsURL(content: string): string;
  31895. /**
  31896. * Format the given number to a specific decimal format
  31897. * @param value defines the number to format
  31898. * @param decimals defines the number of decimals to use
  31899. * @returns the formatted string
  31900. */
  31901. static Format(value: number, decimals?: number): string;
  31902. /**
  31903. * Checks if a given vector is inside a specific range
  31904. * @param v defines the vector to test
  31905. * @param min defines the minimum range
  31906. * @param max defines the maximum range
  31907. */
  31908. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31909. /**
  31910. * Tries to copy an object by duplicating every property
  31911. * @param source defines the source object
  31912. * @param destination defines the target object
  31913. * @param doNotCopyList defines a list of properties to avoid
  31914. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31915. */
  31916. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31917. /**
  31918. * Gets a boolean indicating if the given object has no own property
  31919. * @param obj defines the object to test
  31920. * @returns true if object has no own property
  31921. */
  31922. static IsEmpty(obj: any): boolean;
  31923. /**
  31924. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31925. * @param str Source string
  31926. * @param suffix Suffix to search for in the source string
  31927. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31928. */
  31929. static EndsWith(str: string, suffix: string): boolean;
  31930. /**
  31931. * Function used to register events at window level
  31932. * @param events defines the events to register
  31933. */
  31934. static RegisterTopRootEvents(events: {
  31935. name: string;
  31936. handler: Nullable<(e: FocusEvent) => any>;
  31937. }[]): void;
  31938. /**
  31939. * Function used to unregister events from window level
  31940. * @param events defines the events to unregister
  31941. */
  31942. static UnregisterTopRootEvents(events: {
  31943. name: string;
  31944. handler: Nullable<(e: FocusEvent) => any>;
  31945. }[]): void;
  31946. /**
  31947. * @ignore
  31948. */
  31949. static _ScreenshotCanvas: HTMLCanvasElement;
  31950. /**
  31951. * Dumps the current bound framebuffer
  31952. * @param width defines the rendering width
  31953. * @param height defines the rendering height
  31954. * @param engine defines the hosting engine
  31955. * @param successCallback defines the callback triggered once the data are available
  31956. * @param mimeType defines the mime type of the result
  31957. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31958. */
  31959. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31960. /**
  31961. * Converts the canvas data to blob.
  31962. * This acts as a polyfill for browsers not supporting the to blob function.
  31963. * @param canvas Defines the canvas to extract the data from
  31964. * @param successCallback Defines the callback triggered once the data are available
  31965. * @param mimeType Defines the mime type of the result
  31966. */
  31967. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31968. /**
  31969. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31970. * @param successCallback defines the callback triggered once the data are available
  31971. * @param mimeType defines the mime type of the result
  31972. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31973. */
  31974. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31975. /**
  31976. * Downloads a blob in the browser
  31977. * @param blob defines the blob to download
  31978. * @param fileName defines the name of the downloaded file
  31979. */
  31980. static Download(blob: Blob, fileName: string): void;
  31981. /**
  31982. * Captures a screenshot of the current rendering
  31983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31984. * @param engine defines the rendering engine
  31985. * @param camera defines the source camera
  31986. * @param size This parameter can be set to a single number or to an object with the
  31987. * following (optional) properties: precision, width, height. If a single number is passed,
  31988. * it will be used for both width and height. If an object is passed, the screenshot size
  31989. * will be derived from the parameters. The precision property is a multiplier allowing
  31990. * rendering at a higher or lower resolution
  31991. * @param successCallback defines the callback receives a single parameter which contains the
  31992. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31993. * src parameter of an <img> to display it
  31994. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31995. * Check your browser for supported MIME types
  31996. */
  31997. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31998. /**
  31999. * Generates an image screenshot from the specified camera.
  32000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32001. * @param engine The engine to use for rendering
  32002. * @param camera The camera to use for rendering
  32003. * @param size This parameter can be set to a single number or to an object with the
  32004. * following (optional) properties: precision, width, height. If a single number is passed,
  32005. * it will be used for both width and height. If an object is passed, the screenshot size
  32006. * will be derived from the parameters. The precision property is a multiplier allowing
  32007. * rendering at a higher or lower resolution
  32008. * @param successCallback The callback receives a single parameter which contains the
  32009. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32010. * src parameter of an <img> to display it
  32011. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32012. * Check your browser for supported MIME types
  32013. * @param samples Texture samples (default: 1)
  32014. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32015. * @param fileName A name for for the downloaded file.
  32016. */
  32017. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32018. /**
  32019. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32020. * Be aware Math.random() could cause collisions, but:
  32021. * "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"
  32022. * @returns a pseudo random id
  32023. */
  32024. static RandomId(): string;
  32025. /**
  32026. * Test if the given uri is a base64 string
  32027. * @param uri The uri to test
  32028. * @return True if the uri is a base64 string or false otherwise
  32029. */
  32030. static IsBase64(uri: string): boolean;
  32031. /**
  32032. * Decode the given base64 uri.
  32033. * @param uri The uri to decode
  32034. * @return The decoded base64 data.
  32035. */
  32036. static DecodeBase64(uri: string): ArrayBuffer;
  32037. /**
  32038. * Gets the absolute url.
  32039. * @param url the input url
  32040. * @return the absolute url
  32041. */
  32042. static GetAbsoluteUrl(url: string): string;
  32043. /**
  32044. * No log
  32045. */
  32046. static readonly NoneLogLevel: number;
  32047. /**
  32048. * Only message logs
  32049. */
  32050. static readonly MessageLogLevel: number;
  32051. /**
  32052. * Only warning logs
  32053. */
  32054. static readonly WarningLogLevel: number;
  32055. /**
  32056. * Only error logs
  32057. */
  32058. static readonly ErrorLogLevel: number;
  32059. /**
  32060. * All logs
  32061. */
  32062. static readonly AllLogLevel: number;
  32063. /**
  32064. * Gets a value indicating the number of loading errors
  32065. * @ignorenaming
  32066. */
  32067. static readonly errorsCount: number;
  32068. /**
  32069. * Callback called when a new log is added
  32070. */
  32071. static OnNewCacheEntry: (entry: string) => void;
  32072. /**
  32073. * Log a message to the console
  32074. * @param message defines the message to log
  32075. */
  32076. static Log(message: string): void;
  32077. /**
  32078. * Write a warning message to the console
  32079. * @param message defines the message to log
  32080. */
  32081. static Warn(message: string): void;
  32082. /**
  32083. * Write an error message to the console
  32084. * @param message defines the message to log
  32085. */
  32086. static Error(message: string): void;
  32087. /**
  32088. * Gets current log cache (list of logs)
  32089. */
  32090. static readonly LogCache: string;
  32091. /**
  32092. * Clears the log cache
  32093. */
  32094. static ClearLogCache(): void;
  32095. /**
  32096. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32097. */
  32098. static LogLevels: number;
  32099. /**
  32100. * Checks if the loaded document was accessed via `file:`-Protocol.
  32101. * @returns boolean
  32102. */
  32103. static IsFileURL(): boolean;
  32104. /**
  32105. * Checks if the window object exists
  32106. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32107. */
  32108. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32109. /**
  32110. * No performance log
  32111. */
  32112. static readonly PerformanceNoneLogLevel: number;
  32113. /**
  32114. * Use user marks to log performance
  32115. */
  32116. static readonly PerformanceUserMarkLogLevel: number;
  32117. /**
  32118. * Log performance to the console
  32119. */
  32120. static readonly PerformanceConsoleLogLevel: number;
  32121. private static _performance;
  32122. /**
  32123. * Sets the current performance log level
  32124. */
  32125. static PerformanceLogLevel: number;
  32126. private static _StartPerformanceCounterDisabled;
  32127. private static _EndPerformanceCounterDisabled;
  32128. private static _StartUserMark;
  32129. private static _EndUserMark;
  32130. private static _StartPerformanceConsole;
  32131. private static _EndPerformanceConsole;
  32132. /**
  32133. * Starts a performance counter
  32134. */
  32135. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32136. /**
  32137. * Ends a specific performance coutner
  32138. */
  32139. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32140. /**
  32141. * Gets either window.performance.now() if supported or Date.now() else
  32142. */
  32143. static readonly Now: number;
  32144. /**
  32145. * This method will return the name of the class used to create the instance of the given object.
  32146. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32147. * @param object the object to get the class name from
  32148. * @param isType defines if the object is actually a type
  32149. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32150. */
  32151. static GetClassName(object: any, isType?: boolean): string;
  32152. /**
  32153. * Gets the first element of an array satisfying a given predicate
  32154. * @param array defines the array to browse
  32155. * @param predicate defines the predicate to use
  32156. * @returns null if not found or the element
  32157. */
  32158. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32159. /**
  32160. * This method will return the name of the full name of the class, including its owning module (if any).
  32161. * 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).
  32162. * @param object the object to get the class name from
  32163. * @param isType defines if the object is actually a type
  32164. * @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.
  32165. * @ignorenaming
  32166. */
  32167. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32168. /**
  32169. * Returns a promise that resolves after the given amount of time.
  32170. * @param delay Number of milliseconds to delay
  32171. * @returns Promise that resolves after the given amount of time
  32172. */
  32173. static DelayAsync(delay: number): Promise<void>;
  32174. /**
  32175. * Gets the current gradient from an array of IValueGradient
  32176. * @param ratio defines the current ratio to get
  32177. * @param gradients defines the array of IValueGradient
  32178. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32179. */
  32180. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32181. }
  32182. /**
  32183. * This class is used to track a performance counter which is number based.
  32184. * The user has access to many properties which give statistics of different nature.
  32185. *
  32186. * The implementer can track two kinds of Performance Counter: time and count.
  32187. * 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.
  32188. * 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.
  32189. */
  32190. export class PerfCounter {
  32191. /**
  32192. * Gets or sets a global boolean to turn on and off all the counters
  32193. */
  32194. static Enabled: boolean;
  32195. /**
  32196. * Returns the smallest value ever
  32197. */
  32198. readonly min: number;
  32199. /**
  32200. * Returns the biggest value ever
  32201. */
  32202. readonly max: number;
  32203. /**
  32204. * Returns the average value since the performance counter is running
  32205. */
  32206. readonly average: number;
  32207. /**
  32208. * Returns the average value of the last second the counter was monitored
  32209. */
  32210. readonly lastSecAverage: number;
  32211. /**
  32212. * Returns the current value
  32213. */
  32214. readonly current: number;
  32215. /**
  32216. * Gets the accumulated total
  32217. */
  32218. readonly total: number;
  32219. /**
  32220. * Gets the total value count
  32221. */
  32222. readonly count: number;
  32223. /**
  32224. * Creates a new counter
  32225. */
  32226. constructor();
  32227. /**
  32228. * Call this method to start monitoring a new frame.
  32229. * 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.
  32230. */
  32231. fetchNewFrame(): void;
  32232. /**
  32233. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32234. * @param newCount the count value to add to the monitored count
  32235. * @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.
  32236. */
  32237. addCount(newCount: number, fetchResult: boolean): void;
  32238. /**
  32239. * Start monitoring this performance counter
  32240. */
  32241. beginMonitoring(): void;
  32242. /**
  32243. * Compute the time lapsed since the previous beginMonitoring() call.
  32244. * @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
  32245. */
  32246. endMonitoring(newFrame?: boolean): void;
  32247. private _fetchResult;
  32248. private _startMonitoringTime;
  32249. private _min;
  32250. private _max;
  32251. private _average;
  32252. private _current;
  32253. private _totalValueCount;
  32254. private _totalAccumulated;
  32255. private _lastSecAverage;
  32256. private _lastSecAccumulated;
  32257. private _lastSecTime;
  32258. private _lastSecValueCount;
  32259. }
  32260. /**
  32261. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32262. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32263. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32264. * @param name The name of the class, case should be preserved
  32265. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32266. */
  32267. export function className(name: string, module?: string): (target: Object) => void;
  32268. /**
  32269. * An implementation of a loop for asynchronous functions.
  32270. */
  32271. export class AsyncLoop {
  32272. /**
  32273. * Defines the number of iterations for the loop
  32274. */
  32275. iterations: number;
  32276. /**
  32277. * Defines the current index of the loop.
  32278. */
  32279. index: number;
  32280. private _done;
  32281. private _fn;
  32282. private _successCallback;
  32283. /**
  32284. * Constructor.
  32285. * @param iterations the number of iterations.
  32286. * @param func the function to run each iteration
  32287. * @param successCallback the callback that will be called upon succesful execution
  32288. * @param offset starting offset.
  32289. */
  32290. constructor(
  32291. /**
  32292. * Defines the number of iterations for the loop
  32293. */
  32294. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32295. /**
  32296. * Execute the next iteration. Must be called after the last iteration was finished.
  32297. */
  32298. executeNext(): void;
  32299. /**
  32300. * Break the loop and run the success callback.
  32301. */
  32302. breakLoop(): void;
  32303. /**
  32304. * Create and run an async loop.
  32305. * @param iterations the number of iterations.
  32306. * @param fn the function to run each iteration
  32307. * @param successCallback the callback that will be called upon succesful execution
  32308. * @param offset starting offset.
  32309. * @returns the created async loop object
  32310. */
  32311. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32312. /**
  32313. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32314. * @param iterations total number of iterations
  32315. * @param syncedIterations number of synchronous iterations in each async iteration.
  32316. * @param fn the function to call each iteration.
  32317. * @param callback a success call back that will be called when iterating stops.
  32318. * @param breakFunction a break condition (optional)
  32319. * @param timeout timeout settings for the setTimeout function. default - 0.
  32320. * @returns the created async loop object
  32321. */
  32322. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32323. }
  32324. }
  32325. declare module "babylonjs/Collisions/collisionCoordinator" {
  32326. import { Nullable } from "babylonjs/types";
  32327. import { Scene } from "babylonjs/scene";
  32328. import { Vector3 } from "babylonjs/Maths/math";
  32329. import { Collider } from "babylonjs/Collisions/collider";
  32330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32331. /** @hidden */
  32332. export interface ICollisionCoordinator {
  32333. createCollider(): Collider;
  32334. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32335. init(scene: Scene): void;
  32336. }
  32337. /** @hidden */
  32338. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32339. private _scene;
  32340. private _scaledPosition;
  32341. private _scaledVelocity;
  32342. private _finalPosition;
  32343. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32344. createCollider(): Collider;
  32345. init(scene: Scene): void;
  32346. private _collideWithWorld;
  32347. }
  32348. }
  32349. declare module "babylonjs/Inputs/scene.inputManager" {
  32350. import { Nullable } from "babylonjs/types";
  32351. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32352. import { Vector2 } from "babylonjs/Maths/math";
  32353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32354. import { Scene } from "babylonjs/scene";
  32355. /**
  32356. * Class used to manage all inputs for the scene.
  32357. */
  32358. export class InputManager {
  32359. /** The distance in pixel that you have to move to prevent some events */
  32360. static DragMovementThreshold: number;
  32361. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32362. static LongPressDelay: number;
  32363. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32364. static DoubleClickDelay: number;
  32365. /** If you need to check double click without raising a single click at first click, enable this flag */
  32366. static ExclusiveDoubleClickMode: boolean;
  32367. private _wheelEventName;
  32368. private _onPointerMove;
  32369. private _onPointerDown;
  32370. private _onPointerUp;
  32371. private _initClickEvent;
  32372. private _initActionManager;
  32373. private _delayedSimpleClick;
  32374. private _delayedSimpleClickTimeout;
  32375. private _previousDelayedSimpleClickTimeout;
  32376. private _meshPickProceed;
  32377. private _previousButtonPressed;
  32378. private _currentPickResult;
  32379. private _previousPickResult;
  32380. private _totalPointersPressed;
  32381. private _doubleClickOccured;
  32382. private _pointerOverMesh;
  32383. private _pickedDownMesh;
  32384. private _pickedUpMesh;
  32385. private _pointerX;
  32386. private _pointerY;
  32387. private _unTranslatedPointerX;
  32388. private _unTranslatedPointerY;
  32389. private _startingPointerPosition;
  32390. private _previousStartingPointerPosition;
  32391. private _startingPointerTime;
  32392. private _previousStartingPointerTime;
  32393. private _pointerCaptures;
  32394. private _onKeyDown;
  32395. private _onKeyUp;
  32396. private _onCanvasFocusObserver;
  32397. private _onCanvasBlurObserver;
  32398. private _scene;
  32399. /**
  32400. * Creates a new InputManager
  32401. * @param scene defines the hosting scene
  32402. */
  32403. constructor(scene: Scene);
  32404. /**
  32405. * Gets the mesh that is currently under the pointer
  32406. */
  32407. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32408. /**
  32409. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32410. */
  32411. readonly unTranslatedPointer: Vector2;
  32412. /**
  32413. * Gets or sets the current on-screen X position of the pointer
  32414. */
  32415. pointerX: number;
  32416. /**
  32417. * Gets or sets the current on-screen Y position of the pointer
  32418. */
  32419. pointerY: number;
  32420. private _updatePointerPosition;
  32421. private _processPointerMove;
  32422. private _setRayOnPointerInfo;
  32423. private _checkPrePointerObservable;
  32424. /**
  32425. * Use this method to simulate a pointer move on a mesh
  32426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32429. */
  32430. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32431. /**
  32432. * Use this method to simulate a pointer down on a mesh
  32433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32436. */
  32437. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32438. private _processPointerDown;
  32439. /** @hidden */
  32440. _isPointerSwiping(): boolean;
  32441. /**
  32442. * Use this method to simulate a pointer up on a mesh
  32443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32446. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32447. */
  32448. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32449. private _processPointerUp;
  32450. /**
  32451. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32452. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32453. * @returns true if the pointer was captured
  32454. */
  32455. isPointerCaptured(pointerId?: number): boolean;
  32456. /**
  32457. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32458. * @param attachUp defines if you want to attach events to pointerup
  32459. * @param attachDown defines if you want to attach events to pointerdown
  32460. * @param attachMove defines if you want to attach events to pointermove
  32461. */
  32462. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32463. /**
  32464. * Detaches all event handlers
  32465. */
  32466. detachControl(): void;
  32467. /**
  32468. * Force the value of meshUnderPointer
  32469. * @param mesh defines the mesh to use
  32470. */
  32471. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32472. /**
  32473. * Gets the mesh under the pointer
  32474. * @returns a Mesh or null if no mesh is under the pointer
  32475. */
  32476. getPointerOverMesh(): Nullable<AbstractMesh>;
  32477. }
  32478. }
  32479. declare module "babylonjs/Animations/animationGroup" {
  32480. import { Animatable } from "babylonjs/Animations/animatable";
  32481. import { Animation } from "babylonjs/Animations/animation";
  32482. import { Scene, IDisposable } from "babylonjs/scene";
  32483. import { Observable } from "babylonjs/Misc/observable";
  32484. import { Nullable } from "babylonjs/types";
  32485. /**
  32486. * This class defines the direct association between an animation and a target
  32487. */
  32488. export class TargetedAnimation {
  32489. /**
  32490. * Animation to perform
  32491. */
  32492. animation: Animation;
  32493. /**
  32494. * Target to animate
  32495. */
  32496. target: any;
  32497. }
  32498. /**
  32499. * Use this class to create coordinated animations on multiple targets
  32500. */
  32501. export class AnimationGroup implements IDisposable {
  32502. /** The name of the animation group */
  32503. name: string;
  32504. private _scene;
  32505. private _targetedAnimations;
  32506. private _animatables;
  32507. private _from;
  32508. private _to;
  32509. private _isStarted;
  32510. private _isPaused;
  32511. private _speedRatio;
  32512. /**
  32513. * Gets or sets the unique id of the node
  32514. */
  32515. uniqueId: number;
  32516. /**
  32517. * This observable will notify when one animation have ended
  32518. */
  32519. onAnimationEndObservable: Observable<TargetedAnimation>;
  32520. /**
  32521. * Observer raised when one animation loops
  32522. */
  32523. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32524. /**
  32525. * This observable will notify when all animations have ended.
  32526. */
  32527. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32528. /**
  32529. * This observable will notify when all animations have paused.
  32530. */
  32531. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32532. /**
  32533. * This observable will notify when all animations are playing.
  32534. */
  32535. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32536. /**
  32537. * Gets the first frame
  32538. */
  32539. readonly from: number;
  32540. /**
  32541. * Gets the last frame
  32542. */
  32543. readonly to: number;
  32544. /**
  32545. * Define if the animations are started
  32546. */
  32547. readonly isStarted: boolean;
  32548. /**
  32549. * Gets a value indicating that the current group is playing
  32550. */
  32551. readonly isPlaying: boolean;
  32552. /**
  32553. * Gets or sets the speed ratio to use for all animations
  32554. */
  32555. /**
  32556. * Gets or sets the speed ratio to use for all animations
  32557. */
  32558. speedRatio: number;
  32559. /**
  32560. * Gets the targeted animations for this animation group
  32561. */
  32562. readonly targetedAnimations: Array<TargetedAnimation>;
  32563. /**
  32564. * returning the list of animatables controlled by this animation group.
  32565. */
  32566. readonly animatables: Array<Animatable>;
  32567. /**
  32568. * Instantiates a new Animation Group.
  32569. * This helps managing several animations at once.
  32570. * @see http://doc.babylonjs.com/how_to/group
  32571. * @param name Defines the name of the group
  32572. * @param scene Defines the scene the group belongs to
  32573. */
  32574. constructor(
  32575. /** The name of the animation group */
  32576. name: string, scene?: Nullable<Scene>);
  32577. /**
  32578. * Add an animation (with its target) in the group
  32579. * @param animation defines the animation we want to add
  32580. * @param target defines the target of the animation
  32581. * @returns the TargetedAnimation object
  32582. */
  32583. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32584. /**
  32585. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32586. * It can add constant keys at begin or end
  32587. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32588. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32589. * @returns the animation group
  32590. */
  32591. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32592. /**
  32593. * Start all animations on given targets
  32594. * @param loop defines if animations must loop
  32595. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32596. * @param from defines the from key (optional)
  32597. * @param to defines the to key (optional)
  32598. * @returns the current animation group
  32599. */
  32600. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32601. /**
  32602. * Pause all animations
  32603. * @returns the animation group
  32604. */
  32605. pause(): AnimationGroup;
  32606. /**
  32607. * Play all animations to initial state
  32608. * This function will start() the animations if they were not started or will restart() them if they were paused
  32609. * @param loop defines if animations must loop
  32610. * @returns the animation group
  32611. */
  32612. play(loop?: boolean): AnimationGroup;
  32613. /**
  32614. * Reset all animations to initial state
  32615. * @returns the animation group
  32616. */
  32617. reset(): AnimationGroup;
  32618. /**
  32619. * Restart animations from key 0
  32620. * @returns the animation group
  32621. */
  32622. restart(): AnimationGroup;
  32623. /**
  32624. * Stop all animations
  32625. * @returns the animation group
  32626. */
  32627. stop(): AnimationGroup;
  32628. /**
  32629. * Set animation weight for all animatables
  32630. * @param weight defines the weight to use
  32631. * @return the animationGroup
  32632. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32633. */
  32634. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32635. /**
  32636. * Synchronize and normalize all animatables with a source animatable
  32637. * @param root defines the root animatable to synchronize with
  32638. * @return the animationGroup
  32639. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32640. */
  32641. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32642. /**
  32643. * Goes to a specific frame in this animation group
  32644. * @param frame the frame number to go to
  32645. * @return the animationGroup
  32646. */
  32647. goToFrame(frame: number): AnimationGroup;
  32648. /**
  32649. * Dispose all associated resources
  32650. */
  32651. dispose(): void;
  32652. private _checkAnimationGroupEnded;
  32653. /**
  32654. * Clone the current animation group and returns a copy
  32655. * @param newName defines the name of the new group
  32656. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32657. * @returns the new aniamtion group
  32658. */
  32659. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32660. /**
  32661. * Returns a new AnimationGroup object parsed from the source provided.
  32662. * @param parsedAnimationGroup defines the source
  32663. * @param scene defines the scene that will receive the animationGroup
  32664. * @returns a new AnimationGroup
  32665. */
  32666. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32667. /**
  32668. * Returns the string "AnimationGroup"
  32669. * @returns "AnimationGroup"
  32670. */
  32671. getClassName(): string;
  32672. /**
  32673. * Creates a detailled string about the object
  32674. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32675. * @returns a string representing the object
  32676. */
  32677. toString(fullDetails?: boolean): string;
  32678. }
  32679. }
  32680. declare module "babylonjs/scene" {
  32681. import { Nullable } from "babylonjs/types";
  32682. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32683. import { Observable } from "babylonjs/Misc/observable";
  32684. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32685. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32686. import { Geometry } from "babylonjs/Meshes/geometry";
  32687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32690. import { Mesh } from "babylonjs/Meshes/mesh";
  32691. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32692. import { Bone } from "babylonjs/Bones/bone";
  32693. import { Skeleton } from "babylonjs/Bones/skeleton";
  32694. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32695. import { Camera } from "babylonjs/Cameras/camera";
  32696. import { AbstractScene } from "babylonjs/abstractScene";
  32697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32699. import { Material } from "babylonjs/Materials/material";
  32700. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32701. import { Effect } from "babylonjs/Materials/effect";
  32702. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32703. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32704. import { Light } from "babylonjs/Lights/light";
  32705. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32706. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32707. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32708. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32710. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32711. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32712. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32713. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32714. import { Engine } from "babylonjs/Engines/engine";
  32715. import { Node } from "babylonjs/node";
  32716. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32717. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32718. import { WebRequest } from "babylonjs/Misc/webRequest";
  32719. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32720. import { Ray } from "babylonjs/Culling/ray";
  32721. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32722. import { Animation } from "babylonjs/Animations/animation";
  32723. import { Animatable } from "babylonjs/Animations/animatable";
  32724. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32725. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32726. import { Collider } from "babylonjs/Collisions/collider";
  32727. /**
  32728. * Define an interface for all classes that will hold resources
  32729. */
  32730. export interface IDisposable {
  32731. /**
  32732. * Releases all held resources
  32733. */
  32734. dispose(): void;
  32735. }
  32736. /** Interface defining initialization parameters for Scene class */
  32737. export interface SceneOptions {
  32738. /**
  32739. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32740. * It will improve performance when the number of geometries becomes important.
  32741. */
  32742. useGeometryUniqueIdsMap?: boolean;
  32743. /**
  32744. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32745. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32746. */
  32747. useMaterialMeshMap?: boolean;
  32748. /**
  32749. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32750. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32751. */
  32752. useClonedMeshhMap?: boolean;
  32753. }
  32754. /**
  32755. * Represents a scene to be rendered by the engine.
  32756. * @see http://doc.babylonjs.com/features/scene
  32757. */
  32758. export class Scene extends AbstractScene implements IAnimatable {
  32759. private static _uniqueIdCounter;
  32760. /** The fog is deactivated */
  32761. static readonly FOGMODE_NONE: number;
  32762. /** The fog density is following an exponential function */
  32763. static readonly FOGMODE_EXP: number;
  32764. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32765. static readonly FOGMODE_EXP2: number;
  32766. /** The fog density is following a linear function. */
  32767. static readonly FOGMODE_LINEAR: number;
  32768. /**
  32769. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32771. */
  32772. static MinDeltaTime: number;
  32773. /**
  32774. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32776. */
  32777. static MaxDeltaTime: number;
  32778. /**
  32779. * Factory used to create the default material.
  32780. * @param name The name of the material to create
  32781. * @param scene The scene to create the material for
  32782. * @returns The default material
  32783. */
  32784. static DefaultMaterialFactory(scene: Scene): Material;
  32785. /**
  32786. * Factory used to create the a collision coordinator.
  32787. * @returns The collision coordinator
  32788. */
  32789. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32790. /** @hidden */
  32791. _inputManager: InputManager;
  32792. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32793. cameraToUseForPointers: Nullable<Camera>;
  32794. /** @hidden */
  32795. readonly _isScene: boolean;
  32796. /**
  32797. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32798. */
  32799. autoClear: boolean;
  32800. /**
  32801. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32802. */
  32803. autoClearDepthAndStencil: boolean;
  32804. /**
  32805. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32806. */
  32807. clearColor: Color4;
  32808. /**
  32809. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32810. */
  32811. ambientColor: Color3;
  32812. /**
  32813. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32814. * It should only be one of the following (if not the default embedded one):
  32815. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32816. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32817. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32818. * The material properties need to be setup according to the type of texture in use.
  32819. */
  32820. environmentBRDFTexture: BaseTexture;
  32821. /** @hidden */
  32822. protected _environmentTexture: Nullable<BaseTexture>;
  32823. /**
  32824. * Texture used in all pbr material as the reflection texture.
  32825. * As in the majority of the scene they are the same (exception for multi room and so on),
  32826. * this is easier to reference from here than from all the materials.
  32827. */
  32828. /**
  32829. * Texture used in all pbr material as the reflection texture.
  32830. * As in the majority of the scene they are the same (exception for multi room and so on),
  32831. * this is easier to set here than in all the materials.
  32832. */
  32833. environmentTexture: Nullable<BaseTexture>;
  32834. /** @hidden */
  32835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32836. /**
  32837. * Default image processing configuration used either in the rendering
  32838. * Forward main pass or through the imageProcessingPostProcess if present.
  32839. * As in the majority of the scene they are the same (exception for multi camera),
  32840. * this is easier to reference from here than from all the materials and post process.
  32841. *
  32842. * No setter as we it is a shared configuration, you can set the values instead.
  32843. */
  32844. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32845. private _forceWireframe;
  32846. /**
  32847. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32848. */
  32849. forceWireframe: boolean;
  32850. private _forcePointsCloud;
  32851. /**
  32852. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32853. */
  32854. forcePointsCloud: boolean;
  32855. /**
  32856. * Gets or sets the active clipplane 1
  32857. */
  32858. clipPlane: Nullable<Plane>;
  32859. /**
  32860. * Gets or sets the active clipplane 2
  32861. */
  32862. clipPlane2: Nullable<Plane>;
  32863. /**
  32864. * Gets or sets the active clipplane 3
  32865. */
  32866. clipPlane3: Nullable<Plane>;
  32867. /**
  32868. * Gets or sets the active clipplane 4
  32869. */
  32870. clipPlane4: Nullable<Plane>;
  32871. /**
  32872. * Gets or sets a boolean indicating if animations are enabled
  32873. */
  32874. animationsEnabled: boolean;
  32875. private _animationPropertiesOverride;
  32876. /**
  32877. * Gets or sets the animation properties override
  32878. */
  32879. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32880. /**
  32881. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32882. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32883. */
  32884. useConstantAnimationDeltaTime: boolean;
  32885. /**
  32886. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32887. * Please note that it requires to run a ray cast through the scene on every frame
  32888. */
  32889. constantlyUpdateMeshUnderPointer: boolean;
  32890. /**
  32891. * Defines the HTML cursor to use when hovering over interactive elements
  32892. */
  32893. hoverCursor: string;
  32894. /**
  32895. * Defines the HTML default cursor to use (empty by default)
  32896. */
  32897. defaultCursor: string;
  32898. /**
  32899. * This is used to call preventDefault() on pointer down
  32900. * in order to block unwanted artifacts like system double clicks
  32901. */
  32902. preventDefaultOnPointerDown: boolean;
  32903. /**
  32904. * This is used to call preventDefault() on pointer up
  32905. * in order to block unwanted artifacts like system double clicks
  32906. */
  32907. preventDefaultOnPointerUp: boolean;
  32908. /**
  32909. * Gets or sets user defined metadata
  32910. */
  32911. metadata: any;
  32912. /**
  32913. * For internal use only. Please do not use.
  32914. */
  32915. reservedDataStore: any;
  32916. /**
  32917. * Gets the name of the plugin used to load this scene (null by default)
  32918. */
  32919. loadingPluginName: string;
  32920. /**
  32921. * Use this array to add regular expressions used to disable offline support for specific urls
  32922. */
  32923. disableOfflineSupportExceptionRules: RegExp[];
  32924. /**
  32925. * An event triggered when the scene is disposed.
  32926. */
  32927. onDisposeObservable: Observable<Scene>;
  32928. private _onDisposeObserver;
  32929. /** Sets a function to be executed when this scene is disposed. */
  32930. onDispose: () => void;
  32931. /**
  32932. * An event triggered before rendering the scene (right after animations and physics)
  32933. */
  32934. onBeforeRenderObservable: Observable<Scene>;
  32935. private _onBeforeRenderObserver;
  32936. /** Sets a function to be executed before rendering this scene */
  32937. beforeRender: Nullable<() => void>;
  32938. /**
  32939. * An event triggered after rendering the scene
  32940. */
  32941. onAfterRenderObservable: Observable<Scene>;
  32942. private _onAfterRenderObserver;
  32943. /** Sets a function to be executed after rendering this scene */
  32944. afterRender: Nullable<() => void>;
  32945. /**
  32946. * An event triggered before animating the scene
  32947. */
  32948. onBeforeAnimationsObservable: Observable<Scene>;
  32949. /**
  32950. * An event triggered after animations processing
  32951. */
  32952. onAfterAnimationsObservable: Observable<Scene>;
  32953. /**
  32954. * An event triggered before draw calls are ready to be sent
  32955. */
  32956. onBeforeDrawPhaseObservable: Observable<Scene>;
  32957. /**
  32958. * An event triggered after draw calls have been sent
  32959. */
  32960. onAfterDrawPhaseObservable: Observable<Scene>;
  32961. /**
  32962. * An event triggered when the scene is ready
  32963. */
  32964. onReadyObservable: Observable<Scene>;
  32965. /**
  32966. * An event triggered before rendering a camera
  32967. */
  32968. onBeforeCameraRenderObservable: Observable<Camera>;
  32969. private _onBeforeCameraRenderObserver;
  32970. /** Sets a function to be executed before rendering a camera*/
  32971. beforeCameraRender: () => void;
  32972. /**
  32973. * An event triggered after rendering a camera
  32974. */
  32975. onAfterCameraRenderObservable: Observable<Camera>;
  32976. private _onAfterCameraRenderObserver;
  32977. /** Sets a function to be executed after rendering a camera*/
  32978. afterCameraRender: () => void;
  32979. /**
  32980. * An event triggered when active meshes evaluation is about to start
  32981. */
  32982. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32983. /**
  32984. * An event triggered when active meshes evaluation is done
  32985. */
  32986. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32987. /**
  32988. * An event triggered when particles rendering is about to start
  32989. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32990. */
  32991. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32992. /**
  32993. * An event triggered when particles rendering is done
  32994. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32995. */
  32996. onAfterParticlesRenderingObservable: Observable<Scene>;
  32997. /**
  32998. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32999. */
  33000. onDataLoadedObservable: Observable<Scene>;
  33001. /**
  33002. * An event triggered when a camera is created
  33003. */
  33004. onNewCameraAddedObservable: Observable<Camera>;
  33005. /**
  33006. * An event triggered when a camera is removed
  33007. */
  33008. onCameraRemovedObservable: Observable<Camera>;
  33009. /**
  33010. * An event triggered when a light is created
  33011. */
  33012. onNewLightAddedObservable: Observable<Light>;
  33013. /**
  33014. * An event triggered when a light is removed
  33015. */
  33016. onLightRemovedObservable: Observable<Light>;
  33017. /**
  33018. * An event triggered when a geometry is created
  33019. */
  33020. onNewGeometryAddedObservable: Observable<Geometry>;
  33021. /**
  33022. * An event triggered when a geometry is removed
  33023. */
  33024. onGeometryRemovedObservable: Observable<Geometry>;
  33025. /**
  33026. * An event triggered when a transform node is created
  33027. */
  33028. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33029. /**
  33030. * An event triggered when a transform node is removed
  33031. */
  33032. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33033. /**
  33034. * An event triggered when a mesh is created
  33035. */
  33036. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33037. /**
  33038. * An event triggered when a mesh is removed
  33039. */
  33040. onMeshRemovedObservable: Observable<AbstractMesh>;
  33041. /**
  33042. * An event triggered when a skeleton is created
  33043. */
  33044. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33045. /**
  33046. * An event triggered when a skeleton is removed
  33047. */
  33048. onSkeletonRemovedObservable: Observable<Skeleton>;
  33049. /**
  33050. * An event triggered when a material is created
  33051. */
  33052. onNewMaterialAddedObservable: Observable<Material>;
  33053. /**
  33054. * An event triggered when a material is removed
  33055. */
  33056. onMaterialRemovedObservable: Observable<Material>;
  33057. /**
  33058. * An event triggered when a texture is created
  33059. */
  33060. onNewTextureAddedObservable: Observable<BaseTexture>;
  33061. /**
  33062. * An event triggered when a texture is removed
  33063. */
  33064. onTextureRemovedObservable: Observable<BaseTexture>;
  33065. /**
  33066. * An event triggered when render targets are about to be rendered
  33067. * Can happen multiple times per frame.
  33068. */
  33069. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33070. /**
  33071. * An event triggered when render targets were rendered.
  33072. * Can happen multiple times per frame.
  33073. */
  33074. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33075. /**
  33076. * An event triggered before calculating deterministic simulation step
  33077. */
  33078. onBeforeStepObservable: Observable<Scene>;
  33079. /**
  33080. * An event triggered after calculating deterministic simulation step
  33081. */
  33082. onAfterStepObservable: Observable<Scene>;
  33083. /**
  33084. * An event triggered when the activeCamera property is updated
  33085. */
  33086. onActiveCameraChanged: Observable<Scene>;
  33087. /**
  33088. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33089. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33090. * 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)
  33091. */
  33092. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33093. /**
  33094. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33095. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33096. * 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)
  33097. */
  33098. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33099. /**
  33100. * This Observable will when a mesh has been imported into the scene.
  33101. */
  33102. onMeshImportedObservable: Observable<AbstractMesh>;
  33103. /**
  33104. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33105. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33106. */
  33107. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33108. /** @hidden */
  33109. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33110. /**
  33111. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33112. */
  33113. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33114. /**
  33115. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33116. */
  33117. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33118. /**
  33119. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33120. */
  33121. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33122. /** Callback called when a pointer move is detected */
  33123. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33124. /** Callback called when a pointer down is detected */
  33125. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33126. /** Callback called when a pointer up is detected */
  33127. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33128. /** Callback called when a pointer pick is detected */
  33129. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33130. /**
  33131. * 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).
  33132. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33133. */
  33134. onPrePointerObservable: Observable<PointerInfoPre>;
  33135. /**
  33136. * Observable event triggered each time an input event is received from the rendering canvas
  33137. */
  33138. onPointerObservable: Observable<PointerInfo>;
  33139. /**
  33140. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33141. */
  33142. readonly unTranslatedPointer: Vector2;
  33143. /**
  33144. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33145. */
  33146. static DragMovementThreshold: number;
  33147. /**
  33148. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33149. */
  33150. static LongPressDelay: number;
  33151. /**
  33152. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33153. */
  33154. static DoubleClickDelay: number;
  33155. /** If you need to check double click without raising a single click at first click, enable this flag */
  33156. static ExclusiveDoubleClickMode: boolean;
  33157. /** @hidden */
  33158. _mirroredCameraPosition: Nullable<Vector3>;
  33159. /**
  33160. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33161. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33162. */
  33163. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33164. /**
  33165. * Observable event triggered each time an keyboard event is received from the hosting window
  33166. */
  33167. onKeyboardObservable: Observable<KeyboardInfo>;
  33168. private _useRightHandedSystem;
  33169. /**
  33170. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33171. */
  33172. useRightHandedSystem: boolean;
  33173. private _timeAccumulator;
  33174. private _currentStepId;
  33175. private _currentInternalStep;
  33176. /**
  33177. * Sets the step Id used by deterministic lock step
  33178. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33179. * @param newStepId defines the step Id
  33180. */
  33181. setStepId(newStepId: number): void;
  33182. /**
  33183. * Gets the step Id used by deterministic lock step
  33184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33185. * @returns the step Id
  33186. */
  33187. getStepId(): number;
  33188. /**
  33189. * Gets the internal step used by deterministic lock step
  33190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33191. * @returns the internal step
  33192. */
  33193. getInternalStep(): number;
  33194. private _fogEnabled;
  33195. /**
  33196. * Gets or sets a boolean indicating if fog is enabled on this scene
  33197. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33198. * (Default is true)
  33199. */
  33200. fogEnabled: boolean;
  33201. private _fogMode;
  33202. /**
  33203. * Gets or sets the fog mode to use
  33204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33205. * | mode | value |
  33206. * | --- | --- |
  33207. * | FOGMODE_NONE | 0 |
  33208. * | FOGMODE_EXP | 1 |
  33209. * | FOGMODE_EXP2 | 2 |
  33210. * | FOGMODE_LINEAR | 3 |
  33211. */
  33212. fogMode: number;
  33213. /**
  33214. * Gets or sets the fog color to use
  33215. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33216. * (Default is Color3(0.2, 0.2, 0.3))
  33217. */
  33218. fogColor: Color3;
  33219. /**
  33220. * Gets or sets the fog density to use
  33221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33222. * (Default is 0.1)
  33223. */
  33224. fogDensity: number;
  33225. /**
  33226. * Gets or sets the fog start distance to use
  33227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33228. * (Default is 0)
  33229. */
  33230. fogStart: number;
  33231. /**
  33232. * Gets or sets the fog end distance to use
  33233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33234. * (Default is 1000)
  33235. */
  33236. fogEnd: number;
  33237. private _shadowsEnabled;
  33238. /**
  33239. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33240. */
  33241. shadowsEnabled: boolean;
  33242. private _lightsEnabled;
  33243. /**
  33244. * Gets or sets a boolean indicating if lights are enabled on this scene
  33245. */
  33246. lightsEnabled: boolean;
  33247. /** All of the active cameras added to this scene. */
  33248. activeCameras: Camera[];
  33249. /** @hidden */
  33250. _activeCamera: Nullable<Camera>;
  33251. /** Gets or sets the current active camera */
  33252. activeCamera: Nullable<Camera>;
  33253. private _defaultMaterial;
  33254. /** The default material used on meshes when no material is affected */
  33255. /** The default material used on meshes when no material is affected */
  33256. defaultMaterial: Material;
  33257. private _texturesEnabled;
  33258. /**
  33259. * Gets or sets a boolean indicating if textures are enabled on this scene
  33260. */
  33261. texturesEnabled: boolean;
  33262. /**
  33263. * Gets or sets a boolean indicating if particles are enabled on this scene
  33264. */
  33265. particlesEnabled: boolean;
  33266. /**
  33267. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33268. */
  33269. spritesEnabled: boolean;
  33270. private _skeletonsEnabled;
  33271. /**
  33272. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33273. */
  33274. skeletonsEnabled: boolean;
  33275. /**
  33276. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33277. */
  33278. lensFlaresEnabled: boolean;
  33279. /**
  33280. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33282. */
  33283. collisionsEnabled: boolean;
  33284. private _collisionCoordinator;
  33285. /** @hidden */
  33286. readonly collisionCoordinator: ICollisionCoordinator;
  33287. /**
  33288. * Defines the gravity applied to this scene (used only for collisions)
  33289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33290. */
  33291. gravity: Vector3;
  33292. /**
  33293. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33294. */
  33295. postProcessesEnabled: boolean;
  33296. /**
  33297. * The list of postprocesses added to the scene
  33298. */
  33299. postProcesses: PostProcess[];
  33300. /**
  33301. * Gets the current postprocess manager
  33302. */
  33303. postProcessManager: PostProcessManager;
  33304. /**
  33305. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33306. */
  33307. renderTargetsEnabled: boolean;
  33308. /**
  33309. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33310. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33311. */
  33312. dumpNextRenderTargets: boolean;
  33313. /**
  33314. * The list of user defined render targets added to the scene
  33315. */
  33316. customRenderTargets: RenderTargetTexture[];
  33317. /**
  33318. * Defines if texture loading must be delayed
  33319. * If true, textures will only be loaded when they need to be rendered
  33320. */
  33321. useDelayedTextureLoading: boolean;
  33322. /**
  33323. * Gets the list of meshes imported to the scene through SceneLoader
  33324. */
  33325. importedMeshesFiles: String[];
  33326. /**
  33327. * Gets or sets a boolean indicating if probes are enabled on this scene
  33328. */
  33329. probesEnabled: boolean;
  33330. /**
  33331. * Gets or sets the current offline provider to use to store scene data
  33332. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33333. */
  33334. offlineProvider: IOfflineProvider;
  33335. /**
  33336. * Gets or sets the action manager associated with the scene
  33337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33338. */
  33339. actionManager: AbstractActionManager;
  33340. private _meshesForIntersections;
  33341. /**
  33342. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33343. */
  33344. proceduralTexturesEnabled: boolean;
  33345. private _engine;
  33346. private _totalVertices;
  33347. /** @hidden */
  33348. _activeIndices: PerfCounter;
  33349. /** @hidden */
  33350. _activeParticles: PerfCounter;
  33351. /** @hidden */
  33352. _activeBones: PerfCounter;
  33353. private _animationRatio;
  33354. /** @hidden */
  33355. _animationTimeLast: number;
  33356. /** @hidden */
  33357. _animationTime: number;
  33358. /**
  33359. * Gets or sets a general scale for animation speed
  33360. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33361. */
  33362. animationTimeScale: number;
  33363. /** @hidden */
  33364. _cachedMaterial: Nullable<Material>;
  33365. /** @hidden */
  33366. _cachedEffect: Nullable<Effect>;
  33367. /** @hidden */
  33368. _cachedVisibility: Nullable<number>;
  33369. private _renderId;
  33370. private _frameId;
  33371. private _executeWhenReadyTimeoutId;
  33372. private _intermediateRendering;
  33373. private _viewUpdateFlag;
  33374. private _projectionUpdateFlag;
  33375. /** @hidden */
  33376. _toBeDisposed: Nullable<IDisposable>[];
  33377. private _activeRequests;
  33378. /** @hidden */
  33379. _pendingData: any[];
  33380. private _isDisposed;
  33381. /**
  33382. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33383. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33384. */
  33385. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33386. private _activeMeshes;
  33387. private _processedMaterials;
  33388. private _renderTargets;
  33389. /** @hidden */
  33390. _activeParticleSystems: SmartArray<IParticleSystem>;
  33391. private _activeSkeletons;
  33392. private _softwareSkinnedMeshes;
  33393. private _renderingManager;
  33394. /** @hidden */
  33395. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33396. private _transformMatrix;
  33397. private _sceneUbo;
  33398. /** @hidden */
  33399. _viewMatrix: Matrix;
  33400. private _projectionMatrix;
  33401. /** @hidden */
  33402. _forcedViewPosition: Nullable<Vector3>;
  33403. /** @hidden */
  33404. _frustumPlanes: Plane[];
  33405. /**
  33406. * Gets the list of frustum planes (built from the active camera)
  33407. */
  33408. readonly frustumPlanes: Plane[];
  33409. /**
  33410. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33411. * This is useful if there are more lights that the maximum simulteanous authorized
  33412. */
  33413. requireLightSorting: boolean;
  33414. /** @hidden */
  33415. readonly useMaterialMeshMap: boolean;
  33416. /** @hidden */
  33417. readonly useClonedMeshhMap: boolean;
  33418. private _externalData;
  33419. private _uid;
  33420. /**
  33421. * @hidden
  33422. * Backing store of defined scene components.
  33423. */
  33424. _components: ISceneComponent[];
  33425. /**
  33426. * @hidden
  33427. * Backing store of defined scene components.
  33428. */
  33429. _serializableComponents: ISceneSerializableComponent[];
  33430. /**
  33431. * List of components to register on the next registration step.
  33432. */
  33433. private _transientComponents;
  33434. /**
  33435. * Registers the transient components if needed.
  33436. */
  33437. private _registerTransientComponents;
  33438. /**
  33439. * @hidden
  33440. * Add a component to the scene.
  33441. * Note that the ccomponent could be registered on th next frame if this is called after
  33442. * the register component stage.
  33443. * @param component Defines the component to add to the scene
  33444. */
  33445. _addComponent(component: ISceneComponent): void;
  33446. /**
  33447. * @hidden
  33448. * Gets a component from the scene.
  33449. * @param name defines the name of the component to retrieve
  33450. * @returns the component or null if not present
  33451. */
  33452. _getComponent(name: string): Nullable<ISceneComponent>;
  33453. /**
  33454. * @hidden
  33455. * Defines the actions happening before camera updates.
  33456. */
  33457. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33458. /**
  33459. * @hidden
  33460. * Defines the actions happening before clear the canvas.
  33461. */
  33462. _beforeClearStage: Stage<SimpleStageAction>;
  33463. /**
  33464. * @hidden
  33465. * Defines the actions when collecting render targets for the frame.
  33466. */
  33467. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33468. /**
  33469. * @hidden
  33470. * Defines the actions happening for one camera in the frame.
  33471. */
  33472. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33473. /**
  33474. * @hidden
  33475. * Defines the actions happening during the per mesh ready checks.
  33476. */
  33477. _isReadyForMeshStage: Stage<MeshStageAction>;
  33478. /**
  33479. * @hidden
  33480. * Defines the actions happening before evaluate active mesh checks.
  33481. */
  33482. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33483. /**
  33484. * @hidden
  33485. * Defines the actions happening during the evaluate sub mesh checks.
  33486. */
  33487. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33488. /**
  33489. * @hidden
  33490. * Defines the actions happening during the active mesh stage.
  33491. */
  33492. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33493. /**
  33494. * @hidden
  33495. * Defines the actions happening during the per camera render target step.
  33496. */
  33497. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33498. /**
  33499. * @hidden
  33500. * Defines the actions happening just before the active camera is drawing.
  33501. */
  33502. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33503. /**
  33504. * @hidden
  33505. * Defines the actions happening just before a render target is drawing.
  33506. */
  33507. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33508. /**
  33509. * @hidden
  33510. * Defines the actions happening just before a rendering group is drawing.
  33511. */
  33512. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33513. /**
  33514. * @hidden
  33515. * Defines the actions happening just before a mesh is drawing.
  33516. */
  33517. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33518. /**
  33519. * @hidden
  33520. * Defines the actions happening just after a mesh has been drawn.
  33521. */
  33522. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening just after a rendering group has been drawn.
  33526. */
  33527. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening just after the active camera has been drawn.
  33531. */
  33532. _afterCameraDrawStage: Stage<CameraStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions happening just after a render target has been drawn.
  33536. */
  33537. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening just after rendering all cameras and computing intersections.
  33541. */
  33542. _afterRenderStage: Stage<SimpleStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening when a pointer move event happens.
  33546. */
  33547. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening when a pointer down event happens.
  33551. */
  33552. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening when a pointer up event happens.
  33556. */
  33557. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33558. /**
  33559. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33560. */
  33561. private geometriesByUniqueId;
  33562. /**
  33563. * Creates a new Scene
  33564. * @param engine defines the engine to use to render this scene
  33565. * @param options defines the scene options
  33566. */
  33567. constructor(engine: Engine, options?: SceneOptions);
  33568. /**
  33569. * Gets a string idenfifying the name of the class
  33570. * @returns "Scene" string
  33571. */
  33572. getClassName(): string;
  33573. private _defaultMeshCandidates;
  33574. /**
  33575. * @hidden
  33576. */
  33577. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33578. private _defaultSubMeshCandidates;
  33579. /**
  33580. * @hidden
  33581. */
  33582. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33583. /**
  33584. * Sets the default candidate providers for the scene.
  33585. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33586. * and getCollidingSubMeshCandidates to their default function
  33587. */
  33588. setDefaultCandidateProviders(): void;
  33589. /**
  33590. * Gets the mesh that is currently under the pointer
  33591. */
  33592. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33593. /**
  33594. * Gets or sets the current on-screen X position of the pointer
  33595. */
  33596. pointerX: number;
  33597. /**
  33598. * Gets or sets the current on-screen Y position of the pointer
  33599. */
  33600. pointerY: number;
  33601. /**
  33602. * Gets the cached material (ie. the latest rendered one)
  33603. * @returns the cached material
  33604. */
  33605. getCachedMaterial(): Nullable<Material>;
  33606. /**
  33607. * Gets the cached effect (ie. the latest rendered one)
  33608. * @returns the cached effect
  33609. */
  33610. getCachedEffect(): Nullable<Effect>;
  33611. /**
  33612. * Gets the cached visibility state (ie. the latest rendered one)
  33613. * @returns the cached visibility state
  33614. */
  33615. getCachedVisibility(): Nullable<number>;
  33616. /**
  33617. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33618. * @param material defines the current material
  33619. * @param effect defines the current effect
  33620. * @param visibility defines the current visibility state
  33621. * @returns true if one parameter is not cached
  33622. */
  33623. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33624. /**
  33625. * Gets the engine associated with the scene
  33626. * @returns an Engine
  33627. */
  33628. getEngine(): Engine;
  33629. /**
  33630. * Gets the total number of vertices rendered per frame
  33631. * @returns the total number of vertices rendered per frame
  33632. */
  33633. getTotalVertices(): number;
  33634. /**
  33635. * Gets the performance counter for total vertices
  33636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33637. */
  33638. readonly totalVerticesPerfCounter: PerfCounter;
  33639. /**
  33640. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33641. * @returns the total number of active indices rendered per frame
  33642. */
  33643. getActiveIndices(): number;
  33644. /**
  33645. * Gets the performance counter for active indices
  33646. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33647. */
  33648. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33649. /**
  33650. * Gets the total number of active particles rendered per frame
  33651. * @returns the total number of active particles rendered per frame
  33652. */
  33653. getActiveParticles(): number;
  33654. /**
  33655. * Gets the performance counter for active particles
  33656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33657. */
  33658. readonly activeParticlesPerfCounter: PerfCounter;
  33659. /**
  33660. * Gets the total number of active bones rendered per frame
  33661. * @returns the total number of active bones rendered per frame
  33662. */
  33663. getActiveBones(): number;
  33664. /**
  33665. * Gets the performance counter for active bones
  33666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33667. */
  33668. readonly activeBonesPerfCounter: PerfCounter;
  33669. /**
  33670. * Gets the array of active meshes
  33671. * @returns an array of AbstractMesh
  33672. */
  33673. getActiveMeshes(): SmartArray<AbstractMesh>;
  33674. /**
  33675. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33676. * @returns a number
  33677. */
  33678. getAnimationRatio(): number;
  33679. /**
  33680. * Gets an unique Id for the current render phase
  33681. * @returns a number
  33682. */
  33683. getRenderId(): number;
  33684. /**
  33685. * Gets an unique Id for the current frame
  33686. * @returns a number
  33687. */
  33688. getFrameId(): number;
  33689. /** Call this function if you want to manually increment the render Id*/
  33690. incrementRenderId(): void;
  33691. private _createUbo;
  33692. /**
  33693. * Use this method to simulate a pointer move on a mesh
  33694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33697. * @returns the current scene
  33698. */
  33699. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33700. /**
  33701. * Use this method to simulate a pointer down on a mesh
  33702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33705. * @returns the current scene
  33706. */
  33707. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33708. /**
  33709. * Use this method to simulate a pointer up on a mesh
  33710. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33711. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33712. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33713. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33714. * @returns the current scene
  33715. */
  33716. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33717. /**
  33718. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33719. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33720. * @returns true if the pointer was captured
  33721. */
  33722. isPointerCaptured(pointerId?: number): boolean;
  33723. /**
  33724. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33725. * @param attachUp defines if you want to attach events to pointerup
  33726. * @param attachDown defines if you want to attach events to pointerdown
  33727. * @param attachMove defines if you want to attach events to pointermove
  33728. */
  33729. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33730. /** Detaches all event handlers*/
  33731. detachControl(): void;
  33732. /**
  33733. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33734. * Delay loaded resources are not taking in account
  33735. * @return true if all required resources are ready
  33736. */
  33737. isReady(): boolean;
  33738. /** Resets all cached information relative to material (including effect and visibility) */
  33739. resetCachedMaterial(): void;
  33740. /**
  33741. * Registers a function to be called before every frame render
  33742. * @param func defines the function to register
  33743. */
  33744. registerBeforeRender(func: () => void): void;
  33745. /**
  33746. * Unregisters a function called before every frame render
  33747. * @param func defines the function to unregister
  33748. */
  33749. unregisterBeforeRender(func: () => void): void;
  33750. /**
  33751. * Registers a function to be called after every frame render
  33752. * @param func defines the function to register
  33753. */
  33754. registerAfterRender(func: () => void): void;
  33755. /**
  33756. * Unregisters a function called after every frame render
  33757. * @param func defines the function to unregister
  33758. */
  33759. unregisterAfterRender(func: () => void): void;
  33760. private _executeOnceBeforeRender;
  33761. /**
  33762. * The provided function will run before render once and will be disposed afterwards.
  33763. * A timeout delay can be provided so that the function will be executed in N ms.
  33764. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33765. * @param func The function to be executed.
  33766. * @param timeout optional delay in ms
  33767. */
  33768. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33769. /** @hidden */
  33770. _addPendingData(data: any): void;
  33771. /** @hidden */
  33772. _removePendingData(data: any): void;
  33773. /**
  33774. * Returns the number of items waiting to be loaded
  33775. * @returns the number of items waiting to be loaded
  33776. */
  33777. getWaitingItemsCount(): number;
  33778. /**
  33779. * Returns a boolean indicating if the scene is still loading data
  33780. */
  33781. readonly isLoading: boolean;
  33782. /**
  33783. * Registers a function to be executed when the scene is ready
  33784. * @param {Function} func - the function to be executed
  33785. */
  33786. executeWhenReady(func: () => void): void;
  33787. /**
  33788. * Returns a promise that resolves when the scene is ready
  33789. * @returns A promise that resolves when the scene is ready
  33790. */
  33791. whenReadyAsync(): Promise<void>;
  33792. /** @hidden */
  33793. _checkIsReady(): void;
  33794. /**
  33795. * Gets all animatable attached to the scene
  33796. */
  33797. readonly animatables: Animatable[];
  33798. /**
  33799. * Resets the last animation time frame.
  33800. * Useful to override when animations start running when loading a scene for the first time.
  33801. */
  33802. resetLastAnimationTimeFrame(): void;
  33803. /**
  33804. * Gets the current view matrix
  33805. * @returns a Matrix
  33806. */
  33807. getViewMatrix(): Matrix;
  33808. /**
  33809. * Gets the current projection matrix
  33810. * @returns a Matrix
  33811. */
  33812. getProjectionMatrix(): Matrix;
  33813. /**
  33814. * Gets the current transform matrix
  33815. * @returns a Matrix made of View * Projection
  33816. */
  33817. getTransformMatrix(): Matrix;
  33818. /**
  33819. * Sets the current transform matrix
  33820. * @param viewL defines the View matrix to use
  33821. * @param projectionL defines the Projection matrix to use
  33822. * @param viewR defines the right View matrix to use (if provided)
  33823. * @param projectionR defines the right Projection matrix to use (if provided)
  33824. */
  33825. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33826. /**
  33827. * Gets the uniform buffer used to store scene data
  33828. * @returns a UniformBuffer
  33829. */
  33830. getSceneUniformBuffer(): UniformBuffer;
  33831. /**
  33832. * Gets an unique (relatively to the current scene) Id
  33833. * @returns an unique number for the scene
  33834. */
  33835. getUniqueId(): number;
  33836. /**
  33837. * Add a mesh to the list of scene's meshes
  33838. * @param newMesh defines the mesh to add
  33839. * @param recursive if all child meshes should also be added to the scene
  33840. */
  33841. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33842. /**
  33843. * Remove a mesh for the list of scene's meshes
  33844. * @param toRemove defines the mesh to remove
  33845. * @param recursive if all child meshes should also be removed from the scene
  33846. * @returns the index where the mesh was in the mesh list
  33847. */
  33848. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33849. /**
  33850. * Add a transform node to the list of scene's transform nodes
  33851. * @param newTransformNode defines the transform node to add
  33852. */
  33853. addTransformNode(newTransformNode: TransformNode): void;
  33854. /**
  33855. * Remove a transform node for the list of scene's transform nodes
  33856. * @param toRemove defines the transform node to remove
  33857. * @returns the index where the transform node was in the transform node list
  33858. */
  33859. removeTransformNode(toRemove: TransformNode): number;
  33860. /**
  33861. * Remove a skeleton for the list of scene's skeletons
  33862. * @param toRemove defines the skeleton to remove
  33863. * @returns the index where the skeleton was in the skeleton list
  33864. */
  33865. removeSkeleton(toRemove: Skeleton): number;
  33866. /**
  33867. * Remove a morph target for the list of scene's morph targets
  33868. * @param toRemove defines the morph target to remove
  33869. * @returns the index where the morph target was in the morph target list
  33870. */
  33871. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33872. /**
  33873. * Remove a light for the list of scene's lights
  33874. * @param toRemove defines the light to remove
  33875. * @returns the index where the light was in the light list
  33876. */
  33877. removeLight(toRemove: Light): number;
  33878. /**
  33879. * Remove a camera for the list of scene's cameras
  33880. * @param toRemove defines the camera to remove
  33881. * @returns the index where the camera was in the camera list
  33882. */
  33883. removeCamera(toRemove: Camera): number;
  33884. /**
  33885. * Remove a particle system for the list of scene's particle systems
  33886. * @param toRemove defines the particle system to remove
  33887. * @returns the index where the particle system was in the particle system list
  33888. */
  33889. removeParticleSystem(toRemove: IParticleSystem): number;
  33890. /**
  33891. * Remove a animation for the list of scene's animations
  33892. * @param toRemove defines the animation to remove
  33893. * @returns the index where the animation was in the animation list
  33894. */
  33895. removeAnimation(toRemove: Animation): number;
  33896. /**
  33897. * Removes the given animation group from this scene.
  33898. * @param toRemove The animation group to remove
  33899. * @returns The index of the removed animation group
  33900. */
  33901. removeAnimationGroup(toRemove: AnimationGroup): number;
  33902. /**
  33903. * Removes the given multi-material from this scene.
  33904. * @param toRemove The multi-material to remove
  33905. * @returns The index of the removed multi-material
  33906. */
  33907. removeMultiMaterial(toRemove: MultiMaterial): number;
  33908. /**
  33909. * Removes the given material from this scene.
  33910. * @param toRemove The material to remove
  33911. * @returns The index of the removed material
  33912. */
  33913. removeMaterial(toRemove: Material): number;
  33914. /**
  33915. * Removes the given action manager from this scene.
  33916. * @param toRemove The action manager to remove
  33917. * @returns The index of the removed action manager
  33918. */
  33919. removeActionManager(toRemove: AbstractActionManager): number;
  33920. /**
  33921. * Removes the given texture from this scene.
  33922. * @param toRemove The texture to remove
  33923. * @returns The index of the removed texture
  33924. */
  33925. removeTexture(toRemove: BaseTexture): number;
  33926. /**
  33927. * Adds the given light to this scene
  33928. * @param newLight The light to add
  33929. */
  33930. addLight(newLight: Light): void;
  33931. /**
  33932. * Sorts the list list based on light priorities
  33933. */
  33934. sortLightsByPriority(): void;
  33935. /**
  33936. * Adds the given camera to this scene
  33937. * @param newCamera The camera to add
  33938. */
  33939. addCamera(newCamera: Camera): void;
  33940. /**
  33941. * Adds the given skeleton to this scene
  33942. * @param newSkeleton The skeleton to add
  33943. */
  33944. addSkeleton(newSkeleton: Skeleton): void;
  33945. /**
  33946. * Adds the given particle system to this scene
  33947. * @param newParticleSystem The particle system to add
  33948. */
  33949. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33950. /**
  33951. * Adds the given animation to this scene
  33952. * @param newAnimation The animation to add
  33953. */
  33954. addAnimation(newAnimation: Animation): void;
  33955. /**
  33956. * Adds the given animation group to this scene.
  33957. * @param newAnimationGroup The animation group to add
  33958. */
  33959. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33960. /**
  33961. * Adds the given multi-material to this scene
  33962. * @param newMultiMaterial The multi-material to add
  33963. */
  33964. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33965. /**
  33966. * Adds the given material to this scene
  33967. * @param newMaterial The material to add
  33968. */
  33969. addMaterial(newMaterial: Material): void;
  33970. /**
  33971. * Adds the given morph target to this scene
  33972. * @param newMorphTargetManager The morph target to add
  33973. */
  33974. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33975. /**
  33976. * Adds the given geometry to this scene
  33977. * @param newGeometry The geometry to add
  33978. */
  33979. addGeometry(newGeometry: Geometry): void;
  33980. /**
  33981. * Adds the given action manager to this scene
  33982. * @param newActionManager The action manager to add
  33983. */
  33984. addActionManager(newActionManager: AbstractActionManager): void;
  33985. /**
  33986. * Adds the given texture to this scene.
  33987. * @param newTexture The texture to add
  33988. */
  33989. addTexture(newTexture: BaseTexture): void;
  33990. /**
  33991. * Switch active camera
  33992. * @param newCamera defines the new active camera
  33993. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33994. */
  33995. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33996. /**
  33997. * sets the active camera of the scene using its ID
  33998. * @param id defines the camera's ID
  33999. * @return the new active camera or null if none found.
  34000. */
  34001. setActiveCameraByID(id: string): Nullable<Camera>;
  34002. /**
  34003. * sets the active camera of the scene using its name
  34004. * @param name defines the camera's name
  34005. * @returns the new active camera or null if none found.
  34006. */
  34007. setActiveCameraByName(name: string): Nullable<Camera>;
  34008. /**
  34009. * get an animation group using its name
  34010. * @param name defines the material's name
  34011. * @return the animation group or null if none found.
  34012. */
  34013. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34014. /**
  34015. * Get a material using its unique id
  34016. * @param uniqueId defines the material's unique id
  34017. * @return the material or null if none found.
  34018. */
  34019. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34020. /**
  34021. * get a material using its id
  34022. * @param id defines the material's ID
  34023. * @return the material or null if none found.
  34024. */
  34025. getMaterialByID(id: string): Nullable<Material>;
  34026. /**
  34027. * Gets a material using its name
  34028. * @param name defines the material's name
  34029. * @return the material or null if none found.
  34030. */
  34031. getMaterialByName(name: string): Nullable<Material>;
  34032. /**
  34033. * Gets a camera using its id
  34034. * @param id defines the id to look for
  34035. * @returns the camera or null if not found
  34036. */
  34037. getCameraByID(id: string): Nullable<Camera>;
  34038. /**
  34039. * Gets a camera using its unique id
  34040. * @param uniqueId defines the unique id to look for
  34041. * @returns the camera or null if not found
  34042. */
  34043. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34044. /**
  34045. * Gets a camera using its name
  34046. * @param name defines the camera's name
  34047. * @return the camera or null if none found.
  34048. */
  34049. getCameraByName(name: string): Nullable<Camera>;
  34050. /**
  34051. * Gets a bone using its id
  34052. * @param id defines the bone's id
  34053. * @return the bone or null if not found
  34054. */
  34055. getBoneByID(id: string): Nullable<Bone>;
  34056. /**
  34057. * Gets a bone using its id
  34058. * @param name defines the bone's name
  34059. * @return the bone or null if not found
  34060. */
  34061. getBoneByName(name: string): Nullable<Bone>;
  34062. /**
  34063. * Gets a light node using its name
  34064. * @param name defines the the light's name
  34065. * @return the light or null if none found.
  34066. */
  34067. getLightByName(name: string): Nullable<Light>;
  34068. /**
  34069. * Gets a light node using its id
  34070. * @param id defines the light's id
  34071. * @return the light or null if none found.
  34072. */
  34073. getLightByID(id: string): Nullable<Light>;
  34074. /**
  34075. * Gets a light node using its scene-generated unique ID
  34076. * @param uniqueId defines the light's unique id
  34077. * @return the light or null if none found.
  34078. */
  34079. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34080. /**
  34081. * Gets a particle system by id
  34082. * @param id defines the particle system id
  34083. * @return the corresponding system or null if none found
  34084. */
  34085. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34086. /**
  34087. * Gets a geometry using its ID
  34088. * @param id defines the geometry's id
  34089. * @return the geometry or null if none found.
  34090. */
  34091. getGeometryByID(id: string): Nullable<Geometry>;
  34092. private _getGeometryByUniqueID;
  34093. /**
  34094. * Add a new geometry to this scene
  34095. * @param geometry defines the geometry to be added to the scene.
  34096. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34097. * @return a boolean defining if the geometry was added or not
  34098. */
  34099. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34100. /**
  34101. * Removes an existing geometry
  34102. * @param geometry defines the geometry to be removed from the scene
  34103. * @return a boolean defining if the geometry was removed or not
  34104. */
  34105. removeGeometry(geometry: Geometry): boolean;
  34106. /**
  34107. * Gets the list of geometries attached to the scene
  34108. * @returns an array of Geometry
  34109. */
  34110. getGeometries(): Geometry[];
  34111. /**
  34112. * Gets the first added mesh found of a given ID
  34113. * @param id defines the id to search for
  34114. * @return the mesh found or null if not found at all
  34115. */
  34116. getMeshByID(id: string): Nullable<AbstractMesh>;
  34117. /**
  34118. * Gets a list of meshes using their id
  34119. * @param id defines the id to search for
  34120. * @returns a list of meshes
  34121. */
  34122. getMeshesByID(id: string): Array<AbstractMesh>;
  34123. /**
  34124. * Gets the first added transform node found of a given ID
  34125. * @param id defines the id to search for
  34126. * @return the found transform node or null if not found at all.
  34127. */
  34128. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34129. /**
  34130. * Gets a transform node with its auto-generated unique id
  34131. * @param uniqueId efines the unique id to search for
  34132. * @return the found transform node or null if not found at all.
  34133. */
  34134. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34135. /**
  34136. * Gets a list of transform nodes using their id
  34137. * @param id defines the id to search for
  34138. * @returns a list of transform nodes
  34139. */
  34140. getTransformNodesByID(id: string): Array<TransformNode>;
  34141. /**
  34142. * Gets a mesh with its auto-generated unique id
  34143. * @param uniqueId defines the unique id to search for
  34144. * @return the found mesh or null if not found at all.
  34145. */
  34146. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34147. /**
  34148. * Gets a the last added mesh using a given id
  34149. * @param id defines the id to search for
  34150. * @return the found mesh or null if not found at all.
  34151. */
  34152. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34153. /**
  34154. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34155. * @param id defines the id to search for
  34156. * @return the found node or null if not found at all
  34157. */
  34158. getLastEntryByID(id: string): Nullable<Node>;
  34159. /**
  34160. * Gets a node (Mesh, Camera, Light) using a given id
  34161. * @param id defines the id to search for
  34162. * @return the found node or null if not found at all
  34163. */
  34164. getNodeByID(id: string): Nullable<Node>;
  34165. /**
  34166. * Gets a node (Mesh, Camera, Light) using a given name
  34167. * @param name defines the name to search for
  34168. * @return the found node or null if not found at all.
  34169. */
  34170. getNodeByName(name: string): Nullable<Node>;
  34171. /**
  34172. * Gets a mesh using a given name
  34173. * @param name defines the name to search for
  34174. * @return the found mesh or null if not found at all.
  34175. */
  34176. getMeshByName(name: string): Nullable<AbstractMesh>;
  34177. /**
  34178. * Gets a transform node using a given name
  34179. * @param name defines the name to search for
  34180. * @return the found transform node or null if not found at all.
  34181. */
  34182. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34183. /**
  34184. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34185. * @param id defines the id to search for
  34186. * @return the found skeleton or null if not found at all.
  34187. */
  34188. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34189. /**
  34190. * Gets a skeleton using a given auto generated unique id
  34191. * @param uniqueId defines the unique id to search for
  34192. * @return the found skeleton or null if not found at all.
  34193. */
  34194. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34195. /**
  34196. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34197. * @param id defines the id to search for
  34198. * @return the found skeleton or null if not found at all.
  34199. */
  34200. getSkeletonById(id: string): Nullable<Skeleton>;
  34201. /**
  34202. * Gets a skeleton using a given name
  34203. * @param name defines the name to search for
  34204. * @return the found skeleton or null if not found at all.
  34205. */
  34206. getSkeletonByName(name: string): Nullable<Skeleton>;
  34207. /**
  34208. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34209. * @param id defines the id to search for
  34210. * @return the found morph target manager or null if not found at all.
  34211. */
  34212. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34213. /**
  34214. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34215. * @param id defines the id to search for
  34216. * @return the found morph target or null if not found at all.
  34217. */
  34218. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34219. /**
  34220. * Gets a boolean indicating if the given mesh is active
  34221. * @param mesh defines the mesh to look for
  34222. * @returns true if the mesh is in the active list
  34223. */
  34224. isActiveMesh(mesh: AbstractMesh): boolean;
  34225. /**
  34226. * Return a unique id as a string which can serve as an identifier for the scene
  34227. */
  34228. readonly uid: string;
  34229. /**
  34230. * Add an externaly attached data from its key.
  34231. * This method call will fail and return false, if such key already exists.
  34232. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34233. * @param key the unique key that identifies the data
  34234. * @param data the data object to associate to the key for this Engine instance
  34235. * @return true if no such key were already present and the data was added successfully, false otherwise
  34236. */
  34237. addExternalData<T>(key: string, data: T): boolean;
  34238. /**
  34239. * Get an externaly attached data from its key
  34240. * @param key the unique key that identifies the data
  34241. * @return the associated data, if present (can be null), or undefined if not present
  34242. */
  34243. getExternalData<T>(key: string): Nullable<T>;
  34244. /**
  34245. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34246. * @param key the unique key that identifies the data
  34247. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34248. * @return the associated data, can be null if the factory returned null.
  34249. */
  34250. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34251. /**
  34252. * Remove an externaly attached data from the Engine instance
  34253. * @param key the unique key that identifies the data
  34254. * @return true if the data was successfully removed, false if it doesn't exist
  34255. */
  34256. removeExternalData(key: string): boolean;
  34257. private _evaluateSubMesh;
  34258. /**
  34259. * Clear the processed materials smart array preventing retention point in material dispose.
  34260. */
  34261. freeProcessedMaterials(): void;
  34262. private _preventFreeActiveMeshesAndRenderingGroups;
  34263. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34264. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34265. * when disposing several meshes in a row or a hierarchy of meshes.
  34266. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34267. */
  34268. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34269. /**
  34270. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34271. */
  34272. freeActiveMeshes(): void;
  34273. /**
  34274. * Clear the info related to rendering groups preventing retention points during dispose.
  34275. */
  34276. freeRenderingGroups(): void;
  34277. /** @hidden */
  34278. _isInIntermediateRendering(): boolean;
  34279. /**
  34280. * Lambda returning the list of potentially active meshes.
  34281. */
  34282. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34283. /**
  34284. * Lambda returning the list of potentially active sub meshes.
  34285. */
  34286. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34287. /**
  34288. * Lambda returning the list of potentially intersecting sub meshes.
  34289. */
  34290. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34291. /**
  34292. * Lambda returning the list of potentially colliding sub meshes.
  34293. */
  34294. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34295. private _activeMeshesFrozen;
  34296. /**
  34297. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34298. * @returns the current scene
  34299. */
  34300. freezeActiveMeshes(): Scene;
  34301. /**
  34302. * Use this function to restart evaluating active meshes on every frame
  34303. * @returns the current scene
  34304. */
  34305. unfreezeActiveMeshes(): Scene;
  34306. private _evaluateActiveMeshes;
  34307. private _activeMesh;
  34308. /**
  34309. * Update the transform matrix to update from the current active camera
  34310. * @param force defines a boolean used to force the update even if cache is up to date
  34311. */
  34312. updateTransformMatrix(force?: boolean): void;
  34313. private _bindFrameBuffer;
  34314. /** @hidden */
  34315. _allowPostProcessClearColor: boolean;
  34316. /** @hidden */
  34317. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34318. private _processSubCameras;
  34319. private _checkIntersections;
  34320. /** @hidden */
  34321. _advancePhysicsEngineStep(step: number): void;
  34322. /**
  34323. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34324. */
  34325. getDeterministicFrameTime: () => number;
  34326. /** @hidden */
  34327. _animate(): void;
  34328. /** Execute all animations (for a frame) */
  34329. animate(): void;
  34330. /**
  34331. * Render the scene
  34332. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34333. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34334. */
  34335. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34336. /**
  34337. * Freeze all materials
  34338. * A frozen material will not be updatable but should be faster to render
  34339. */
  34340. freezeMaterials(): void;
  34341. /**
  34342. * Unfreeze all materials
  34343. * A frozen material will not be updatable but should be faster to render
  34344. */
  34345. unfreezeMaterials(): void;
  34346. /**
  34347. * Releases all held ressources
  34348. */
  34349. dispose(): void;
  34350. /**
  34351. * Gets if the scene is already disposed
  34352. */
  34353. readonly isDisposed: boolean;
  34354. /**
  34355. * Call this function to reduce memory footprint of the scene.
  34356. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34357. */
  34358. clearCachedVertexData(): void;
  34359. /**
  34360. * This function will remove the local cached buffer data from texture.
  34361. * It will save memory but will prevent the texture from being rebuilt
  34362. */
  34363. cleanCachedTextureBuffer(): void;
  34364. /**
  34365. * Get the world extend vectors with an optional filter
  34366. *
  34367. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34368. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34369. */
  34370. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34371. min: Vector3;
  34372. max: Vector3;
  34373. };
  34374. /**
  34375. * Creates a ray that can be used to pick in the scene
  34376. * @param x defines the x coordinate of the origin (on-screen)
  34377. * @param y defines the y coordinate of the origin (on-screen)
  34378. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34379. * @param camera defines the camera to use for the picking
  34380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34381. * @returns a Ray
  34382. */
  34383. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34384. /**
  34385. * Creates a ray that can be used to pick in the scene
  34386. * @param x defines the x coordinate of the origin (on-screen)
  34387. * @param y defines the y coordinate of the origin (on-screen)
  34388. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34389. * @param result defines the ray where to store the picking ray
  34390. * @param camera defines the camera to use for the picking
  34391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34392. * @returns the current scene
  34393. */
  34394. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34395. /**
  34396. * Creates a ray that can be used to pick in the scene
  34397. * @param x defines the x coordinate of the origin (on-screen)
  34398. * @param y defines the y coordinate of the origin (on-screen)
  34399. * @param camera defines the camera to use for the picking
  34400. * @returns a Ray
  34401. */
  34402. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34403. /**
  34404. * Creates a ray that can be used to pick in the scene
  34405. * @param x defines the x coordinate of the origin (on-screen)
  34406. * @param y defines the y coordinate of the origin (on-screen)
  34407. * @param result defines the ray where to store the picking ray
  34408. * @param camera defines the camera to use for the picking
  34409. * @returns the current scene
  34410. */
  34411. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34412. /** Launch a ray to try to pick a mesh in the scene
  34413. * @param x position on screen
  34414. * @param y position on screen
  34415. * @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
  34416. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34417. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34419. * @returns a PickingInfo
  34420. */
  34421. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34422. /** Use the given ray to pick a mesh in the scene
  34423. * @param ray The ray to use to pick meshes
  34424. * @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
  34425. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34427. * @returns a PickingInfo
  34428. */
  34429. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34430. /**
  34431. * Launch a ray to try to pick a mesh in the scene
  34432. * @param x X position on screen
  34433. * @param y Y position on screen
  34434. * @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
  34435. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34437. * @returns an array of PickingInfo
  34438. */
  34439. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34440. /**
  34441. * Launch a ray to try to pick a mesh in the scene
  34442. * @param ray Ray to use
  34443. * @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
  34444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34445. * @returns an array of PickingInfo
  34446. */
  34447. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34448. /**
  34449. * Force the value of meshUnderPointer
  34450. * @param mesh defines the mesh to use
  34451. */
  34452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34453. /**
  34454. * Gets the mesh under the pointer
  34455. * @returns a Mesh or null if no mesh is under the pointer
  34456. */
  34457. getPointerOverMesh(): Nullable<AbstractMesh>;
  34458. /** @hidden */
  34459. _rebuildGeometries(): void;
  34460. /** @hidden */
  34461. _rebuildTextures(): void;
  34462. private _getByTags;
  34463. /**
  34464. * Get a list of meshes by tags
  34465. * @param tagsQuery defines the tags query to use
  34466. * @param forEach defines a predicate used to filter results
  34467. * @returns an array of Mesh
  34468. */
  34469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34470. /**
  34471. * Get a list of cameras by tags
  34472. * @param tagsQuery defines the tags query to use
  34473. * @param forEach defines a predicate used to filter results
  34474. * @returns an array of Camera
  34475. */
  34476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34477. /**
  34478. * Get a list of lights by tags
  34479. * @param tagsQuery defines the tags query to use
  34480. * @param forEach defines a predicate used to filter results
  34481. * @returns an array of Light
  34482. */
  34483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34484. /**
  34485. * Get a list of materials by tags
  34486. * @param tagsQuery defines the tags query to use
  34487. * @param forEach defines a predicate used to filter results
  34488. * @returns an array of Material
  34489. */
  34490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34491. /**
  34492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34493. * This allowed control for front to back rendering or reversly depending of the special needs.
  34494. *
  34495. * @param renderingGroupId The rendering group id corresponding to its index
  34496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34499. */
  34500. 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;
  34501. /**
  34502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34503. *
  34504. * @param renderingGroupId The rendering group id corresponding to its index
  34505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34508. */
  34509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34510. /**
  34511. * Gets the current auto clear configuration for one rendering group of the rendering
  34512. * manager.
  34513. * @param index the rendering group index to get the information for
  34514. * @returns The auto clear setup for the requested rendering group
  34515. */
  34516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34517. private _blockMaterialDirtyMechanism;
  34518. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34519. blockMaterialDirtyMechanism: boolean;
  34520. /**
  34521. * Will flag all materials as dirty to trigger new shader compilation
  34522. * @param flag defines the flag used to specify which material part must be marked as dirty
  34523. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34524. */
  34525. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34526. /** @hidden */
  34527. _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;
  34528. /** @hidden */
  34529. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34530. }
  34531. }
  34532. declare module "babylonjs/assetContainer" {
  34533. import { AbstractScene } from "babylonjs/abstractScene";
  34534. import { Scene } from "babylonjs/scene";
  34535. import { Mesh } from "babylonjs/Meshes/mesh";
  34536. /**
  34537. * Set of assets to keep when moving a scene into an asset container.
  34538. */
  34539. export class KeepAssets extends AbstractScene {
  34540. }
  34541. /**
  34542. * Container with a set of assets that can be added or removed from a scene.
  34543. */
  34544. export class AssetContainer extends AbstractScene {
  34545. /**
  34546. * The scene the AssetContainer belongs to.
  34547. */
  34548. scene: Scene;
  34549. /**
  34550. * Instantiates an AssetContainer.
  34551. * @param scene The scene the AssetContainer belongs to.
  34552. */
  34553. constructor(scene: Scene);
  34554. /**
  34555. * Adds all the assets from the container to the scene.
  34556. */
  34557. addAllToScene(): void;
  34558. /**
  34559. * Removes all the assets in the container from the scene
  34560. */
  34561. removeAllFromScene(): void;
  34562. /**
  34563. * Disposes all the assets in the container
  34564. */
  34565. dispose(): void;
  34566. private _moveAssets;
  34567. /**
  34568. * Removes all the assets contained in the scene and adds them to the container.
  34569. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34570. */
  34571. moveAllFromScene(keepAssets?: KeepAssets): void;
  34572. /**
  34573. * 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.
  34574. * @returns the root mesh
  34575. */
  34576. createRootMesh(): Mesh;
  34577. }
  34578. }
  34579. declare module "babylonjs/abstractScene" {
  34580. import { Scene } from "babylonjs/scene";
  34581. import { Nullable } from "babylonjs/types";
  34582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34583. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34584. import { Geometry } from "babylonjs/Meshes/geometry";
  34585. import { Skeleton } from "babylonjs/Bones/skeleton";
  34586. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34587. import { AssetContainer } from "babylonjs/assetContainer";
  34588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34589. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34591. import { Material } from "babylonjs/Materials/material";
  34592. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34593. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34594. import { Camera } from "babylonjs/Cameras/camera";
  34595. import { Light } from "babylonjs/Lights/light";
  34596. import { Node } from "babylonjs/node";
  34597. import { Animation } from "babylonjs/Animations/animation";
  34598. /**
  34599. * Defines how the parser contract is defined.
  34600. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34601. */
  34602. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34603. /**
  34604. * Defines how the individual parser contract is defined.
  34605. * These parser can parse an individual asset
  34606. */
  34607. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34608. /**
  34609. * Base class of the scene acting as a container for the different elements composing a scene.
  34610. * This class is dynamically extended by the different components of the scene increasing
  34611. * flexibility and reducing coupling
  34612. */
  34613. export abstract class AbstractScene {
  34614. /**
  34615. * Stores the list of available parsers in the application.
  34616. */
  34617. private static _BabylonFileParsers;
  34618. /**
  34619. * Stores the list of available individual parsers in the application.
  34620. */
  34621. private static _IndividualBabylonFileParsers;
  34622. /**
  34623. * Adds a parser in the list of available ones
  34624. * @param name Defines the name of the parser
  34625. * @param parser Defines the parser to add
  34626. */
  34627. static AddParser(name: string, parser: BabylonFileParser): void;
  34628. /**
  34629. * Gets a general parser from the list of avaialble ones
  34630. * @param name Defines the name of the parser
  34631. * @returns the requested parser or null
  34632. */
  34633. static GetParser(name: string): Nullable<BabylonFileParser>;
  34634. /**
  34635. * Adds n individual parser in the list of available ones
  34636. * @param name Defines the name of the parser
  34637. * @param parser Defines the parser to add
  34638. */
  34639. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34640. /**
  34641. * Gets an individual parser from the list of avaialble ones
  34642. * @param name Defines the name of the parser
  34643. * @returns the requested parser or null
  34644. */
  34645. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34646. /**
  34647. * Parser json data and populate both a scene and its associated container object
  34648. * @param jsonData Defines the data to parse
  34649. * @param scene Defines the scene to parse the data for
  34650. * @param container Defines the container attached to the parsing sequence
  34651. * @param rootUrl Defines the root url of the data
  34652. */
  34653. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34654. /**
  34655. * Gets the list of root nodes (ie. nodes with no parent)
  34656. */
  34657. rootNodes: Node[];
  34658. /** All of the cameras added to this scene
  34659. * @see http://doc.babylonjs.com/babylon101/cameras
  34660. */
  34661. cameras: Camera[];
  34662. /**
  34663. * All of the lights added to this scene
  34664. * @see http://doc.babylonjs.com/babylon101/lights
  34665. */
  34666. lights: Light[];
  34667. /**
  34668. * All of the (abstract) meshes added to this scene
  34669. */
  34670. meshes: AbstractMesh[];
  34671. /**
  34672. * The list of skeletons added to the scene
  34673. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34674. */
  34675. skeletons: Skeleton[];
  34676. /**
  34677. * All of the particle systems added to this scene
  34678. * @see http://doc.babylonjs.com/babylon101/particles
  34679. */
  34680. particleSystems: IParticleSystem[];
  34681. /**
  34682. * Gets a list of Animations associated with the scene
  34683. */
  34684. animations: Animation[];
  34685. /**
  34686. * All of the animation groups added to this scene
  34687. * @see http://doc.babylonjs.com/how_to/group
  34688. */
  34689. animationGroups: AnimationGroup[];
  34690. /**
  34691. * All of the multi-materials added to this scene
  34692. * @see http://doc.babylonjs.com/how_to/multi_materials
  34693. */
  34694. multiMaterials: MultiMaterial[];
  34695. /**
  34696. * All of the materials added to this scene
  34697. * In the context of a Scene, it is not supposed to be modified manually.
  34698. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34699. * Note also that the order of the Material wihin the array is not significant and might change.
  34700. * @see http://doc.babylonjs.com/babylon101/materials
  34701. */
  34702. materials: Material[];
  34703. /**
  34704. * The list of morph target managers added to the scene
  34705. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34706. */
  34707. morphTargetManagers: MorphTargetManager[];
  34708. /**
  34709. * The list of geometries used in the scene.
  34710. */
  34711. geometries: Geometry[];
  34712. /**
  34713. * All of the tranform nodes added to this scene
  34714. * In the context of a Scene, it is not supposed to be modified manually.
  34715. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34716. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34717. * @see http://doc.babylonjs.com/how_to/transformnode
  34718. */
  34719. transformNodes: TransformNode[];
  34720. /**
  34721. * ActionManagers available on the scene.
  34722. */
  34723. actionManagers: AbstractActionManager[];
  34724. /**
  34725. * Textures to keep.
  34726. */
  34727. textures: BaseTexture[];
  34728. /**
  34729. * Environment texture for the scene
  34730. */
  34731. environmentTexture: Nullable<BaseTexture>;
  34732. }
  34733. }
  34734. declare module "babylonjs/Audio/sound" {
  34735. import { Observable } from "babylonjs/Misc/observable";
  34736. import { Vector3 } from "babylonjs/Maths/math";
  34737. import { Nullable } from "babylonjs/types";
  34738. import { Scene } from "babylonjs/scene";
  34739. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34740. /**
  34741. * Defines a sound that can be played in the application.
  34742. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34744. */
  34745. export class Sound {
  34746. /**
  34747. * The name of the sound in the scene.
  34748. */
  34749. name: string;
  34750. /**
  34751. * Does the sound autoplay once loaded.
  34752. */
  34753. autoplay: boolean;
  34754. /**
  34755. * Does the sound loop after it finishes playing once.
  34756. */
  34757. loop: boolean;
  34758. /**
  34759. * Does the sound use a custom attenuation curve to simulate the falloff
  34760. * happening when the source gets further away from the camera.
  34761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34762. */
  34763. useCustomAttenuation: boolean;
  34764. /**
  34765. * The sound track id this sound belongs to.
  34766. */
  34767. soundTrackId: number;
  34768. /**
  34769. * Is this sound currently played.
  34770. */
  34771. isPlaying: boolean;
  34772. /**
  34773. * Is this sound currently paused.
  34774. */
  34775. isPaused: boolean;
  34776. /**
  34777. * Does this sound enables spatial sound.
  34778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34779. */
  34780. spatialSound: boolean;
  34781. /**
  34782. * Define the reference distance the sound should be heard perfectly.
  34783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34784. */
  34785. refDistance: number;
  34786. /**
  34787. * Define the roll off factor of spatial sounds.
  34788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34789. */
  34790. rolloffFactor: number;
  34791. /**
  34792. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34794. */
  34795. maxDistance: number;
  34796. /**
  34797. * Define the distance attenuation model the sound will follow.
  34798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34799. */
  34800. distanceModel: string;
  34801. /**
  34802. * @hidden
  34803. * Back Compat
  34804. **/
  34805. onended: () => any;
  34806. /**
  34807. * Observable event when the current playing sound finishes.
  34808. */
  34809. onEndedObservable: Observable<Sound>;
  34810. private _panningModel;
  34811. private _playbackRate;
  34812. private _streaming;
  34813. private _startTime;
  34814. private _startOffset;
  34815. private _position;
  34816. /** @hidden */
  34817. _positionInEmitterSpace: boolean;
  34818. private _localDirection;
  34819. private _volume;
  34820. private _isReadyToPlay;
  34821. private _isDirectional;
  34822. private _readyToPlayCallback;
  34823. private _audioBuffer;
  34824. private _soundSource;
  34825. private _streamingSource;
  34826. private _soundPanner;
  34827. private _soundGain;
  34828. private _inputAudioNode;
  34829. private _outputAudioNode;
  34830. private _coneInnerAngle;
  34831. private _coneOuterAngle;
  34832. private _coneOuterGain;
  34833. private _scene;
  34834. private _connectedTransformNode;
  34835. private _customAttenuationFunction;
  34836. private _registerFunc;
  34837. private _isOutputConnected;
  34838. private _htmlAudioElement;
  34839. private _urlType;
  34840. /** @hidden */
  34841. static _SceneComponentInitialization: (scene: Scene) => void;
  34842. /**
  34843. * Create a sound and attach it to a scene
  34844. * @param name Name of your sound
  34845. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34846. * @param scene defines the scene the sound belongs to
  34847. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34848. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34849. */
  34850. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34851. /**
  34852. * Release the sound and its associated resources
  34853. */
  34854. dispose(): void;
  34855. /**
  34856. * Gets if the sounds is ready to be played or not.
  34857. * @returns true if ready, otherwise false
  34858. */
  34859. isReady(): boolean;
  34860. private _soundLoaded;
  34861. /**
  34862. * Sets the data of the sound from an audiobuffer
  34863. * @param audioBuffer The audioBuffer containing the data
  34864. */
  34865. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34866. /**
  34867. * Updates the current sounds options such as maxdistance, loop...
  34868. * @param options A JSON object containing values named as the object properties
  34869. */
  34870. updateOptions(options: any): void;
  34871. private _createSpatialParameters;
  34872. private _updateSpatialParameters;
  34873. /**
  34874. * Switch the panning model to HRTF:
  34875. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34877. */
  34878. switchPanningModelToHRTF(): void;
  34879. /**
  34880. * Switch the panning model to Equal Power:
  34881. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34883. */
  34884. switchPanningModelToEqualPower(): void;
  34885. private _switchPanningModel;
  34886. /**
  34887. * Connect this sound to a sound track audio node like gain...
  34888. * @param soundTrackAudioNode the sound track audio node to connect to
  34889. */
  34890. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34891. /**
  34892. * Transform this sound into a directional source
  34893. * @param coneInnerAngle Size of the inner cone in degree
  34894. * @param coneOuterAngle Size of the outer cone in degree
  34895. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34896. */
  34897. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34898. /**
  34899. * Gets or sets the inner angle for the directional cone.
  34900. */
  34901. /**
  34902. * Gets or sets the inner angle for the directional cone.
  34903. */
  34904. directionalConeInnerAngle: number;
  34905. /**
  34906. * Gets or sets the outer angle for the directional cone.
  34907. */
  34908. /**
  34909. * Gets or sets the outer angle for the directional cone.
  34910. */
  34911. directionalConeOuterAngle: number;
  34912. /**
  34913. * Sets the position of the emitter if spatial sound is enabled
  34914. * @param newPosition Defines the new posisiton
  34915. */
  34916. setPosition(newPosition: Vector3): void;
  34917. /**
  34918. * Sets the local direction of the emitter if spatial sound is enabled
  34919. * @param newLocalDirection Defines the new local direction
  34920. */
  34921. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34922. private _updateDirection;
  34923. /** @hidden */
  34924. updateDistanceFromListener(): void;
  34925. /**
  34926. * Sets a new custom attenuation function for the sound.
  34927. * @param callback Defines the function used for the attenuation
  34928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34929. */
  34930. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34931. /**
  34932. * Play the sound
  34933. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34934. * @param offset (optional) Start the sound setting it at a specific time
  34935. */
  34936. play(time?: number, offset?: number): void;
  34937. private _onended;
  34938. /**
  34939. * Stop the sound
  34940. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34941. */
  34942. stop(time?: number): void;
  34943. /**
  34944. * Put the sound in pause
  34945. */
  34946. pause(): void;
  34947. /**
  34948. * Sets a dedicated volume for this sounds
  34949. * @param newVolume Define the new volume of the sound
  34950. * @param time Define in how long the sound should be at this value
  34951. */
  34952. setVolume(newVolume: number, time?: number): void;
  34953. /**
  34954. * Set the sound play back rate
  34955. * @param newPlaybackRate Define the playback rate the sound should be played at
  34956. */
  34957. setPlaybackRate(newPlaybackRate: number): void;
  34958. /**
  34959. * Gets the volume of the sound.
  34960. * @returns the volume of the sound
  34961. */
  34962. getVolume(): number;
  34963. /**
  34964. * Attach the sound to a dedicated mesh
  34965. * @param transformNode The transform node to connect the sound with
  34966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34967. */
  34968. attachToMesh(transformNode: TransformNode): void;
  34969. /**
  34970. * Detach the sound from the previously attached mesh
  34971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34972. */
  34973. detachFromMesh(): void;
  34974. private _onRegisterAfterWorldMatrixUpdate;
  34975. /**
  34976. * Clone the current sound in the scene.
  34977. * @returns the new sound clone
  34978. */
  34979. clone(): Nullable<Sound>;
  34980. /**
  34981. * Gets the current underlying audio buffer containing the data
  34982. * @returns the audio buffer
  34983. */
  34984. getAudioBuffer(): Nullable<AudioBuffer>;
  34985. /**
  34986. * Serializes the Sound in a JSON representation
  34987. * @returns the JSON representation of the sound
  34988. */
  34989. serialize(): any;
  34990. /**
  34991. * Parse a JSON representation of a sound to innstantiate in a given scene
  34992. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34993. * @param scene Define the scene the new parsed sound should be created in
  34994. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34995. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34996. * @returns the newly parsed sound
  34997. */
  34998. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34999. }
  35000. }
  35001. declare module "babylonjs/Actions/directAudioActions" {
  35002. import { Action } from "babylonjs/Actions/action";
  35003. import { Condition } from "babylonjs/Actions/condition";
  35004. import { Sound } from "babylonjs/Audio/sound";
  35005. /**
  35006. * This defines an action helpful to play a defined sound on a triggered action.
  35007. */
  35008. export class PlaySoundAction extends Action {
  35009. private _sound;
  35010. /**
  35011. * Instantiate the action
  35012. * @param triggerOptions defines the trigger options
  35013. * @param sound defines the sound to play
  35014. * @param condition defines the trigger related conditions
  35015. */
  35016. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35017. /** @hidden */
  35018. _prepare(): void;
  35019. /**
  35020. * Execute the action and play the sound.
  35021. */
  35022. execute(): void;
  35023. /**
  35024. * Serializes the actions and its related information.
  35025. * @param parent defines the object to serialize in
  35026. * @returns the serialized object
  35027. */
  35028. serialize(parent: any): any;
  35029. }
  35030. /**
  35031. * This defines an action helpful to stop a defined sound on a triggered action.
  35032. */
  35033. export class StopSoundAction extends Action {
  35034. private _sound;
  35035. /**
  35036. * Instantiate the action
  35037. * @param triggerOptions defines the trigger options
  35038. * @param sound defines the sound to stop
  35039. * @param condition defines the trigger related conditions
  35040. */
  35041. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35042. /** @hidden */
  35043. _prepare(): void;
  35044. /**
  35045. * Execute the action and stop the sound.
  35046. */
  35047. execute(): void;
  35048. /**
  35049. * Serializes the actions and its related information.
  35050. * @param parent defines the object to serialize in
  35051. * @returns the serialized object
  35052. */
  35053. serialize(parent: any): any;
  35054. }
  35055. }
  35056. declare module "babylonjs/Actions/interpolateValueAction" {
  35057. import { Action } from "babylonjs/Actions/action";
  35058. import { Condition } from "babylonjs/Actions/condition";
  35059. import { Observable } from "babylonjs/Misc/observable";
  35060. /**
  35061. * This defines an action responsible to change the value of a property
  35062. * by interpolating between its current value and the newly set one once triggered.
  35063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35064. */
  35065. export class InterpolateValueAction extends Action {
  35066. /**
  35067. * Defines the path of the property where the value should be interpolated
  35068. */
  35069. propertyPath: string;
  35070. /**
  35071. * Defines the target value at the end of the interpolation.
  35072. */
  35073. value: any;
  35074. /**
  35075. * Defines the time it will take for the property to interpolate to the value.
  35076. */
  35077. duration: number;
  35078. /**
  35079. * Defines if the other scene animations should be stopped when the action has been triggered
  35080. */
  35081. stopOtherAnimations?: boolean;
  35082. /**
  35083. * Defines a callback raised once the interpolation animation has been done.
  35084. */
  35085. onInterpolationDone?: () => void;
  35086. /**
  35087. * Observable triggered once the interpolation animation has been done.
  35088. */
  35089. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35090. private _target;
  35091. private _effectiveTarget;
  35092. private _property;
  35093. /**
  35094. * Instantiate the action
  35095. * @param triggerOptions defines the trigger options
  35096. * @param target defines the object containing the value to interpolate
  35097. * @param propertyPath defines the path to the property in the target object
  35098. * @param value defines the target value at the end of the interpolation
  35099. * @param duration deines the time it will take for the property to interpolate to the value.
  35100. * @param condition defines the trigger related conditions
  35101. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35102. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35103. */
  35104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35105. /** @hidden */
  35106. _prepare(): void;
  35107. /**
  35108. * Execute the action starts the value interpolation.
  35109. */
  35110. execute(): void;
  35111. /**
  35112. * Serializes the actions and its related information.
  35113. * @param parent defines the object to serialize in
  35114. * @returns the serialized object
  35115. */
  35116. serialize(parent: any): any;
  35117. }
  35118. }
  35119. declare module "babylonjs/Actions/index" {
  35120. export * from "babylonjs/Actions/action";
  35121. export * from "babylonjs/Actions/actionEvent";
  35122. export * from "babylonjs/Actions/actionManager";
  35123. export * from "babylonjs/Actions/condition";
  35124. export * from "babylonjs/Actions/directActions";
  35125. export * from "babylonjs/Actions/directAudioActions";
  35126. export * from "babylonjs/Actions/interpolateValueAction";
  35127. }
  35128. declare module "babylonjs/Animations/index" {
  35129. export * from "babylonjs/Animations/animatable";
  35130. export * from "babylonjs/Animations/animation";
  35131. export * from "babylonjs/Animations/animationGroup";
  35132. export * from "babylonjs/Animations/animationPropertiesOverride";
  35133. export * from "babylonjs/Animations/easing";
  35134. export * from "babylonjs/Animations/runtimeAnimation";
  35135. export * from "babylonjs/Animations/animationEvent";
  35136. export * from "babylonjs/Animations/animationGroup";
  35137. export * from "babylonjs/Animations/animationKey";
  35138. export * from "babylonjs/Animations/animationRange";
  35139. }
  35140. declare module "babylonjs/Audio/soundTrack" {
  35141. import { Sound } from "babylonjs/Audio/sound";
  35142. import { Analyser } from "babylonjs/Audio/analyser";
  35143. import { Scene } from "babylonjs/scene";
  35144. /**
  35145. * Options allowed during the creation of a sound track.
  35146. */
  35147. export interface ISoundTrackOptions {
  35148. /**
  35149. * The volume the sound track should take during creation
  35150. */
  35151. volume?: number;
  35152. /**
  35153. * Define if the sound track is the main sound track of the scene
  35154. */
  35155. mainTrack?: boolean;
  35156. }
  35157. /**
  35158. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35159. * It will be also used in a future release to apply effects on a specific track.
  35160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35161. */
  35162. export class SoundTrack {
  35163. /**
  35164. * The unique identifier of the sound track in the scene.
  35165. */
  35166. id: number;
  35167. /**
  35168. * The list of sounds included in the sound track.
  35169. */
  35170. soundCollection: Array<Sound>;
  35171. private _outputAudioNode;
  35172. private _scene;
  35173. private _isMainTrack;
  35174. private _connectedAnalyser;
  35175. private _options;
  35176. private _isInitialized;
  35177. /**
  35178. * Creates a new sound track.
  35179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35180. * @param scene Define the scene the sound track belongs to
  35181. * @param options
  35182. */
  35183. constructor(scene: Scene, options?: ISoundTrackOptions);
  35184. private _initializeSoundTrackAudioGraph;
  35185. /**
  35186. * Release the sound track and its associated resources
  35187. */
  35188. dispose(): void;
  35189. /**
  35190. * Adds a sound to this sound track
  35191. * @param sound define the cound to add
  35192. * @ignoreNaming
  35193. */
  35194. AddSound(sound: Sound): void;
  35195. /**
  35196. * Removes a sound to this sound track
  35197. * @param sound define the cound to remove
  35198. * @ignoreNaming
  35199. */
  35200. RemoveSound(sound: Sound): void;
  35201. /**
  35202. * Set a global volume for the full sound track.
  35203. * @param newVolume Define the new volume of the sound track
  35204. */
  35205. setVolume(newVolume: number): void;
  35206. /**
  35207. * Switch the panning model to HRTF:
  35208. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35210. */
  35211. switchPanningModelToHRTF(): void;
  35212. /**
  35213. * Switch the panning model to Equal Power:
  35214. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35216. */
  35217. switchPanningModelToEqualPower(): void;
  35218. /**
  35219. * Connect the sound track to an audio analyser allowing some amazing
  35220. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35222. * @param analyser The analyser to connect to the engine
  35223. */
  35224. connectToAnalyser(analyser: Analyser): void;
  35225. }
  35226. }
  35227. declare module "babylonjs/Audio/audioSceneComponent" {
  35228. import { Sound } from "babylonjs/Audio/sound";
  35229. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35230. import { Nullable } from "babylonjs/types";
  35231. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35232. import { Scene } from "babylonjs/scene";
  35233. import { AbstractScene } from "babylonjs/abstractScene";
  35234. module "babylonjs/abstractScene" {
  35235. interface AbstractScene {
  35236. /**
  35237. * The list of sounds used in the scene.
  35238. */
  35239. sounds: Nullable<Array<Sound>>;
  35240. }
  35241. }
  35242. module "babylonjs/scene" {
  35243. interface Scene {
  35244. /**
  35245. * @hidden
  35246. * Backing field
  35247. */
  35248. _mainSoundTrack: SoundTrack;
  35249. /**
  35250. * The main sound track played by the scene.
  35251. * It cotains your primary collection of sounds.
  35252. */
  35253. mainSoundTrack: SoundTrack;
  35254. /**
  35255. * The list of sound tracks added to the scene
  35256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35257. */
  35258. soundTracks: Nullable<Array<SoundTrack>>;
  35259. /**
  35260. * Gets a sound using a given name
  35261. * @param name defines the name to search for
  35262. * @return the found sound or null if not found at all.
  35263. */
  35264. getSoundByName(name: string): Nullable<Sound>;
  35265. /**
  35266. * Gets or sets if audio support is enabled
  35267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35268. */
  35269. audioEnabled: boolean;
  35270. /**
  35271. * Gets or sets if audio will be output to headphones
  35272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35273. */
  35274. headphone: boolean;
  35275. }
  35276. }
  35277. /**
  35278. * Defines the sound scene component responsible to manage any sounds
  35279. * in a given scene.
  35280. */
  35281. export class AudioSceneComponent implements ISceneSerializableComponent {
  35282. /**
  35283. * The component name helpfull to identify the component in the list of scene components.
  35284. */
  35285. readonly name: string;
  35286. /**
  35287. * The scene the component belongs to.
  35288. */
  35289. scene: Scene;
  35290. private _audioEnabled;
  35291. /**
  35292. * Gets whether audio is enabled or not.
  35293. * Please use related enable/disable method to switch state.
  35294. */
  35295. readonly audioEnabled: boolean;
  35296. private _headphone;
  35297. /**
  35298. * Gets whether audio is outputing to headphone or not.
  35299. * Please use the according Switch methods to change output.
  35300. */
  35301. readonly headphone: boolean;
  35302. /**
  35303. * Creates a new instance of the component for the given scene
  35304. * @param scene Defines the scene to register the component in
  35305. */
  35306. constructor(scene: Scene);
  35307. /**
  35308. * Registers the component in a given scene
  35309. */
  35310. register(): void;
  35311. /**
  35312. * Rebuilds the elements related to this component in case of
  35313. * context lost for instance.
  35314. */
  35315. rebuild(): void;
  35316. /**
  35317. * Serializes the component data to the specified json object
  35318. * @param serializationObject The object to serialize to
  35319. */
  35320. serialize(serializationObject: any): void;
  35321. /**
  35322. * Adds all the element from the container to the scene
  35323. * @param container the container holding the elements
  35324. */
  35325. addFromContainer(container: AbstractScene): void;
  35326. /**
  35327. * Removes all the elements in the container from the scene
  35328. * @param container contains the elements to remove
  35329. * @param dispose if the removed element should be disposed (default: false)
  35330. */
  35331. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35332. /**
  35333. * Disposes the component and the associated ressources.
  35334. */
  35335. dispose(): void;
  35336. /**
  35337. * Disables audio in the associated scene.
  35338. */
  35339. disableAudio(): void;
  35340. /**
  35341. * Enables audio in the associated scene.
  35342. */
  35343. enableAudio(): void;
  35344. /**
  35345. * Switch audio to headphone output.
  35346. */
  35347. switchAudioModeForHeadphones(): void;
  35348. /**
  35349. * Switch audio to normal speakers.
  35350. */
  35351. switchAudioModeForNormalSpeakers(): void;
  35352. private _afterRender;
  35353. }
  35354. }
  35355. declare module "babylonjs/Audio/weightedsound" {
  35356. import { Sound } from "babylonjs/Audio/sound";
  35357. /**
  35358. * Wraps one or more Sound objects and selects one with random weight for playback.
  35359. */
  35360. export class WeightedSound {
  35361. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35362. loop: boolean;
  35363. private _coneInnerAngle;
  35364. private _coneOuterAngle;
  35365. private _volume;
  35366. /** A Sound is currently playing. */
  35367. isPlaying: boolean;
  35368. /** A Sound is currently paused. */
  35369. isPaused: boolean;
  35370. private _sounds;
  35371. private _weights;
  35372. private _currentIndex?;
  35373. /**
  35374. * Creates a new WeightedSound from the list of sounds given.
  35375. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35376. * @param sounds Array of Sounds that will be selected from.
  35377. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35378. */
  35379. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35380. /**
  35381. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35382. */
  35383. /**
  35384. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35385. */
  35386. directionalConeInnerAngle: number;
  35387. /**
  35388. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35389. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35390. */
  35391. /**
  35392. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35393. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35394. */
  35395. directionalConeOuterAngle: number;
  35396. /**
  35397. * Playback volume.
  35398. */
  35399. /**
  35400. * Playback volume.
  35401. */
  35402. volume: number;
  35403. private _onended;
  35404. /**
  35405. * Suspend playback
  35406. */
  35407. pause(): void;
  35408. /**
  35409. * Stop playback
  35410. */
  35411. stop(): void;
  35412. /**
  35413. * Start playback.
  35414. * @param startOffset Position the clip head at a specific time in seconds.
  35415. */
  35416. play(startOffset?: number): void;
  35417. }
  35418. }
  35419. declare module "babylonjs/Audio/index" {
  35420. export * from "babylonjs/Audio/analyser";
  35421. export * from "babylonjs/Audio/audioEngine";
  35422. export * from "babylonjs/Audio/audioSceneComponent";
  35423. export * from "babylonjs/Audio/sound";
  35424. export * from "babylonjs/Audio/soundTrack";
  35425. export * from "babylonjs/Audio/weightedsound";
  35426. }
  35427. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35428. import { Behavior } from "babylonjs/Behaviors/behavior";
  35429. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35430. import { BackEase } from "babylonjs/Animations/easing";
  35431. /**
  35432. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35433. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35434. */
  35435. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35436. /**
  35437. * Gets the name of the behavior.
  35438. */
  35439. readonly name: string;
  35440. /**
  35441. * The easing function used by animations
  35442. */
  35443. static EasingFunction: BackEase;
  35444. /**
  35445. * The easing mode used by animations
  35446. */
  35447. static EasingMode: number;
  35448. /**
  35449. * The duration of the animation, in milliseconds
  35450. */
  35451. transitionDuration: number;
  35452. /**
  35453. * Length of the distance animated by the transition when lower radius is reached
  35454. */
  35455. lowerRadiusTransitionRange: number;
  35456. /**
  35457. * Length of the distance animated by the transition when upper radius is reached
  35458. */
  35459. upperRadiusTransitionRange: number;
  35460. private _autoTransitionRange;
  35461. /**
  35462. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35463. */
  35464. /**
  35465. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35466. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35467. */
  35468. autoTransitionRange: boolean;
  35469. private _attachedCamera;
  35470. private _onAfterCheckInputsObserver;
  35471. private _onMeshTargetChangedObserver;
  35472. /**
  35473. * Initializes the behavior.
  35474. */
  35475. init(): void;
  35476. /**
  35477. * Attaches the behavior to its arc rotate camera.
  35478. * @param camera Defines the camera to attach the behavior to
  35479. */
  35480. attach(camera: ArcRotateCamera): void;
  35481. /**
  35482. * Detaches the behavior from its current arc rotate camera.
  35483. */
  35484. detach(): void;
  35485. private _radiusIsAnimating;
  35486. private _radiusBounceTransition;
  35487. private _animatables;
  35488. private _cachedWheelPrecision;
  35489. /**
  35490. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35491. * @param radiusLimit The limit to check against.
  35492. * @return Bool to indicate if at limit.
  35493. */
  35494. private _isRadiusAtLimit;
  35495. /**
  35496. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35497. * @param radiusDelta The delta by which to animate to. Can be negative.
  35498. */
  35499. private _applyBoundRadiusAnimation;
  35500. /**
  35501. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35502. */
  35503. protected _clearAnimationLocks(): void;
  35504. /**
  35505. * Stops and removes all animations that have been applied to the camera
  35506. */
  35507. stopAllAnimations(): void;
  35508. }
  35509. }
  35510. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35511. import { Behavior } from "babylonjs/Behaviors/behavior";
  35512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35513. import { ExponentialEase } from "babylonjs/Animations/easing";
  35514. import { Nullable } from "babylonjs/types";
  35515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35516. import { Vector3 } from "babylonjs/Maths/math";
  35517. /**
  35518. * 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.
  35519. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35520. */
  35521. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35522. /**
  35523. * Gets the name of the behavior.
  35524. */
  35525. readonly name: string;
  35526. private _mode;
  35527. private _radiusScale;
  35528. private _positionScale;
  35529. private _defaultElevation;
  35530. private _elevationReturnTime;
  35531. private _elevationReturnWaitTime;
  35532. private _zoomStopsAnimation;
  35533. private _framingTime;
  35534. /**
  35535. * The easing function used by animations
  35536. */
  35537. static EasingFunction: ExponentialEase;
  35538. /**
  35539. * The easing mode used by animations
  35540. */
  35541. static EasingMode: number;
  35542. /**
  35543. * Sets the current mode used by the behavior
  35544. */
  35545. /**
  35546. * Gets current mode used by the behavior.
  35547. */
  35548. mode: number;
  35549. /**
  35550. * Sets the scale applied to the radius (1 by default)
  35551. */
  35552. /**
  35553. * Gets the scale applied to the radius
  35554. */
  35555. radiusScale: number;
  35556. /**
  35557. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35558. */
  35559. /**
  35560. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35561. */
  35562. positionScale: number;
  35563. /**
  35564. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35565. * behaviour is triggered, in radians.
  35566. */
  35567. /**
  35568. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35569. * behaviour is triggered, in radians.
  35570. */
  35571. defaultElevation: number;
  35572. /**
  35573. * Sets the time (in milliseconds) taken to return to the default beta position.
  35574. * Negative value indicates camera should not return to default.
  35575. */
  35576. /**
  35577. * Gets the time (in milliseconds) taken to return to the default beta position.
  35578. * Negative value indicates camera should not return to default.
  35579. */
  35580. elevationReturnTime: number;
  35581. /**
  35582. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35583. */
  35584. /**
  35585. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35586. */
  35587. elevationReturnWaitTime: number;
  35588. /**
  35589. * Sets the flag that indicates if user zooming should stop animation.
  35590. */
  35591. /**
  35592. * Gets the flag that indicates if user zooming should stop animation.
  35593. */
  35594. zoomStopsAnimation: boolean;
  35595. /**
  35596. * Sets the transition time when framing the mesh, in milliseconds
  35597. */
  35598. /**
  35599. * Gets the transition time when framing the mesh, in milliseconds
  35600. */
  35601. framingTime: number;
  35602. /**
  35603. * Define if the behavior should automatically change the configured
  35604. * camera limits and sensibilities.
  35605. */
  35606. autoCorrectCameraLimitsAndSensibility: boolean;
  35607. private _onPrePointerObservableObserver;
  35608. private _onAfterCheckInputsObserver;
  35609. private _onMeshTargetChangedObserver;
  35610. private _attachedCamera;
  35611. private _isPointerDown;
  35612. private _lastInteractionTime;
  35613. /**
  35614. * Initializes the behavior.
  35615. */
  35616. init(): void;
  35617. /**
  35618. * Attaches the behavior to its arc rotate camera.
  35619. * @param camera Defines the camera to attach the behavior to
  35620. */
  35621. attach(camera: ArcRotateCamera): void;
  35622. /**
  35623. * Detaches the behavior from its current arc rotate camera.
  35624. */
  35625. detach(): void;
  35626. private _animatables;
  35627. private _betaIsAnimating;
  35628. private _betaTransition;
  35629. private _radiusTransition;
  35630. private _vectorTransition;
  35631. /**
  35632. * Targets the given mesh and updates zoom level accordingly.
  35633. * @param mesh The mesh to target.
  35634. * @param radius Optional. If a cached radius position already exists, overrides default.
  35635. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35636. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35637. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35638. */
  35639. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35640. /**
  35641. * Targets the given mesh with its children and updates zoom level accordingly.
  35642. * @param mesh The mesh to target.
  35643. * @param radius Optional. If a cached radius position already exists, overrides default.
  35644. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35647. */
  35648. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35649. /**
  35650. * Targets the given meshes with their children and updates zoom level accordingly.
  35651. * @param meshes The mesh to target.
  35652. * @param radius Optional. If a cached radius position already exists, overrides default.
  35653. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35654. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35655. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35656. */
  35657. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35658. /**
  35659. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35660. * @param minimumWorld Determines the smaller position of the bounding box extend
  35661. * @param maximumWorld Determines the bigger position of the bounding box extend
  35662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35664. */
  35665. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35666. /**
  35667. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35668. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35669. * frustum width.
  35670. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35671. * to fully enclose the mesh in the viewing frustum.
  35672. */
  35673. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35674. /**
  35675. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35676. * is automatically returned to its default position (expected to be above ground plane).
  35677. */
  35678. private _maintainCameraAboveGround;
  35679. /**
  35680. * Returns the frustum slope based on the canvas ratio and camera FOV
  35681. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35682. */
  35683. private _getFrustumSlope;
  35684. /**
  35685. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35686. */
  35687. private _clearAnimationLocks;
  35688. /**
  35689. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35690. */
  35691. private _applyUserInteraction;
  35692. /**
  35693. * Stops and removes all animations that have been applied to the camera
  35694. */
  35695. stopAllAnimations(): void;
  35696. /**
  35697. * Gets a value indicating if the user is moving the camera
  35698. */
  35699. readonly isUserIsMoving: boolean;
  35700. /**
  35701. * The camera can move all the way towards the mesh.
  35702. */
  35703. static IgnoreBoundsSizeMode: number;
  35704. /**
  35705. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35706. */
  35707. static FitFrustumSidesMode: number;
  35708. }
  35709. }
  35710. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35711. import { Nullable } from "babylonjs/types";
  35712. import { Camera } from "babylonjs/Cameras/camera";
  35713. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35714. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35715. /**
  35716. * Base class for Camera Pointer Inputs.
  35717. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35718. * for example usage.
  35719. */
  35720. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35721. /**
  35722. * Defines the camera the input is attached to.
  35723. */
  35724. abstract camera: Camera;
  35725. /**
  35726. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35727. */
  35728. protected _altKey: boolean;
  35729. protected _ctrlKey: boolean;
  35730. protected _metaKey: boolean;
  35731. protected _shiftKey: boolean;
  35732. /**
  35733. * Which mouse buttons were pressed at time of last mouse event.
  35734. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35735. */
  35736. protected _buttonsPressed: number;
  35737. /**
  35738. * Defines the buttons associated with the input to handle camera move.
  35739. */
  35740. buttons: number[];
  35741. /**
  35742. * Attach the input controls to a specific dom element to get the input from.
  35743. * @param element Defines the element the controls should be listened from
  35744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35745. */
  35746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35747. /**
  35748. * Detach the current controls from the specified dom element.
  35749. * @param element Defines the element to stop listening the inputs from
  35750. */
  35751. detachControl(element: Nullable<HTMLElement>): void;
  35752. /**
  35753. * Gets the class name of the current input.
  35754. * @returns the class name
  35755. */
  35756. getClassName(): string;
  35757. /**
  35758. * Get the friendly name associated with the input class.
  35759. * @returns the input friendly name
  35760. */
  35761. getSimpleName(): string;
  35762. /**
  35763. * Called on pointer POINTERDOUBLETAP event.
  35764. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35765. */
  35766. protected onDoubleTap(type: string): void;
  35767. /**
  35768. * Called on pointer POINTERMOVE event if only a single touch is active.
  35769. * Override this method to provide functionality.
  35770. */
  35771. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35772. /**
  35773. * Called on pointer POINTERMOVE event if multiple touches are active.
  35774. * Override this method to provide functionality.
  35775. */
  35776. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35777. /**
  35778. * Called on JS contextmenu event.
  35779. * Override this method to provide functionality.
  35780. */
  35781. protected onContextMenu(evt: PointerEvent): void;
  35782. /**
  35783. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35784. * press.
  35785. * Override this method to provide functionality.
  35786. */
  35787. protected onButtonDown(evt: PointerEvent): void;
  35788. /**
  35789. * Called each time a new POINTERUP event occurs. Ie, for each button
  35790. * release.
  35791. * Override this method to provide functionality.
  35792. */
  35793. protected onButtonUp(evt: PointerEvent): void;
  35794. /**
  35795. * Called when window becomes inactive.
  35796. * Override this method to provide functionality.
  35797. */
  35798. protected onLostFocus(): void;
  35799. private _pointerInput;
  35800. private _observer;
  35801. private _onLostFocus;
  35802. private pointA;
  35803. private pointB;
  35804. }
  35805. }
  35806. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35807. import { Nullable } from "babylonjs/types";
  35808. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35809. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35810. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35811. /**
  35812. * Manage the pointers inputs to control an arc rotate camera.
  35813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35814. */
  35815. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35816. /**
  35817. * Defines the camera the input is attached to.
  35818. */
  35819. camera: ArcRotateCamera;
  35820. /**
  35821. * Gets the class name of the current input.
  35822. * @returns the class name
  35823. */
  35824. getClassName(): string;
  35825. /**
  35826. * Defines the buttons associated with the input to handle camera move.
  35827. */
  35828. buttons: number[];
  35829. /**
  35830. * Defines the pointer angular sensibility along the X axis or how fast is
  35831. * the camera rotating.
  35832. */
  35833. angularSensibilityX: number;
  35834. /**
  35835. * Defines the pointer angular sensibility along the Y axis or how fast is
  35836. * the camera rotating.
  35837. */
  35838. angularSensibilityY: number;
  35839. /**
  35840. * Defines the pointer pinch precision or how fast is the camera zooming.
  35841. */
  35842. pinchPrecision: number;
  35843. /**
  35844. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35845. * from 0.
  35846. * It defines the percentage of current camera.radius to use as delta when
  35847. * pinch zoom is used.
  35848. */
  35849. pinchDeltaPercentage: number;
  35850. /**
  35851. * Defines the pointer panning sensibility or how fast is the camera moving.
  35852. */
  35853. panningSensibility: number;
  35854. /**
  35855. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35856. */
  35857. multiTouchPanning: boolean;
  35858. /**
  35859. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35860. * zoom (pinch) through multitouch.
  35861. */
  35862. multiTouchPanAndZoom: boolean;
  35863. /**
  35864. * Revers pinch action direction.
  35865. */
  35866. pinchInwards: boolean;
  35867. private _isPanClick;
  35868. private _twoFingerActivityCount;
  35869. private _isPinching;
  35870. /**
  35871. * Called on pointer POINTERMOVE event if only a single touch is active.
  35872. */
  35873. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35874. /**
  35875. * Called on pointer POINTERDOUBLETAP event.
  35876. */
  35877. protected onDoubleTap(type: string): void;
  35878. /**
  35879. * Called on pointer POINTERMOVE event if multiple touches are active.
  35880. */
  35881. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35882. /**
  35883. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35884. * press.
  35885. */
  35886. protected onButtonDown(evt: PointerEvent): void;
  35887. /**
  35888. * Called each time a new POINTERUP event occurs. Ie, for each button
  35889. * release.
  35890. */
  35891. protected onButtonUp(evt: PointerEvent): void;
  35892. /**
  35893. * Called when window becomes inactive.
  35894. */
  35895. protected onLostFocus(): void;
  35896. }
  35897. }
  35898. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35899. import { Nullable } from "babylonjs/types";
  35900. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35901. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35902. /**
  35903. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35905. */
  35906. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35907. /**
  35908. * Defines the camera the input is attached to.
  35909. */
  35910. camera: ArcRotateCamera;
  35911. /**
  35912. * Defines the list of key codes associated with the up action (increase alpha)
  35913. */
  35914. keysUp: number[];
  35915. /**
  35916. * Defines the list of key codes associated with the down action (decrease alpha)
  35917. */
  35918. keysDown: number[];
  35919. /**
  35920. * Defines the list of key codes associated with the left action (increase beta)
  35921. */
  35922. keysLeft: number[];
  35923. /**
  35924. * Defines the list of key codes associated with the right action (decrease beta)
  35925. */
  35926. keysRight: number[];
  35927. /**
  35928. * Defines the list of key codes associated with the reset action.
  35929. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35930. */
  35931. keysReset: number[];
  35932. /**
  35933. * Defines the panning sensibility of the inputs.
  35934. * (How fast is the camera paning)
  35935. */
  35936. panningSensibility: number;
  35937. /**
  35938. * Defines the zooming sensibility of the inputs.
  35939. * (How fast is the camera zooming)
  35940. */
  35941. zoomingSensibility: number;
  35942. /**
  35943. * Defines wether maintaining the alt key down switch the movement mode from
  35944. * orientation to zoom.
  35945. */
  35946. useAltToZoom: boolean;
  35947. /**
  35948. * Rotation speed of the camera
  35949. */
  35950. angularSpeed: number;
  35951. private _keys;
  35952. private _ctrlPressed;
  35953. private _altPressed;
  35954. private _onCanvasBlurObserver;
  35955. private _onKeyboardObserver;
  35956. private _engine;
  35957. private _scene;
  35958. /**
  35959. * Attach the input controls to a specific dom element to get the input from.
  35960. * @param element Defines the element the controls should be listened from
  35961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35962. */
  35963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35964. /**
  35965. * Detach the current controls from the specified dom element.
  35966. * @param element Defines the element to stop listening the inputs from
  35967. */
  35968. detachControl(element: Nullable<HTMLElement>): void;
  35969. /**
  35970. * Update the current camera state depending on the inputs that have been used this frame.
  35971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35972. */
  35973. checkInputs(): void;
  35974. /**
  35975. * Gets the class name of the current intput.
  35976. * @returns the class name
  35977. */
  35978. getClassName(): string;
  35979. /**
  35980. * Get the friendly name associated with the input class.
  35981. * @returns the input friendly name
  35982. */
  35983. getSimpleName(): string;
  35984. }
  35985. }
  35986. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35987. import { Nullable } from "babylonjs/types";
  35988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35990. /**
  35991. * Manage the mouse wheel inputs to control an arc rotate camera.
  35992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35993. */
  35994. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35995. /**
  35996. * Defines the camera the input is attached to.
  35997. */
  35998. camera: ArcRotateCamera;
  35999. /**
  36000. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36001. */
  36002. wheelPrecision: number;
  36003. /**
  36004. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36005. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36006. */
  36007. wheelDeltaPercentage: number;
  36008. private _wheel;
  36009. private _observer;
  36010. /**
  36011. * Attach the input controls to a specific dom element to get the input from.
  36012. * @param element Defines the element the controls should be listened from
  36013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36014. */
  36015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36016. /**
  36017. * Detach the current controls from the specified dom element.
  36018. * @param element Defines the element to stop listening the inputs from
  36019. */
  36020. detachControl(element: Nullable<HTMLElement>): void;
  36021. /**
  36022. * Gets the class name of the current intput.
  36023. * @returns the class name
  36024. */
  36025. getClassName(): string;
  36026. /**
  36027. * Get the friendly name associated with the input class.
  36028. * @returns the input friendly name
  36029. */
  36030. getSimpleName(): string;
  36031. }
  36032. }
  36033. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36034. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36035. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36036. /**
  36037. * Default Inputs manager for the ArcRotateCamera.
  36038. * It groups all the default supported inputs for ease of use.
  36039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36040. */
  36041. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36042. /**
  36043. * Instantiates a new ArcRotateCameraInputsManager.
  36044. * @param camera Defines the camera the inputs belong to
  36045. */
  36046. constructor(camera: ArcRotateCamera);
  36047. /**
  36048. * Add mouse wheel input support to the input manager.
  36049. * @returns the current input manager
  36050. */
  36051. addMouseWheel(): ArcRotateCameraInputsManager;
  36052. /**
  36053. * Add pointers input support to the input manager.
  36054. * @returns the current input manager
  36055. */
  36056. addPointers(): ArcRotateCameraInputsManager;
  36057. /**
  36058. * Add keyboard input support to the input manager.
  36059. * @returns the current input manager
  36060. */
  36061. addKeyboard(): ArcRotateCameraInputsManager;
  36062. }
  36063. }
  36064. declare module "babylonjs/Cameras/arcRotateCamera" {
  36065. import { Observable } from "babylonjs/Misc/observable";
  36066. import { Nullable } from "babylonjs/types";
  36067. import { Scene } from "babylonjs/scene";
  36068. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36070. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36071. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36072. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36073. import { Camera } from "babylonjs/Cameras/camera";
  36074. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36075. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36076. import { Collider } from "babylonjs/Collisions/collider";
  36077. /**
  36078. * This represents an orbital type of camera.
  36079. *
  36080. * 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.
  36081. * 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.
  36082. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36083. */
  36084. export class ArcRotateCamera extends TargetCamera {
  36085. /**
  36086. * Defines the rotation angle of the camera along the longitudinal axis.
  36087. */
  36088. alpha: number;
  36089. /**
  36090. * Defines the rotation angle of the camera along the latitudinal axis.
  36091. */
  36092. beta: number;
  36093. /**
  36094. * Defines the radius of the camera from it s target point.
  36095. */
  36096. radius: number;
  36097. protected _target: Vector3;
  36098. protected _targetHost: Nullable<AbstractMesh>;
  36099. /**
  36100. * Defines the target point of the camera.
  36101. * The camera looks towards it form the radius distance.
  36102. */
  36103. target: Vector3;
  36104. /**
  36105. * Define the current local position of the camera in the scene
  36106. */
  36107. position: Vector3;
  36108. protected _upVector: Vector3;
  36109. protected _upToYMatrix: Matrix;
  36110. protected _YToUpMatrix: Matrix;
  36111. /**
  36112. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36113. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36114. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36115. */
  36116. upVector: Vector3;
  36117. /**
  36118. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36119. */
  36120. setMatUp(): void;
  36121. /**
  36122. * Current inertia value on the longitudinal axis.
  36123. * The bigger this number the longer it will take for the camera to stop.
  36124. */
  36125. inertialAlphaOffset: number;
  36126. /**
  36127. * Current inertia value on the latitudinal axis.
  36128. * The bigger this number the longer it will take for the camera to stop.
  36129. */
  36130. inertialBetaOffset: number;
  36131. /**
  36132. * Current inertia value on the radius axis.
  36133. * The bigger this number the longer it will take for the camera to stop.
  36134. */
  36135. inertialRadiusOffset: number;
  36136. /**
  36137. * Minimum allowed angle on the longitudinal axis.
  36138. * This can help limiting how the Camera is able to move in the scene.
  36139. */
  36140. lowerAlphaLimit: Nullable<number>;
  36141. /**
  36142. * Maximum allowed angle on the longitudinal axis.
  36143. * This can help limiting how the Camera is able to move in the scene.
  36144. */
  36145. upperAlphaLimit: Nullable<number>;
  36146. /**
  36147. * Minimum allowed angle on the latitudinal axis.
  36148. * This can help limiting how the Camera is able to move in the scene.
  36149. */
  36150. lowerBetaLimit: number;
  36151. /**
  36152. * Maximum allowed angle on the latitudinal axis.
  36153. * This can help limiting how the Camera is able to move in the scene.
  36154. */
  36155. upperBetaLimit: number;
  36156. /**
  36157. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36158. * This can help limiting how the Camera is able to move in the scene.
  36159. */
  36160. lowerRadiusLimit: Nullable<number>;
  36161. /**
  36162. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36163. * This can help limiting how the Camera is able to move in the scene.
  36164. */
  36165. upperRadiusLimit: Nullable<number>;
  36166. /**
  36167. * Defines the current inertia value used during panning of the camera along the X axis.
  36168. */
  36169. inertialPanningX: number;
  36170. /**
  36171. * Defines the current inertia value used during panning of the camera along the Y axis.
  36172. */
  36173. inertialPanningY: number;
  36174. /**
  36175. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36176. * Basically if your fingers moves away from more than this distance you will be considered
  36177. * in pinch mode.
  36178. */
  36179. pinchToPanMaxDistance: number;
  36180. /**
  36181. * Defines the maximum distance the camera can pan.
  36182. * This could help keeping the cammera always in your scene.
  36183. */
  36184. panningDistanceLimit: Nullable<number>;
  36185. /**
  36186. * Defines the target of the camera before paning.
  36187. */
  36188. panningOriginTarget: Vector3;
  36189. /**
  36190. * Defines the value of the inertia used during panning.
  36191. * 0 would mean stop inertia and one would mean no decelleration at all.
  36192. */
  36193. panningInertia: number;
  36194. /**
  36195. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36196. */
  36197. angularSensibilityX: number;
  36198. /**
  36199. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36200. */
  36201. angularSensibilityY: number;
  36202. /**
  36203. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36204. */
  36205. pinchPrecision: number;
  36206. /**
  36207. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36208. * It will be used instead of pinchDeltaPrecision if different from 0.
  36209. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36210. */
  36211. pinchDeltaPercentage: number;
  36212. /**
  36213. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36214. */
  36215. panningSensibility: number;
  36216. /**
  36217. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36218. */
  36219. keysUp: number[];
  36220. /**
  36221. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36222. */
  36223. keysDown: number[];
  36224. /**
  36225. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36226. */
  36227. keysLeft: number[];
  36228. /**
  36229. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36230. */
  36231. keysRight: number[];
  36232. /**
  36233. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36234. */
  36235. wheelPrecision: number;
  36236. /**
  36237. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36238. * It will be used instead of pinchDeltaPrecision if different from 0.
  36239. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36240. */
  36241. wheelDeltaPercentage: number;
  36242. /**
  36243. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36244. */
  36245. zoomOnFactor: number;
  36246. /**
  36247. * Defines a screen offset for the camera position.
  36248. */
  36249. targetScreenOffset: Vector2;
  36250. /**
  36251. * Allows the camera to be completely reversed.
  36252. * If false the camera can not arrive upside down.
  36253. */
  36254. allowUpsideDown: boolean;
  36255. /**
  36256. * Define if double tap/click is used to restore the previously saved state of the camera.
  36257. */
  36258. useInputToRestoreState: boolean;
  36259. /** @hidden */
  36260. _viewMatrix: Matrix;
  36261. /** @hidden */
  36262. _useCtrlForPanning: boolean;
  36263. /** @hidden */
  36264. _panningMouseButton: number;
  36265. /**
  36266. * Defines the input associated to the camera.
  36267. */
  36268. inputs: ArcRotateCameraInputsManager;
  36269. /** @hidden */
  36270. _reset: () => void;
  36271. /**
  36272. * Defines the allowed panning axis.
  36273. */
  36274. panningAxis: Vector3;
  36275. protected _localDirection: Vector3;
  36276. protected _transformedDirection: Vector3;
  36277. private _bouncingBehavior;
  36278. /**
  36279. * Gets the bouncing behavior of the camera if it has been enabled.
  36280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36281. */
  36282. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36283. /**
  36284. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36286. */
  36287. useBouncingBehavior: boolean;
  36288. private _framingBehavior;
  36289. /**
  36290. * Gets the framing behavior of the camera if it has been enabled.
  36291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36292. */
  36293. readonly framingBehavior: Nullable<FramingBehavior>;
  36294. /**
  36295. * Defines if the framing behavior of the camera is enabled on the camera.
  36296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36297. */
  36298. useFramingBehavior: boolean;
  36299. private _autoRotationBehavior;
  36300. /**
  36301. * Gets the auto rotation behavior of the camera if it has been enabled.
  36302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36303. */
  36304. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36305. /**
  36306. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36308. */
  36309. useAutoRotationBehavior: boolean;
  36310. /**
  36311. * Observable triggered when the mesh target has been changed on the camera.
  36312. */
  36313. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36314. /**
  36315. * Event raised when the camera is colliding with a mesh.
  36316. */
  36317. onCollide: (collidedMesh: AbstractMesh) => void;
  36318. /**
  36319. * Defines whether the camera should check collision with the objects oh the scene.
  36320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36321. */
  36322. checkCollisions: boolean;
  36323. /**
  36324. * Defines the collision radius of the camera.
  36325. * This simulates a sphere around the camera.
  36326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36327. */
  36328. collisionRadius: Vector3;
  36329. protected _collider: Collider;
  36330. protected _previousPosition: Vector3;
  36331. protected _collisionVelocity: Vector3;
  36332. protected _newPosition: Vector3;
  36333. protected _previousAlpha: number;
  36334. protected _previousBeta: number;
  36335. protected _previousRadius: number;
  36336. protected _collisionTriggered: boolean;
  36337. protected _targetBoundingCenter: Nullable<Vector3>;
  36338. private _computationVector;
  36339. /**
  36340. * Instantiates a new ArcRotateCamera in a given scene
  36341. * @param name Defines the name of the camera
  36342. * @param alpha Defines the camera rotation along the logitudinal axis
  36343. * @param beta Defines the camera rotation along the latitudinal axis
  36344. * @param radius Defines the camera distance from its target
  36345. * @param target Defines the camera target
  36346. * @param scene Defines the scene the camera belongs to
  36347. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36348. */
  36349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36350. /** @hidden */
  36351. _initCache(): void;
  36352. /** @hidden */
  36353. _updateCache(ignoreParentClass?: boolean): void;
  36354. protected _getTargetPosition(): Vector3;
  36355. private _storedAlpha;
  36356. private _storedBeta;
  36357. private _storedRadius;
  36358. private _storedTarget;
  36359. /**
  36360. * Stores the current state of the camera (alpha, beta, radius and target)
  36361. * @returns the camera itself
  36362. */
  36363. storeState(): Camera;
  36364. /**
  36365. * @hidden
  36366. * Restored camera state. You must call storeState() first
  36367. */
  36368. _restoreStateValues(): boolean;
  36369. /** @hidden */
  36370. _isSynchronizedViewMatrix(): boolean;
  36371. /**
  36372. * Attached controls to the current camera.
  36373. * @param element Defines the element the controls should be listened from
  36374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36375. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36376. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36377. */
  36378. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36379. /**
  36380. * Detach the current controls from the camera.
  36381. * The camera will stop reacting to inputs.
  36382. * @param element Defines the element to stop listening the inputs from
  36383. */
  36384. detachControl(element: HTMLElement): void;
  36385. /** @hidden */
  36386. _checkInputs(): void;
  36387. protected _checkLimits(): void;
  36388. /**
  36389. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36390. */
  36391. rebuildAnglesAndRadius(): void;
  36392. /**
  36393. * Use a position to define the current camera related information like aplha, beta and radius
  36394. * @param position Defines the position to set the camera at
  36395. */
  36396. setPosition(position: Vector3): void;
  36397. /**
  36398. * Defines the target the camera should look at.
  36399. * This will automatically adapt alpha beta and radius to fit within the new target.
  36400. * @param target Defines the new target as a Vector or a mesh
  36401. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36402. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36403. */
  36404. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36405. /** @hidden */
  36406. _getViewMatrix(): Matrix;
  36407. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36408. /**
  36409. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36410. * @param meshes Defines the mesh to zoom on
  36411. * @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)
  36412. */
  36413. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36414. /**
  36415. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36416. * The target will be changed but the radius
  36417. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36418. * @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)
  36419. */
  36420. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36421. min: Vector3;
  36422. max: Vector3;
  36423. distance: number;
  36424. }, doNotUpdateMaxZ?: boolean): void;
  36425. /**
  36426. * @override
  36427. * Override Camera.createRigCamera
  36428. */
  36429. createRigCamera(name: string, cameraIndex: number): Camera;
  36430. /**
  36431. * @hidden
  36432. * @override
  36433. * Override Camera._updateRigCameras
  36434. */
  36435. _updateRigCameras(): void;
  36436. /**
  36437. * Destroy the camera and release the current resources hold by it.
  36438. */
  36439. dispose(): void;
  36440. /**
  36441. * Gets the current object class name.
  36442. * @return the class name
  36443. */
  36444. getClassName(): string;
  36445. }
  36446. }
  36447. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36448. import { Behavior } from "babylonjs/Behaviors/behavior";
  36449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36450. /**
  36451. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36452. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36453. */
  36454. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36455. /**
  36456. * Gets the name of the behavior.
  36457. */
  36458. readonly name: string;
  36459. private _zoomStopsAnimation;
  36460. private _idleRotationSpeed;
  36461. private _idleRotationWaitTime;
  36462. private _idleRotationSpinupTime;
  36463. /**
  36464. * Sets the flag that indicates if user zooming should stop animation.
  36465. */
  36466. /**
  36467. * Gets the flag that indicates if user zooming should stop animation.
  36468. */
  36469. zoomStopsAnimation: boolean;
  36470. /**
  36471. * Sets the default speed at which the camera rotates around the model.
  36472. */
  36473. /**
  36474. * Gets the default speed at which the camera rotates around the model.
  36475. */
  36476. idleRotationSpeed: number;
  36477. /**
  36478. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36479. */
  36480. /**
  36481. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36482. */
  36483. idleRotationWaitTime: number;
  36484. /**
  36485. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36486. */
  36487. /**
  36488. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36489. */
  36490. idleRotationSpinupTime: number;
  36491. /**
  36492. * Gets a value indicating if the camera is currently rotating because of this behavior
  36493. */
  36494. readonly rotationInProgress: boolean;
  36495. private _onPrePointerObservableObserver;
  36496. private _onAfterCheckInputsObserver;
  36497. private _attachedCamera;
  36498. private _isPointerDown;
  36499. private _lastFrameTime;
  36500. private _lastInteractionTime;
  36501. private _cameraRotationSpeed;
  36502. /**
  36503. * Initializes the behavior.
  36504. */
  36505. init(): void;
  36506. /**
  36507. * Attaches the behavior to its arc rotate camera.
  36508. * @param camera Defines the camera to attach the behavior to
  36509. */
  36510. attach(camera: ArcRotateCamera): void;
  36511. /**
  36512. * Detaches the behavior from its current arc rotate camera.
  36513. */
  36514. detach(): void;
  36515. /**
  36516. * Returns true if user is scrolling.
  36517. * @return true if user is scrolling.
  36518. */
  36519. private _userIsZooming;
  36520. private _lastFrameRadius;
  36521. private _shouldAnimationStopForInteraction;
  36522. /**
  36523. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36524. */
  36525. private _applyUserInteraction;
  36526. private _userIsMoving;
  36527. }
  36528. }
  36529. declare module "babylonjs/Behaviors/Cameras/index" {
  36530. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36531. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36532. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36533. }
  36534. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36535. import { Mesh } from "babylonjs/Meshes/mesh";
  36536. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36537. import { Behavior } from "babylonjs/Behaviors/behavior";
  36538. /**
  36539. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36540. */
  36541. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36542. private ui;
  36543. /**
  36544. * The name of the behavior
  36545. */
  36546. name: string;
  36547. /**
  36548. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36549. */
  36550. distanceAwayFromFace: number;
  36551. /**
  36552. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36553. */
  36554. distanceAwayFromBottomOfFace: number;
  36555. private _faceVectors;
  36556. private _target;
  36557. private _scene;
  36558. private _onRenderObserver;
  36559. private _tmpMatrix;
  36560. private _tmpVector;
  36561. /**
  36562. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36563. * @param ui The transform node that should be attched to the mesh
  36564. */
  36565. constructor(ui: TransformNode);
  36566. /**
  36567. * Initializes the behavior
  36568. */
  36569. init(): void;
  36570. private _closestFace;
  36571. private _zeroVector;
  36572. private _lookAtTmpMatrix;
  36573. private _lookAtToRef;
  36574. /**
  36575. * Attaches the AttachToBoxBehavior to the passed in mesh
  36576. * @param target The mesh that the specified node will be attached to
  36577. */
  36578. attach(target: Mesh): void;
  36579. /**
  36580. * Detaches the behavior from the mesh
  36581. */
  36582. detach(): void;
  36583. }
  36584. }
  36585. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36586. import { Behavior } from "babylonjs/Behaviors/behavior";
  36587. import { Mesh } from "babylonjs/Meshes/mesh";
  36588. /**
  36589. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36590. */
  36591. export class FadeInOutBehavior implements Behavior<Mesh> {
  36592. /**
  36593. * Time in milliseconds to delay before fading in (Default: 0)
  36594. */
  36595. delay: number;
  36596. /**
  36597. * Time in milliseconds for the mesh to fade in (Default: 300)
  36598. */
  36599. fadeInTime: number;
  36600. private _millisecondsPerFrame;
  36601. private _hovered;
  36602. private _hoverValue;
  36603. private _ownerNode;
  36604. /**
  36605. * Instatiates the FadeInOutBehavior
  36606. */
  36607. constructor();
  36608. /**
  36609. * The name of the behavior
  36610. */
  36611. readonly name: string;
  36612. /**
  36613. * Initializes the behavior
  36614. */
  36615. init(): void;
  36616. /**
  36617. * Attaches the fade behavior on the passed in mesh
  36618. * @param ownerNode The mesh that will be faded in/out once attached
  36619. */
  36620. attach(ownerNode: Mesh): void;
  36621. /**
  36622. * Detaches the behavior from the mesh
  36623. */
  36624. detach(): void;
  36625. /**
  36626. * Triggers the mesh to begin fading in or out
  36627. * @param value if the object should fade in or out (true to fade in)
  36628. */
  36629. fadeIn(value: boolean): void;
  36630. private _update;
  36631. private _setAllVisibility;
  36632. }
  36633. }
  36634. declare module "babylonjs/Misc/pivotTools" {
  36635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36636. /**
  36637. * Class containing a set of static utilities functions for managing Pivots
  36638. * @hidden
  36639. */
  36640. export class PivotTools {
  36641. private static _PivotCached;
  36642. private static _OldPivotPoint;
  36643. private static _PivotTranslation;
  36644. private static _PivotTmpVector;
  36645. /** @hidden */
  36646. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36647. /** @hidden */
  36648. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36649. }
  36650. }
  36651. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36652. import { Scene } from "babylonjs/scene";
  36653. import { Vector4, Plane } from "babylonjs/Maths/math";
  36654. import { Mesh } from "babylonjs/Meshes/mesh";
  36655. import { Nullable } from "babylonjs/types";
  36656. /**
  36657. * Class containing static functions to help procedurally build meshes
  36658. */
  36659. export class PlaneBuilder {
  36660. /**
  36661. * Creates a plane mesh
  36662. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36663. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36664. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36668. * @param name defines the name of the mesh
  36669. * @param options defines the options used to create the mesh
  36670. * @param scene defines the hosting scene
  36671. * @returns the plane mesh
  36672. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36673. */
  36674. static CreatePlane(name: string, options: {
  36675. size?: number;
  36676. width?: number;
  36677. height?: number;
  36678. sideOrientation?: number;
  36679. frontUVs?: Vector4;
  36680. backUVs?: Vector4;
  36681. updatable?: boolean;
  36682. sourcePlane?: Plane;
  36683. }, scene?: Nullable<Scene>): Mesh;
  36684. }
  36685. }
  36686. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36687. import { Behavior } from "babylonjs/Behaviors/behavior";
  36688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36689. import { Observable } from "babylonjs/Misc/observable";
  36690. import { Vector3 } from "babylonjs/Maths/math";
  36691. import { Ray } from "babylonjs/Culling/ray";
  36692. import "babylonjs/Meshes/Builders/planeBuilder";
  36693. /**
  36694. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36695. */
  36696. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36697. private static _AnyMouseID;
  36698. private _attachedNode;
  36699. private _dragPlane;
  36700. private _scene;
  36701. private _pointerObserver;
  36702. private _beforeRenderObserver;
  36703. private static _planeScene;
  36704. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36705. /**
  36706. * 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)
  36707. */
  36708. maxDragAngle: number;
  36709. /**
  36710. * @hidden
  36711. */
  36712. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36713. /**
  36714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36715. */
  36716. currentDraggingPointerID: number;
  36717. /**
  36718. * The last position where the pointer hit the drag plane in world space
  36719. */
  36720. lastDragPosition: Vector3;
  36721. /**
  36722. * If the behavior is currently in a dragging state
  36723. */
  36724. dragging: boolean;
  36725. /**
  36726. * 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)
  36727. */
  36728. dragDeltaRatio: number;
  36729. /**
  36730. * If the drag plane orientation should be updated during the dragging (Default: true)
  36731. */
  36732. updateDragPlane: boolean;
  36733. private _debugMode;
  36734. private _moving;
  36735. /**
  36736. * Fires each time the attached mesh is dragged with the pointer
  36737. * * delta between last drag position and current drag position in world space
  36738. * * dragDistance along the drag axis
  36739. * * dragPlaneNormal normal of the current drag plane used during the drag
  36740. * * dragPlanePoint in world space where the drag intersects the drag plane
  36741. */
  36742. onDragObservable: Observable<{
  36743. delta: Vector3;
  36744. dragPlanePoint: Vector3;
  36745. dragPlaneNormal: Vector3;
  36746. dragDistance: number;
  36747. pointerId: number;
  36748. }>;
  36749. /**
  36750. * Fires each time a drag begins (eg. mouse down on mesh)
  36751. */
  36752. onDragStartObservable: Observable<{
  36753. dragPlanePoint: Vector3;
  36754. pointerId: number;
  36755. }>;
  36756. /**
  36757. * Fires each time a drag ends (eg. mouse release after drag)
  36758. */
  36759. onDragEndObservable: Observable<{
  36760. dragPlanePoint: Vector3;
  36761. pointerId: number;
  36762. }>;
  36763. /**
  36764. * If the attached mesh should be moved when dragged
  36765. */
  36766. moveAttached: boolean;
  36767. /**
  36768. * If the drag behavior will react to drag events (Default: true)
  36769. */
  36770. enabled: boolean;
  36771. /**
  36772. * If camera controls should be detached during the drag
  36773. */
  36774. detachCameraControls: boolean;
  36775. /**
  36776. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36777. */
  36778. useObjectOrienationForDragging: boolean;
  36779. private _options;
  36780. /**
  36781. * Creates a pointer drag behavior that can be attached to a mesh
  36782. * @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)
  36783. */
  36784. constructor(options?: {
  36785. dragAxis?: Vector3;
  36786. dragPlaneNormal?: Vector3;
  36787. });
  36788. /**
  36789. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36790. */
  36791. validateDrag: (targetPosition: Vector3) => boolean;
  36792. /**
  36793. * The name of the behavior
  36794. */
  36795. readonly name: string;
  36796. /**
  36797. * Initializes the behavior
  36798. */
  36799. init(): void;
  36800. private _tmpVector;
  36801. private _alternatePickedPoint;
  36802. private _worldDragAxis;
  36803. private _targetPosition;
  36804. private _attachedElement;
  36805. /**
  36806. * Attaches the drag behavior the passed in mesh
  36807. * @param ownerNode The mesh that will be dragged around once attached
  36808. */
  36809. attach(ownerNode: AbstractMesh): void;
  36810. /**
  36811. * Force relase the drag action by code.
  36812. */
  36813. releaseDrag(): void;
  36814. private _startDragRay;
  36815. private _lastPointerRay;
  36816. /**
  36817. * Simulates the start of a pointer drag event on the behavior
  36818. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36819. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36820. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36821. */
  36822. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36823. private _startDrag;
  36824. private _dragDelta;
  36825. private _moveDrag;
  36826. private _pickWithRayOnDragPlane;
  36827. private _pointA;
  36828. private _pointB;
  36829. private _pointC;
  36830. private _lineA;
  36831. private _lineB;
  36832. private _localAxis;
  36833. private _lookAt;
  36834. private _updateDragPlanePosition;
  36835. /**
  36836. * Detaches the behavior from the mesh
  36837. */
  36838. detach(): void;
  36839. }
  36840. }
  36841. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36842. import { Mesh } from "babylonjs/Meshes/mesh";
  36843. import { Behavior } from "babylonjs/Behaviors/behavior";
  36844. /**
  36845. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36846. */
  36847. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36848. private _dragBehaviorA;
  36849. private _dragBehaviorB;
  36850. private _startDistance;
  36851. private _initialScale;
  36852. private _targetScale;
  36853. private _ownerNode;
  36854. private _sceneRenderObserver;
  36855. /**
  36856. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36857. */
  36858. constructor();
  36859. /**
  36860. * The name of the behavior
  36861. */
  36862. readonly name: string;
  36863. /**
  36864. * Initializes the behavior
  36865. */
  36866. init(): void;
  36867. private _getCurrentDistance;
  36868. /**
  36869. * Attaches the scale behavior the passed in mesh
  36870. * @param ownerNode The mesh that will be scaled around once attached
  36871. */
  36872. attach(ownerNode: Mesh): void;
  36873. /**
  36874. * Detaches the behavior from the mesh
  36875. */
  36876. detach(): void;
  36877. }
  36878. }
  36879. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36880. import { Behavior } from "babylonjs/Behaviors/behavior";
  36881. import { Mesh } from "babylonjs/Meshes/mesh";
  36882. import { Observable } from "babylonjs/Misc/observable";
  36883. /**
  36884. * 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
  36885. */
  36886. export class SixDofDragBehavior implements Behavior<Mesh> {
  36887. private static _virtualScene;
  36888. private _ownerNode;
  36889. private _sceneRenderObserver;
  36890. private _scene;
  36891. private _targetPosition;
  36892. private _virtualOriginMesh;
  36893. private _virtualDragMesh;
  36894. private _pointerObserver;
  36895. private _moving;
  36896. private _startingOrientation;
  36897. /**
  36898. * 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)
  36899. */
  36900. private zDragFactor;
  36901. /**
  36902. * If the object should rotate to face the drag origin
  36903. */
  36904. rotateDraggedObject: boolean;
  36905. /**
  36906. * If the behavior is currently in a dragging state
  36907. */
  36908. dragging: boolean;
  36909. /**
  36910. * 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)
  36911. */
  36912. dragDeltaRatio: number;
  36913. /**
  36914. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36915. */
  36916. currentDraggingPointerID: number;
  36917. /**
  36918. * If camera controls should be detached during the drag
  36919. */
  36920. detachCameraControls: boolean;
  36921. /**
  36922. * Fires each time a drag starts
  36923. */
  36924. onDragStartObservable: Observable<{}>;
  36925. /**
  36926. * Fires each time a drag ends (eg. mouse release after drag)
  36927. */
  36928. onDragEndObservable: Observable<{}>;
  36929. /**
  36930. * 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
  36931. */
  36932. constructor();
  36933. /**
  36934. * The name of the behavior
  36935. */
  36936. readonly name: string;
  36937. /**
  36938. * Initializes the behavior
  36939. */
  36940. init(): void;
  36941. /**
  36942. * Attaches the scale behavior the passed in mesh
  36943. * @param ownerNode The mesh that will be scaled around once attached
  36944. */
  36945. attach(ownerNode: Mesh): void;
  36946. /**
  36947. * Detaches the behavior from the mesh
  36948. */
  36949. detach(): void;
  36950. }
  36951. }
  36952. declare module "babylonjs/Behaviors/Meshes/index" {
  36953. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36954. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36955. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36956. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36957. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36958. }
  36959. declare module "babylonjs/Behaviors/index" {
  36960. export * from "babylonjs/Behaviors/behavior";
  36961. export * from "babylonjs/Behaviors/Cameras/index";
  36962. export * from "babylonjs/Behaviors/Meshes/index";
  36963. }
  36964. declare module "babylonjs/Bones/boneIKController" {
  36965. import { Bone } from "babylonjs/Bones/bone";
  36966. import { Vector3 } from "babylonjs/Maths/math";
  36967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36968. import { Nullable } from "babylonjs/types";
  36969. /**
  36970. * Class used to apply inverse kinematics to bones
  36971. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36972. */
  36973. export class BoneIKController {
  36974. private static _tmpVecs;
  36975. private static _tmpQuat;
  36976. private static _tmpMats;
  36977. /**
  36978. * Gets or sets the target mesh
  36979. */
  36980. targetMesh: AbstractMesh;
  36981. /** Gets or sets the mesh used as pole */
  36982. poleTargetMesh: AbstractMesh;
  36983. /**
  36984. * Gets or sets the bone used as pole
  36985. */
  36986. poleTargetBone: Nullable<Bone>;
  36987. /**
  36988. * Gets or sets the target position
  36989. */
  36990. targetPosition: Vector3;
  36991. /**
  36992. * Gets or sets the pole target position
  36993. */
  36994. poleTargetPosition: Vector3;
  36995. /**
  36996. * Gets or sets the pole target local offset
  36997. */
  36998. poleTargetLocalOffset: Vector3;
  36999. /**
  37000. * Gets or sets the pole angle
  37001. */
  37002. poleAngle: number;
  37003. /**
  37004. * Gets or sets the mesh associated with the controller
  37005. */
  37006. mesh: AbstractMesh;
  37007. /**
  37008. * 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)
  37009. */
  37010. slerpAmount: number;
  37011. private _bone1Quat;
  37012. private _bone1Mat;
  37013. private _bone2Ang;
  37014. private _bone1;
  37015. private _bone2;
  37016. private _bone1Length;
  37017. private _bone2Length;
  37018. private _maxAngle;
  37019. private _maxReach;
  37020. private _rightHandedSystem;
  37021. private _bendAxis;
  37022. private _slerping;
  37023. private _adjustRoll;
  37024. /**
  37025. * Gets or sets maximum allowed angle
  37026. */
  37027. maxAngle: number;
  37028. /**
  37029. * Creates a new BoneIKController
  37030. * @param mesh defines the mesh to control
  37031. * @param bone defines the bone to control
  37032. * @param options defines options to set up the controller
  37033. */
  37034. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37035. targetMesh?: AbstractMesh;
  37036. poleTargetMesh?: AbstractMesh;
  37037. poleTargetBone?: Bone;
  37038. poleTargetLocalOffset?: Vector3;
  37039. poleAngle?: number;
  37040. bendAxis?: Vector3;
  37041. maxAngle?: number;
  37042. slerpAmount?: number;
  37043. });
  37044. private _setMaxAngle;
  37045. /**
  37046. * Force the controller to update the bones
  37047. */
  37048. update(): void;
  37049. }
  37050. }
  37051. declare module "babylonjs/Bones/boneLookController" {
  37052. import { Vector3, Space } from "babylonjs/Maths/math";
  37053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37054. import { Bone } from "babylonjs/Bones/bone";
  37055. /**
  37056. * Class used to make a bone look toward a point in space
  37057. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37058. */
  37059. export class BoneLookController {
  37060. private static _tmpVecs;
  37061. private static _tmpQuat;
  37062. private static _tmpMats;
  37063. /**
  37064. * The target Vector3 that the bone will look at
  37065. */
  37066. target: Vector3;
  37067. /**
  37068. * The mesh that the bone is attached to
  37069. */
  37070. mesh: AbstractMesh;
  37071. /**
  37072. * The bone that will be looking to the target
  37073. */
  37074. bone: Bone;
  37075. /**
  37076. * The up axis of the coordinate system that is used when the bone is rotated
  37077. */
  37078. upAxis: Vector3;
  37079. /**
  37080. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37081. */
  37082. upAxisSpace: Space;
  37083. /**
  37084. * Used to make an adjustment to the yaw of the bone
  37085. */
  37086. adjustYaw: number;
  37087. /**
  37088. * Used to make an adjustment to the pitch of the bone
  37089. */
  37090. adjustPitch: number;
  37091. /**
  37092. * Used to make an adjustment to the roll of the bone
  37093. */
  37094. adjustRoll: number;
  37095. /**
  37096. * 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)
  37097. */
  37098. slerpAmount: number;
  37099. private _minYaw;
  37100. private _maxYaw;
  37101. private _minPitch;
  37102. private _maxPitch;
  37103. private _minYawSin;
  37104. private _minYawCos;
  37105. private _maxYawSin;
  37106. private _maxYawCos;
  37107. private _midYawConstraint;
  37108. private _minPitchTan;
  37109. private _maxPitchTan;
  37110. private _boneQuat;
  37111. private _slerping;
  37112. private _transformYawPitch;
  37113. private _transformYawPitchInv;
  37114. private _firstFrameSkipped;
  37115. private _yawRange;
  37116. private _fowardAxis;
  37117. /**
  37118. * Gets or sets the minimum yaw angle that the bone can look to
  37119. */
  37120. minYaw: number;
  37121. /**
  37122. * Gets or sets the maximum yaw angle that the bone can look to
  37123. */
  37124. maxYaw: number;
  37125. /**
  37126. * Gets or sets the minimum pitch angle that the bone can look to
  37127. */
  37128. minPitch: number;
  37129. /**
  37130. * Gets or sets the maximum pitch angle that the bone can look to
  37131. */
  37132. maxPitch: number;
  37133. /**
  37134. * Create a BoneLookController
  37135. * @param mesh the mesh that the bone belongs to
  37136. * @param bone the bone that will be looking to the target
  37137. * @param target the target Vector3 to look at
  37138. * @param options optional settings:
  37139. * * maxYaw: the maximum angle the bone will yaw to
  37140. * * minYaw: the minimum angle the bone will yaw to
  37141. * * maxPitch: the maximum angle the bone will pitch to
  37142. * * minPitch: the minimum angle the bone will yaw to
  37143. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37144. * * upAxis: the up axis of the coordinate system
  37145. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37146. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37147. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37148. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37149. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37150. * * adjustRoll: used to make an adjustment to the roll of the bone
  37151. **/
  37152. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37153. maxYaw?: number;
  37154. minYaw?: number;
  37155. maxPitch?: number;
  37156. minPitch?: number;
  37157. slerpAmount?: number;
  37158. upAxis?: Vector3;
  37159. upAxisSpace?: Space;
  37160. yawAxis?: Vector3;
  37161. pitchAxis?: Vector3;
  37162. adjustYaw?: number;
  37163. adjustPitch?: number;
  37164. adjustRoll?: number;
  37165. });
  37166. /**
  37167. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37168. */
  37169. update(): void;
  37170. private _getAngleDiff;
  37171. private _getAngleBetween;
  37172. private _isAngleBetween;
  37173. }
  37174. }
  37175. declare module "babylonjs/Bones/index" {
  37176. export * from "babylonjs/Bones/bone";
  37177. export * from "babylonjs/Bones/boneIKController";
  37178. export * from "babylonjs/Bones/boneLookController";
  37179. export * from "babylonjs/Bones/skeleton";
  37180. }
  37181. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37182. import { Nullable } from "babylonjs/types";
  37183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37185. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37186. /**
  37187. * Manage the gamepad inputs to control an arc rotate camera.
  37188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37189. */
  37190. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37191. /**
  37192. * Defines the camera the input is attached to.
  37193. */
  37194. camera: ArcRotateCamera;
  37195. /**
  37196. * Defines the gamepad the input is gathering event from.
  37197. */
  37198. gamepad: Nullable<Gamepad>;
  37199. /**
  37200. * Defines the gamepad rotation sensiblity.
  37201. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37202. */
  37203. gamepadRotationSensibility: number;
  37204. /**
  37205. * Defines the gamepad move sensiblity.
  37206. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37207. */
  37208. gamepadMoveSensibility: number;
  37209. private _onGamepadConnectedObserver;
  37210. private _onGamepadDisconnectedObserver;
  37211. /**
  37212. * Attach the input controls to a specific dom element to get the input from.
  37213. * @param element Defines the element the controls should be listened from
  37214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37215. */
  37216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37217. /**
  37218. * Detach the current controls from the specified dom element.
  37219. * @param element Defines the element to stop listening the inputs from
  37220. */
  37221. detachControl(element: Nullable<HTMLElement>): void;
  37222. /**
  37223. * Update the current camera state depending on the inputs that have been used this frame.
  37224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37225. */
  37226. checkInputs(): void;
  37227. /**
  37228. * Gets the class name of the current intput.
  37229. * @returns the class name
  37230. */
  37231. getClassName(): string;
  37232. /**
  37233. * Get the friendly name associated with the input class.
  37234. * @returns the input friendly name
  37235. */
  37236. getSimpleName(): string;
  37237. }
  37238. }
  37239. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37240. import { Nullable } from "babylonjs/types";
  37241. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37242. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37243. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37244. interface ArcRotateCameraInputsManager {
  37245. /**
  37246. * Add orientation input support to the input manager.
  37247. * @returns the current input manager
  37248. */
  37249. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37250. }
  37251. }
  37252. /**
  37253. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37255. */
  37256. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37257. /**
  37258. * Defines the camera the input is attached to.
  37259. */
  37260. camera: ArcRotateCamera;
  37261. /**
  37262. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37263. */
  37264. alphaCorrection: number;
  37265. /**
  37266. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37267. */
  37268. gammaCorrection: number;
  37269. private _alpha;
  37270. private _gamma;
  37271. private _dirty;
  37272. private _deviceOrientationHandler;
  37273. /**
  37274. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37275. */
  37276. constructor();
  37277. /**
  37278. * Attach the input controls to a specific dom element to get the input from.
  37279. * @param element Defines the element the controls should be listened from
  37280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37281. */
  37282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37283. /** @hidden */
  37284. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37285. /**
  37286. * Update the current camera state depending on the inputs that have been used this frame.
  37287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37288. */
  37289. checkInputs(): void;
  37290. /**
  37291. * Detach the current controls from the specified dom element.
  37292. * @param element Defines the element to stop listening the inputs from
  37293. */
  37294. detachControl(element: Nullable<HTMLElement>): void;
  37295. /**
  37296. * Gets the class name of the current intput.
  37297. * @returns the class name
  37298. */
  37299. getClassName(): string;
  37300. /**
  37301. * Get the friendly name associated with the input class.
  37302. * @returns the input friendly name
  37303. */
  37304. getSimpleName(): string;
  37305. }
  37306. }
  37307. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37308. import { Nullable } from "babylonjs/types";
  37309. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37310. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37311. /**
  37312. * Listen to mouse events to control the camera.
  37313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37314. */
  37315. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37316. /**
  37317. * Defines the camera the input is attached to.
  37318. */
  37319. camera: FlyCamera;
  37320. /**
  37321. * Defines if touch is enabled. (Default is true.)
  37322. */
  37323. touchEnabled: boolean;
  37324. /**
  37325. * Defines the buttons associated with the input to handle camera rotation.
  37326. */
  37327. buttons: number[];
  37328. /**
  37329. * Assign buttons for Yaw control.
  37330. */
  37331. buttonsYaw: number[];
  37332. /**
  37333. * Assign buttons for Pitch control.
  37334. */
  37335. buttonsPitch: number[];
  37336. /**
  37337. * Assign buttons for Roll control.
  37338. */
  37339. buttonsRoll: number[];
  37340. /**
  37341. * Detect if any button is being pressed while mouse is moved.
  37342. * -1 = Mouse locked.
  37343. * 0 = Left button.
  37344. * 1 = Middle Button.
  37345. * 2 = Right Button.
  37346. */
  37347. activeButton: number;
  37348. /**
  37349. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37350. * Higher values reduce its sensitivity.
  37351. */
  37352. angularSensibility: number;
  37353. private _mousemoveCallback;
  37354. private _observer;
  37355. private _rollObserver;
  37356. private previousPosition;
  37357. private noPreventDefault;
  37358. private element;
  37359. /**
  37360. * Listen to mouse events to control the camera.
  37361. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37363. */
  37364. constructor(touchEnabled?: boolean);
  37365. /**
  37366. * Attach the mouse control to the HTML DOM element.
  37367. * @param element Defines the element that listens to the input events.
  37368. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37369. */
  37370. attachControl(element: HTMLElement, noPreventDefault?: boolean): 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 input.
  37378. * @returns the class name.
  37379. */
  37380. getClassName(): string;
  37381. /**
  37382. * Get the friendly name associated with the input class.
  37383. * @returns the input's friendly name.
  37384. */
  37385. getSimpleName(): string;
  37386. private _pointerInput;
  37387. private _onMouseMove;
  37388. /**
  37389. * Rotate camera by mouse offset.
  37390. */
  37391. private rotateCamera;
  37392. }
  37393. }
  37394. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37395. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37396. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37397. /**
  37398. * Default Inputs manager for the FlyCamera.
  37399. * It groups all the default supported inputs for ease of use.
  37400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37401. */
  37402. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37403. /**
  37404. * Instantiates a new FlyCameraInputsManager.
  37405. * @param camera Defines the camera the inputs belong to.
  37406. */
  37407. constructor(camera: FlyCamera);
  37408. /**
  37409. * Add keyboard input support to the input manager.
  37410. * @returns the new FlyCameraKeyboardMoveInput().
  37411. */
  37412. addKeyboard(): FlyCameraInputsManager;
  37413. /**
  37414. * Add mouse input support to the input manager.
  37415. * @param touchEnabled Enable touch screen support.
  37416. * @returns the new FlyCameraMouseInput().
  37417. */
  37418. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37419. }
  37420. }
  37421. declare module "babylonjs/Cameras/flyCamera" {
  37422. import { Scene } from "babylonjs/scene";
  37423. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37425. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37426. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37427. /**
  37428. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37429. * such as in a 3D Space Shooter or a Flight Simulator.
  37430. */
  37431. export class FlyCamera extends TargetCamera {
  37432. /**
  37433. * Define the collision ellipsoid of the camera.
  37434. * This is helpful for simulating a camera body, like a player's body.
  37435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37436. */
  37437. ellipsoid: Vector3;
  37438. /**
  37439. * Define an offset for the position of the ellipsoid around the camera.
  37440. * This can be helpful if the camera is attached away from the player's body center,
  37441. * such as at its head.
  37442. */
  37443. ellipsoidOffset: Vector3;
  37444. /**
  37445. * Enable or disable collisions of the camera with the rest of the scene objects.
  37446. */
  37447. checkCollisions: boolean;
  37448. /**
  37449. * Enable or disable gravity on the camera.
  37450. */
  37451. applyGravity: boolean;
  37452. /**
  37453. * Define the current direction the camera is moving to.
  37454. */
  37455. cameraDirection: Vector3;
  37456. /**
  37457. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37458. * This overrides and empties cameraRotation.
  37459. */
  37460. rotationQuaternion: Quaternion;
  37461. /**
  37462. * Track Roll to maintain the wanted Rolling when looking around.
  37463. */
  37464. _trackRoll: number;
  37465. /**
  37466. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37467. */
  37468. rollCorrect: number;
  37469. /**
  37470. * Mimic a banked turn, Rolling the camera when Yawing.
  37471. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37472. */
  37473. bankedTurn: boolean;
  37474. /**
  37475. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37476. */
  37477. bankedTurnLimit: number;
  37478. /**
  37479. * Value of 0 disables the banked Roll.
  37480. * Value of 1 is equal to the Yaw angle in radians.
  37481. */
  37482. bankedTurnMultiplier: number;
  37483. /**
  37484. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37485. */
  37486. inputs: FlyCameraInputsManager;
  37487. /**
  37488. * Gets the input sensibility for mouse input.
  37489. * Higher values reduce sensitivity.
  37490. */
  37491. /**
  37492. * Sets the input sensibility for a mouse input.
  37493. * Higher values reduce sensitivity.
  37494. */
  37495. angularSensibility: number;
  37496. /**
  37497. * Get the keys for camera movement forward.
  37498. */
  37499. /**
  37500. * Set the keys for camera movement forward.
  37501. */
  37502. keysForward: number[];
  37503. /**
  37504. * Get the keys for camera movement backward.
  37505. */
  37506. keysBackward: number[];
  37507. /**
  37508. * Get the keys for camera movement up.
  37509. */
  37510. /**
  37511. * Set the keys for camera movement up.
  37512. */
  37513. keysUp: number[];
  37514. /**
  37515. * Get the keys for camera movement down.
  37516. */
  37517. /**
  37518. * Set the keys for camera movement down.
  37519. */
  37520. keysDown: number[];
  37521. /**
  37522. * Get the keys for camera movement left.
  37523. */
  37524. /**
  37525. * Set the keys for camera movement left.
  37526. */
  37527. keysLeft: number[];
  37528. /**
  37529. * Set the keys for camera movement right.
  37530. */
  37531. /**
  37532. * Set the keys for camera movement right.
  37533. */
  37534. keysRight: number[];
  37535. /**
  37536. * Event raised when the camera collides with a mesh in the scene.
  37537. */
  37538. onCollide: (collidedMesh: AbstractMesh) => void;
  37539. private _collider;
  37540. private _needMoveForGravity;
  37541. private _oldPosition;
  37542. private _diffPosition;
  37543. private _newPosition;
  37544. /** @hidden */
  37545. _localDirection: Vector3;
  37546. /** @hidden */
  37547. _transformedDirection: Vector3;
  37548. /**
  37549. * Instantiates a FlyCamera.
  37550. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37551. * such as in a 3D Space Shooter or a Flight Simulator.
  37552. * @param name Define the name of the camera in the scene.
  37553. * @param position Define the starting position of the camera in the scene.
  37554. * @param scene Define the scene the camera belongs to.
  37555. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37556. */
  37557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37558. /**
  37559. * Attach a control to the HTML DOM element.
  37560. * @param element Defines the element that listens to the input events.
  37561. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37562. */
  37563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37564. /**
  37565. * Detach a control from the HTML DOM element.
  37566. * The camera will stop reacting to that input.
  37567. * @param element Defines the element that listens to the input events.
  37568. */
  37569. detachControl(element: HTMLElement): void;
  37570. private _collisionMask;
  37571. /**
  37572. * Get the mask that the camera ignores in collision events.
  37573. */
  37574. /**
  37575. * Set the mask that the camera ignores in collision events.
  37576. */
  37577. collisionMask: number;
  37578. /** @hidden */
  37579. _collideWithWorld(displacement: Vector3): void;
  37580. /** @hidden */
  37581. private _onCollisionPositionChange;
  37582. /** @hidden */
  37583. _checkInputs(): void;
  37584. /** @hidden */
  37585. _decideIfNeedsToMove(): boolean;
  37586. /** @hidden */
  37587. _updatePosition(): void;
  37588. /**
  37589. * Restore the Roll to its target value at the rate specified.
  37590. * @param rate - Higher means slower restoring.
  37591. * @hidden
  37592. */
  37593. restoreRoll(rate: number): void;
  37594. /**
  37595. * Destroy the camera and release the current resources held by it.
  37596. */
  37597. dispose(): void;
  37598. /**
  37599. * Get the current object class name.
  37600. * @returns the class name.
  37601. */
  37602. getClassName(): string;
  37603. }
  37604. }
  37605. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37606. import { Nullable } from "babylonjs/types";
  37607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37608. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37609. /**
  37610. * Listen to keyboard events to control the camera.
  37611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37612. */
  37613. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37614. /**
  37615. * Defines the camera the input is attached to.
  37616. */
  37617. camera: FlyCamera;
  37618. /**
  37619. * The list of keyboard keys used to control the forward move of the camera.
  37620. */
  37621. keysForward: number[];
  37622. /**
  37623. * The list of keyboard keys used to control the backward move of the camera.
  37624. */
  37625. keysBackward: number[];
  37626. /**
  37627. * The list of keyboard keys used to control the forward move of the camera.
  37628. */
  37629. keysUp: number[];
  37630. /**
  37631. * The list of keyboard keys used to control the backward move of the camera.
  37632. */
  37633. keysDown: number[];
  37634. /**
  37635. * The list of keyboard keys used to control the right strafe move of the camera.
  37636. */
  37637. keysRight: number[];
  37638. /**
  37639. * The list of keyboard keys used to control the left strafe move of the camera.
  37640. */
  37641. keysLeft: number[];
  37642. private _keys;
  37643. private _onCanvasBlurObserver;
  37644. private _onKeyboardObserver;
  37645. private _engine;
  37646. private _scene;
  37647. /**
  37648. * Attach the input controls to a specific dom element to get the input from.
  37649. * @param element Defines the element the controls should be listened from
  37650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37651. */
  37652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37653. /**
  37654. * Detach the current controls from the specified dom element.
  37655. * @param element Defines the element to stop listening the inputs from
  37656. */
  37657. detachControl(element: Nullable<HTMLElement>): void;
  37658. /**
  37659. * Gets the class name of the current intput.
  37660. * @returns the class name
  37661. */
  37662. getClassName(): string;
  37663. /** @hidden */
  37664. _onLostFocus(e: FocusEvent): void;
  37665. /**
  37666. * Get the friendly name associated with the input class.
  37667. * @returns the input friendly name
  37668. */
  37669. getSimpleName(): string;
  37670. /**
  37671. * Update the current camera state depending on the inputs that have been used this frame.
  37672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37673. */
  37674. checkInputs(): void;
  37675. }
  37676. }
  37677. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37678. import { Nullable } from "babylonjs/types";
  37679. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37680. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37681. /**
  37682. * Manage the mouse wheel inputs to control a follow camera.
  37683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37684. */
  37685. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37686. /**
  37687. * Defines the camera the input is attached to.
  37688. */
  37689. camera: FollowCamera;
  37690. /**
  37691. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37692. */
  37693. axisControlRadius: boolean;
  37694. /**
  37695. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37696. */
  37697. axisControlHeight: boolean;
  37698. /**
  37699. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37700. */
  37701. axisControlRotation: boolean;
  37702. /**
  37703. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37704. * relation to mouseWheel events.
  37705. */
  37706. wheelPrecision: number;
  37707. /**
  37708. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37709. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37710. */
  37711. wheelDeltaPercentage: number;
  37712. private _wheel;
  37713. private _observer;
  37714. /**
  37715. * Attach the input controls to a specific dom element to get the input from.
  37716. * @param element Defines the element the controls should be listened from
  37717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37718. */
  37719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37720. /**
  37721. * Detach the current controls from the specified dom element.
  37722. * @param element Defines the element to stop listening the inputs from
  37723. */
  37724. detachControl(element: Nullable<HTMLElement>): void;
  37725. /**
  37726. * Gets the class name of the current intput.
  37727. * @returns the class name
  37728. */
  37729. getClassName(): string;
  37730. /**
  37731. * Get the friendly name associated with the input class.
  37732. * @returns the input friendly name
  37733. */
  37734. getSimpleName(): string;
  37735. }
  37736. }
  37737. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37738. import { Nullable } from "babylonjs/types";
  37739. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37740. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37741. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37742. /**
  37743. * Manage the pointers inputs to control an follow camera.
  37744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37745. */
  37746. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37747. /**
  37748. * Defines the camera the input is attached to.
  37749. */
  37750. camera: FollowCamera;
  37751. /**
  37752. * Gets the class name of the current input.
  37753. * @returns the class name
  37754. */
  37755. getClassName(): string;
  37756. /**
  37757. * Defines the pointer angular sensibility along the X axis or how fast is
  37758. * the camera rotating.
  37759. * A negative number will reverse the axis direction.
  37760. */
  37761. angularSensibilityX: number;
  37762. /**
  37763. * Defines the pointer angular sensibility along the Y axis or how fast is
  37764. * the camera rotating.
  37765. * A negative number will reverse the axis direction.
  37766. */
  37767. angularSensibilityY: number;
  37768. /**
  37769. * Defines the pointer pinch precision or how fast is the camera zooming.
  37770. * A negative number will reverse the axis direction.
  37771. */
  37772. pinchPrecision: number;
  37773. /**
  37774. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37775. * from 0.
  37776. * It defines the percentage of current camera.radius to use as delta when
  37777. * pinch zoom is used.
  37778. */
  37779. pinchDeltaPercentage: number;
  37780. /**
  37781. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37782. */
  37783. axisXControlRadius: boolean;
  37784. /**
  37785. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37786. */
  37787. axisXControlHeight: boolean;
  37788. /**
  37789. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37790. */
  37791. axisXControlRotation: boolean;
  37792. /**
  37793. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37794. */
  37795. axisYControlRadius: boolean;
  37796. /**
  37797. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37798. */
  37799. axisYControlHeight: boolean;
  37800. /**
  37801. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37802. */
  37803. axisYControlRotation: boolean;
  37804. /**
  37805. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37806. */
  37807. axisPinchControlRadius: boolean;
  37808. /**
  37809. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37810. */
  37811. axisPinchControlHeight: boolean;
  37812. /**
  37813. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37814. */
  37815. axisPinchControlRotation: boolean;
  37816. /**
  37817. * Log error messages if basic misconfiguration has occurred.
  37818. */
  37819. warningEnable: boolean;
  37820. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37821. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37822. private _warningCounter;
  37823. private _warning;
  37824. }
  37825. }
  37826. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37827. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37828. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37829. /**
  37830. * Default Inputs manager for the FollowCamera.
  37831. * It groups all the default supported inputs for ease of use.
  37832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37833. */
  37834. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37835. /**
  37836. * Instantiates a new FollowCameraInputsManager.
  37837. * @param camera Defines the camera the inputs belong to
  37838. */
  37839. constructor(camera: FollowCamera);
  37840. /**
  37841. * Add keyboard input support to the input manager.
  37842. * @returns the current input manager
  37843. */
  37844. addKeyboard(): FollowCameraInputsManager;
  37845. /**
  37846. * Add mouse wheel input support to the input manager.
  37847. * @returns the current input manager
  37848. */
  37849. addMouseWheel(): FollowCameraInputsManager;
  37850. /**
  37851. * Add pointers input support to the input manager.
  37852. * @returns the current input manager
  37853. */
  37854. addPointers(): FollowCameraInputsManager;
  37855. /**
  37856. * Add orientation input support to the input manager.
  37857. * @returns the current input manager
  37858. */
  37859. addVRDeviceOrientation(): FollowCameraInputsManager;
  37860. }
  37861. }
  37862. declare module "babylonjs/Cameras/followCamera" {
  37863. import { Nullable } from "babylonjs/types";
  37864. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37865. import { Scene } from "babylonjs/scene";
  37866. import { Vector3 } from "babylonjs/Maths/math";
  37867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37868. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37869. /**
  37870. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37871. * an arc rotate version arcFollowCamera are available.
  37872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37873. */
  37874. export class FollowCamera extends TargetCamera {
  37875. /**
  37876. * Distance the follow camera should follow an object at
  37877. */
  37878. radius: number;
  37879. /**
  37880. * Minimum allowed distance of the camera to the axis of rotation
  37881. * (The camera can not get closer).
  37882. * This can help limiting how the Camera is able to move in the scene.
  37883. */
  37884. lowerRadiusLimit: Nullable<number>;
  37885. /**
  37886. * Maximum allowed distance of the camera to the axis of rotation
  37887. * (The camera can not get further).
  37888. * This can help limiting how the Camera is able to move in the scene.
  37889. */
  37890. upperRadiusLimit: Nullable<number>;
  37891. /**
  37892. * Define a rotation offset between the camera and the object it follows
  37893. */
  37894. rotationOffset: number;
  37895. /**
  37896. * Minimum allowed angle to camera position relative to target object.
  37897. * This can help limiting how the Camera is able to move in the scene.
  37898. */
  37899. lowerRotationOffsetLimit: Nullable<number>;
  37900. /**
  37901. * Maximum allowed angle to camera position relative to target object.
  37902. * This can help limiting how the Camera is able to move in the scene.
  37903. */
  37904. upperRotationOffsetLimit: Nullable<number>;
  37905. /**
  37906. * Define a height offset between the camera and the object it follows.
  37907. * It can help following an object from the top (like a car chaing a plane)
  37908. */
  37909. heightOffset: number;
  37910. /**
  37911. * Minimum allowed height of camera position relative to target object.
  37912. * This can help limiting how the Camera is able to move in the scene.
  37913. */
  37914. lowerHeightOffsetLimit: Nullable<number>;
  37915. /**
  37916. * Maximum allowed height of camera position relative to target object.
  37917. * This can help limiting how the Camera is able to move in the scene.
  37918. */
  37919. upperHeightOffsetLimit: Nullable<number>;
  37920. /**
  37921. * Define how fast the camera can accelerate to follow it s target.
  37922. */
  37923. cameraAcceleration: number;
  37924. /**
  37925. * Define the speed limit of the camera following an object.
  37926. */
  37927. maxCameraSpeed: number;
  37928. /**
  37929. * Define the target of the camera.
  37930. */
  37931. lockedTarget: Nullable<AbstractMesh>;
  37932. /**
  37933. * Defines the input associated with the camera.
  37934. */
  37935. inputs: FollowCameraInputsManager;
  37936. /**
  37937. * Instantiates the follow camera.
  37938. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37939. * @param name Define the name of the camera in the scene
  37940. * @param position Define the position of the camera
  37941. * @param scene Define the scene the camera belong to
  37942. * @param lockedTarget Define the target of the camera
  37943. */
  37944. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37945. private _follow;
  37946. /**
  37947. * Attached controls to the current camera.
  37948. * @param element Defines the element the controls should be listened from
  37949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37950. */
  37951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37952. /**
  37953. * Detach the current controls from the camera.
  37954. * The camera will stop reacting to inputs.
  37955. * @param element Defines the element to stop listening the inputs from
  37956. */
  37957. detachControl(element: HTMLElement): void;
  37958. /** @hidden */
  37959. _checkInputs(): void;
  37960. private _checkLimits;
  37961. /**
  37962. * Gets the camera class name.
  37963. * @returns the class name
  37964. */
  37965. getClassName(): string;
  37966. }
  37967. /**
  37968. * Arc Rotate version of the follow camera.
  37969. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37971. */
  37972. export class ArcFollowCamera extends TargetCamera {
  37973. /** The longitudinal angle of the camera */
  37974. alpha: number;
  37975. /** The latitudinal angle of the camera */
  37976. beta: number;
  37977. /** The radius of the camera from its target */
  37978. radius: number;
  37979. /** Define the camera target (the messh it should follow) */
  37980. target: Nullable<AbstractMesh>;
  37981. private _cartesianCoordinates;
  37982. /**
  37983. * Instantiates a new ArcFollowCamera
  37984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37985. * @param name Define the name of the camera
  37986. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37987. * @param beta Define the rotation angle of the camera around the elevation axis
  37988. * @param radius Define the radius of the camera from its target point
  37989. * @param target Define the target of the camera
  37990. * @param scene Define the scene the camera belongs to
  37991. */
  37992. constructor(name: string,
  37993. /** The longitudinal angle of the camera */
  37994. alpha: number,
  37995. /** The latitudinal angle of the camera */
  37996. beta: number,
  37997. /** The radius of the camera from its target */
  37998. radius: number,
  37999. /** Define the camera target (the messh it should follow) */
  38000. target: Nullable<AbstractMesh>, scene: Scene);
  38001. private _follow;
  38002. /** @hidden */
  38003. _checkInputs(): void;
  38004. /**
  38005. * Returns the class name of the object.
  38006. * It is mostly used internally for serialization purposes.
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38012. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38013. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38014. import { Nullable } from "babylonjs/types";
  38015. /**
  38016. * Manage the keyboard inputs to control the movement of a follow camera.
  38017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38018. */
  38019. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38020. /**
  38021. * Defines the camera the input is attached to.
  38022. */
  38023. camera: FollowCamera;
  38024. /**
  38025. * Defines the list of key codes associated with the up action (increase heightOffset)
  38026. */
  38027. keysHeightOffsetIncr: number[];
  38028. /**
  38029. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38030. */
  38031. keysHeightOffsetDecr: number[];
  38032. /**
  38033. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38034. */
  38035. keysHeightOffsetModifierAlt: boolean;
  38036. /**
  38037. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38038. */
  38039. keysHeightOffsetModifierCtrl: boolean;
  38040. /**
  38041. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38042. */
  38043. keysHeightOffsetModifierShift: boolean;
  38044. /**
  38045. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38046. */
  38047. keysRotationOffsetIncr: number[];
  38048. /**
  38049. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38050. */
  38051. keysRotationOffsetDecr: number[];
  38052. /**
  38053. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38054. */
  38055. keysRotationOffsetModifierAlt: boolean;
  38056. /**
  38057. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38058. */
  38059. keysRotationOffsetModifierCtrl: boolean;
  38060. /**
  38061. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38062. */
  38063. keysRotationOffsetModifierShift: boolean;
  38064. /**
  38065. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38066. */
  38067. keysRadiusIncr: number[];
  38068. /**
  38069. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38070. */
  38071. keysRadiusDecr: number[];
  38072. /**
  38073. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38074. */
  38075. keysRadiusModifierAlt: boolean;
  38076. /**
  38077. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38078. */
  38079. keysRadiusModifierCtrl: boolean;
  38080. /**
  38081. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38082. */
  38083. keysRadiusModifierShift: boolean;
  38084. /**
  38085. * Defines the rate of change of heightOffset.
  38086. */
  38087. heightSensibility: number;
  38088. /**
  38089. * Defines the rate of change of rotationOffset.
  38090. */
  38091. rotationSensibility: number;
  38092. /**
  38093. * Defines the rate of change of radius.
  38094. */
  38095. radiusSensibility: number;
  38096. private _keys;
  38097. private _ctrlPressed;
  38098. private _altPressed;
  38099. private _shiftPressed;
  38100. private _onCanvasBlurObserver;
  38101. private _onKeyboardObserver;
  38102. private _engine;
  38103. private _scene;
  38104. /**
  38105. * Attach the input controls to a specific dom element to get the input from.
  38106. * @param element Defines the element the controls should be listened from
  38107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38108. */
  38109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38110. /**
  38111. * Detach the current controls from the specified dom element.
  38112. * @param element Defines the element to stop listening the inputs from
  38113. */
  38114. detachControl(element: Nullable<HTMLElement>): void;
  38115. /**
  38116. * Update the current camera state depending on the inputs that have been used this frame.
  38117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38118. */
  38119. checkInputs(): void;
  38120. /**
  38121. * Gets the class name of the current input.
  38122. * @returns the class name
  38123. */
  38124. getClassName(): string;
  38125. /**
  38126. * Get the friendly name associated with the input class.
  38127. * @returns the input friendly name
  38128. */
  38129. getSimpleName(): string;
  38130. /**
  38131. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38132. * allow modification of the heightOffset value.
  38133. */
  38134. private _modifierHeightOffset;
  38135. /**
  38136. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38137. * allow modification of the rotationOffset value.
  38138. */
  38139. private _modifierRotationOffset;
  38140. /**
  38141. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38142. * allow modification of the radius value.
  38143. */
  38144. private _modifierRadius;
  38145. }
  38146. }
  38147. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38148. import { Nullable } from "babylonjs/types";
  38149. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38150. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38151. import { Observable } from "babylonjs/Misc/observable";
  38152. module "babylonjs/Cameras/freeCameraInputsManager" {
  38153. interface FreeCameraInputsManager {
  38154. /**
  38155. * @hidden
  38156. */
  38157. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38158. /**
  38159. * Add orientation input support to the input manager.
  38160. * @returns the current input manager
  38161. */
  38162. addDeviceOrientation(): FreeCameraInputsManager;
  38163. }
  38164. }
  38165. /**
  38166. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38167. * Screen rotation is taken into account.
  38168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38169. */
  38170. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38171. private _camera;
  38172. private _screenOrientationAngle;
  38173. private _constantTranform;
  38174. private _screenQuaternion;
  38175. private _alpha;
  38176. private _beta;
  38177. private _gamma;
  38178. /**
  38179. * @hidden
  38180. */
  38181. _onDeviceOrientationChangedObservable: Observable<void>;
  38182. /**
  38183. * Instantiates a new input
  38184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38185. */
  38186. constructor();
  38187. /**
  38188. * Define the camera controlled by the input.
  38189. */
  38190. camera: FreeCamera;
  38191. /**
  38192. * Attach the input controls to a specific dom element to get the input from.
  38193. * @param element Defines the element the controls should be listened from
  38194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38195. */
  38196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38197. private _orientationChanged;
  38198. private _deviceOrientation;
  38199. /**
  38200. * Detach the current controls from the specified dom element.
  38201. * @param element Defines the element to stop listening the inputs from
  38202. */
  38203. detachControl(element: Nullable<HTMLElement>): void;
  38204. /**
  38205. * Update the current camera state depending on the inputs that have been used this frame.
  38206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38207. */
  38208. checkInputs(): void;
  38209. /**
  38210. * Gets the class name of the current intput.
  38211. * @returns the class name
  38212. */
  38213. getClassName(): string;
  38214. /**
  38215. * Get the friendly name associated with the input class.
  38216. * @returns the input friendly name
  38217. */
  38218. getSimpleName(): string;
  38219. }
  38220. }
  38221. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38222. import { Nullable } from "babylonjs/types";
  38223. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38225. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38226. /**
  38227. * Manage the gamepad inputs to control a free camera.
  38228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38229. */
  38230. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38231. /**
  38232. * Define the camera the input is attached to.
  38233. */
  38234. camera: FreeCamera;
  38235. /**
  38236. * Define the Gamepad controlling the input
  38237. */
  38238. gamepad: Nullable<Gamepad>;
  38239. /**
  38240. * Defines the gamepad rotation sensiblity.
  38241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38242. */
  38243. gamepadAngularSensibility: number;
  38244. /**
  38245. * Defines the gamepad move sensiblity.
  38246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38247. */
  38248. gamepadMoveSensibility: number;
  38249. private _onGamepadConnectedObserver;
  38250. private _onGamepadDisconnectedObserver;
  38251. private _cameraTransform;
  38252. private _deltaTransform;
  38253. private _vector3;
  38254. private _vector2;
  38255. /**
  38256. * Attach the input controls to a specific dom element to get the input from.
  38257. * @param element Defines the element the controls should be listened from
  38258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38259. */
  38260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38261. /**
  38262. * Detach the current controls from the specified dom element.
  38263. * @param element Defines the element to stop listening the inputs from
  38264. */
  38265. detachControl(element: Nullable<HTMLElement>): void;
  38266. /**
  38267. * Update the current camera state depending on the inputs that have been used this frame.
  38268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38269. */
  38270. checkInputs(): void;
  38271. /**
  38272. * Gets the class name of the current intput.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * Get the friendly name associated with the input class.
  38278. * @returns the input friendly name
  38279. */
  38280. getSimpleName(): string;
  38281. }
  38282. }
  38283. declare module "babylonjs/Misc/virtualJoystick" {
  38284. import { Nullable } from "babylonjs/types";
  38285. import { Vector3 } from "babylonjs/Maths/math";
  38286. /**
  38287. * Defines the potential axis of a Joystick
  38288. */
  38289. export enum JoystickAxis {
  38290. /** X axis */
  38291. X = 0,
  38292. /** Y axis */
  38293. Y = 1,
  38294. /** Z axis */
  38295. Z = 2
  38296. }
  38297. /**
  38298. * Class used to define virtual joystick (used in touch mode)
  38299. */
  38300. export class VirtualJoystick {
  38301. /**
  38302. * Gets or sets a boolean indicating that left and right values must be inverted
  38303. */
  38304. reverseLeftRight: boolean;
  38305. /**
  38306. * Gets or sets a boolean indicating that up and down values must be inverted
  38307. */
  38308. reverseUpDown: boolean;
  38309. /**
  38310. * Gets the offset value for the position (ie. the change of the position value)
  38311. */
  38312. deltaPosition: Vector3;
  38313. /**
  38314. * Gets a boolean indicating if the virtual joystick was pressed
  38315. */
  38316. pressed: boolean;
  38317. /**
  38318. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38319. */
  38320. static Canvas: Nullable<HTMLCanvasElement>;
  38321. private static _globalJoystickIndex;
  38322. private static vjCanvasContext;
  38323. private static vjCanvasWidth;
  38324. private static vjCanvasHeight;
  38325. private static halfWidth;
  38326. private _action;
  38327. private _axisTargetedByLeftAndRight;
  38328. private _axisTargetedByUpAndDown;
  38329. private _joystickSensibility;
  38330. private _inversedSensibility;
  38331. private _joystickPointerID;
  38332. private _joystickColor;
  38333. private _joystickPointerPos;
  38334. private _joystickPreviousPointerPos;
  38335. private _joystickPointerStartPos;
  38336. private _deltaJoystickVector;
  38337. private _leftJoystick;
  38338. private _touches;
  38339. private _onPointerDownHandlerRef;
  38340. private _onPointerMoveHandlerRef;
  38341. private _onPointerUpHandlerRef;
  38342. private _onResize;
  38343. /**
  38344. * Creates a new virtual joystick
  38345. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38346. */
  38347. constructor(leftJoystick?: boolean);
  38348. /**
  38349. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38350. * @param newJoystickSensibility defines the new sensibility
  38351. */
  38352. setJoystickSensibility(newJoystickSensibility: number): void;
  38353. private _onPointerDown;
  38354. private _onPointerMove;
  38355. private _onPointerUp;
  38356. /**
  38357. * Change the color of the virtual joystick
  38358. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38359. */
  38360. setJoystickColor(newColor: string): void;
  38361. /**
  38362. * Defines a callback to call when the joystick is touched
  38363. * @param action defines the callback
  38364. */
  38365. setActionOnTouch(action: () => any): void;
  38366. /**
  38367. * Defines which axis you'd like to control for left & right
  38368. * @param axis defines the axis to use
  38369. */
  38370. setAxisForLeftRight(axis: JoystickAxis): void;
  38371. /**
  38372. * Defines which axis you'd like to control for up & down
  38373. * @param axis defines the axis to use
  38374. */
  38375. setAxisForUpDown(axis: JoystickAxis): void;
  38376. private _drawVirtualJoystick;
  38377. /**
  38378. * Release internal HTML canvas
  38379. */
  38380. releaseCanvas(): void;
  38381. }
  38382. }
  38383. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38384. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38385. import { Nullable } from "babylonjs/types";
  38386. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38387. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38388. module "babylonjs/Cameras/freeCameraInputsManager" {
  38389. interface FreeCameraInputsManager {
  38390. /**
  38391. * Add virtual joystick input support to the input manager.
  38392. * @returns the current input manager
  38393. */
  38394. addVirtualJoystick(): FreeCameraInputsManager;
  38395. }
  38396. }
  38397. /**
  38398. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38400. */
  38401. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38402. /**
  38403. * Defines the camera the input is attached to.
  38404. */
  38405. camera: FreeCamera;
  38406. private _leftjoystick;
  38407. private _rightjoystick;
  38408. /**
  38409. * Gets the left stick of the virtual joystick.
  38410. * @returns The virtual Joystick
  38411. */
  38412. getLeftJoystick(): VirtualJoystick;
  38413. /**
  38414. * Gets the right stick of the virtual joystick.
  38415. * @returns The virtual Joystick
  38416. */
  38417. getRightJoystick(): VirtualJoystick;
  38418. /**
  38419. * Update the current camera state depending on the inputs that have been used this frame.
  38420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38421. */
  38422. checkInputs(): void;
  38423. /**
  38424. * Attach the input controls to a specific dom element to get the input from.
  38425. * @param element Defines the element the controls should be listened from
  38426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38427. */
  38428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38429. /**
  38430. * Detach the current controls from the specified dom element.
  38431. * @param element Defines the element to stop listening the inputs from
  38432. */
  38433. detachControl(element: Nullable<HTMLElement>): void;
  38434. /**
  38435. * Gets the class name of the current intput.
  38436. * @returns the class name
  38437. */
  38438. getClassName(): string;
  38439. /**
  38440. * Get the friendly name associated with the input class.
  38441. * @returns the input friendly name
  38442. */
  38443. getSimpleName(): string;
  38444. }
  38445. }
  38446. declare module "babylonjs/Cameras/Inputs/index" {
  38447. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38448. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38449. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38450. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38451. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38452. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38453. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38454. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38455. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38456. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38457. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38458. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38459. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38460. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38461. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38462. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38463. }
  38464. declare module "babylonjs/Cameras/touchCamera" {
  38465. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38466. import { Scene } from "babylonjs/scene";
  38467. import { Vector3 } from "babylonjs/Maths/math";
  38468. /**
  38469. * This represents a FPS type of camera controlled by touch.
  38470. * This is like a universal camera minus the Gamepad controls.
  38471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38472. */
  38473. export class TouchCamera extends FreeCamera {
  38474. /**
  38475. * Defines the touch sensibility for rotation.
  38476. * The higher the faster.
  38477. */
  38478. touchAngularSensibility: number;
  38479. /**
  38480. * Defines the touch sensibility for move.
  38481. * The higher the faster.
  38482. */
  38483. touchMoveSensibility: number;
  38484. /**
  38485. * Instantiates a new touch camera.
  38486. * This represents a FPS type of camera controlled by touch.
  38487. * This is like a universal camera minus the Gamepad controls.
  38488. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38489. * @param name Define the name of the camera in the scene
  38490. * @param position Define the start position of the camera in the scene
  38491. * @param scene Define the scene the camera belongs to
  38492. */
  38493. constructor(name: string, position: Vector3, scene: Scene);
  38494. /**
  38495. * Gets the current object class name.
  38496. * @return the class name
  38497. */
  38498. getClassName(): string;
  38499. /** @hidden */
  38500. _setupInputs(): void;
  38501. }
  38502. }
  38503. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38504. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38505. import { Scene } from "babylonjs/scene";
  38506. import { Vector3, Axis } from "babylonjs/Maths/math";
  38507. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38508. /**
  38509. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38510. * being tilted forward or back and left or right.
  38511. */
  38512. export class DeviceOrientationCamera extends FreeCamera {
  38513. private _initialQuaternion;
  38514. private _quaternionCache;
  38515. private _tmpDragQuaternion;
  38516. /**
  38517. * Creates a new device orientation camera
  38518. * @param name The name of the camera
  38519. * @param position The start position camera
  38520. * @param scene The scene the camera belongs to
  38521. */
  38522. constructor(name: string, position: Vector3, scene: Scene);
  38523. /**
  38524. * @hidden
  38525. * Disabled pointer input on first orientation sensor update (Default: true)
  38526. */
  38527. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38528. private _dragFactor;
  38529. /**
  38530. * Enabled turning on the y axis when the orientation sensor is active
  38531. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38532. */
  38533. enableHorizontalDragging(dragFactor?: number): void;
  38534. /**
  38535. * Gets the current instance class name ("DeviceOrientationCamera").
  38536. * This helps avoiding instanceof at run time.
  38537. * @returns the class name
  38538. */
  38539. getClassName(): string;
  38540. /**
  38541. * @hidden
  38542. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38543. */
  38544. _checkInputs(): void;
  38545. /**
  38546. * Reset the camera to its default orientation on the specified axis only.
  38547. * @param axis The axis to reset
  38548. */
  38549. resetToCurrentRotation(axis?: Axis): void;
  38550. }
  38551. }
  38552. declare module "babylonjs/Cameras/universalCamera" {
  38553. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3 } from "babylonjs/Maths/math";
  38556. /**
  38557. * 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,
  38558. * which still works and will still be found in many Playgrounds.
  38559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38560. */
  38561. export class UniversalCamera extends TouchCamera {
  38562. /**
  38563. * Defines the gamepad rotation sensiblity.
  38564. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38565. */
  38566. gamepadAngularSensibility: number;
  38567. /**
  38568. * Defines the gamepad move sensiblity.
  38569. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38570. */
  38571. gamepadMoveSensibility: number;
  38572. /**
  38573. * 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,
  38574. * which still works and will still be found in many Playgrounds.
  38575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38576. * @param name Define the name of the camera in the scene
  38577. * @param position Define the start position of the camera in the scene
  38578. * @param scene Define the scene the camera belongs to
  38579. */
  38580. constructor(name: string, position: Vector3, scene: Scene);
  38581. /**
  38582. * Gets the current object class name.
  38583. * @return the class name
  38584. */
  38585. getClassName(): string;
  38586. }
  38587. }
  38588. declare module "babylonjs/Cameras/gamepadCamera" {
  38589. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38590. import { Scene } from "babylonjs/scene";
  38591. import { Vector3 } from "babylonjs/Maths/math";
  38592. /**
  38593. * This represents a FPS type of camera. This is only here for back compat purpose.
  38594. * Please use the UniversalCamera instead as both are identical.
  38595. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38596. */
  38597. export class GamepadCamera extends UniversalCamera {
  38598. /**
  38599. * Instantiates a new Gamepad Camera
  38600. * This represents a FPS type of camera. This is only here for back compat purpose.
  38601. * Please use the UniversalCamera instead as both are identical.
  38602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38603. * @param name Define the name of the camera in the scene
  38604. * @param position Define the start position of the camera in the scene
  38605. * @param scene Define the scene the camera belongs to
  38606. */
  38607. constructor(name: string, position: Vector3, scene: Scene);
  38608. /**
  38609. * Gets the current object class name.
  38610. * @return the class name
  38611. */
  38612. getClassName(): string;
  38613. }
  38614. }
  38615. declare module "babylonjs/Shaders/pass.fragment" {
  38616. /** @hidden */
  38617. export var passPixelShader: {
  38618. name: string;
  38619. shader: string;
  38620. };
  38621. }
  38622. declare module "babylonjs/Shaders/passCube.fragment" {
  38623. /** @hidden */
  38624. export var passCubePixelShader: {
  38625. name: string;
  38626. shader: string;
  38627. };
  38628. }
  38629. declare module "babylonjs/PostProcesses/passPostProcess" {
  38630. import { Nullable } from "babylonjs/types";
  38631. import { Camera } from "babylonjs/Cameras/camera";
  38632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38633. import { Engine } from "babylonjs/Engines/engine";
  38634. import "babylonjs/Shaders/pass.fragment";
  38635. import "babylonjs/Shaders/passCube.fragment";
  38636. /**
  38637. * PassPostProcess which produces an output the same as it's input
  38638. */
  38639. export class PassPostProcess extends PostProcess {
  38640. /**
  38641. * Creates the PassPostProcess
  38642. * @param name The name of the effect.
  38643. * @param options The required width/height ratio to downsize to before computing the render pass.
  38644. * @param camera The camera to apply the render pass to.
  38645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38646. * @param engine The engine which the post process will be applied. (default: current engine)
  38647. * @param reusable If the post process can be reused on the same frame. (default: false)
  38648. * @param textureType The type of texture to be used when performing the post processing.
  38649. * @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)
  38650. */
  38651. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38652. }
  38653. /**
  38654. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38655. */
  38656. export class PassCubePostProcess extends PostProcess {
  38657. private _face;
  38658. /**
  38659. * Gets or sets the cube face to display.
  38660. * * 0 is +X
  38661. * * 1 is -X
  38662. * * 2 is +Y
  38663. * * 3 is -Y
  38664. * * 4 is +Z
  38665. * * 5 is -Z
  38666. */
  38667. face: number;
  38668. /**
  38669. * Creates the PassCubePostProcess
  38670. * @param name The name of the effect.
  38671. * @param options The required width/height ratio to downsize to before computing the render pass.
  38672. * @param camera The camera to apply the render pass to.
  38673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38674. * @param engine The engine which the post process will be applied. (default: current engine)
  38675. * @param reusable If the post process can be reused on the same frame. (default: false)
  38676. * @param textureType The type of texture to be used when performing the post processing.
  38677. * @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)
  38678. */
  38679. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38680. }
  38681. }
  38682. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38683. /** @hidden */
  38684. export var anaglyphPixelShader: {
  38685. name: string;
  38686. shader: string;
  38687. };
  38688. }
  38689. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38690. import { Engine } from "babylonjs/Engines/engine";
  38691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38692. import { Camera } from "babylonjs/Cameras/camera";
  38693. import "babylonjs/Shaders/anaglyph.fragment";
  38694. /**
  38695. * Postprocess used to generate anaglyphic rendering
  38696. */
  38697. export class AnaglyphPostProcess extends PostProcess {
  38698. private _passedProcess;
  38699. /**
  38700. * Creates a new AnaglyphPostProcess
  38701. * @param name defines postprocess name
  38702. * @param options defines creation options or target ratio scale
  38703. * @param rigCameras defines cameras using this postprocess
  38704. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38705. * @param engine defines hosting engine
  38706. * @param reusable defines if the postprocess will be reused multiple times per frame
  38707. */
  38708. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38712. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38713. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38714. import { Scene } from "babylonjs/scene";
  38715. import { Vector3 } from "babylonjs/Maths/math";
  38716. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38717. /**
  38718. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38719. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38720. */
  38721. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38722. /**
  38723. * Creates a new AnaglyphArcRotateCamera
  38724. * @param name defines camera name
  38725. * @param alpha defines alpha angle (in radians)
  38726. * @param beta defines beta angle (in radians)
  38727. * @param radius defines radius
  38728. * @param target defines camera target
  38729. * @param interaxialDistance defines distance between each color axis
  38730. * @param scene defines the hosting scene
  38731. */
  38732. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38733. /**
  38734. * Gets camera class name
  38735. * @returns AnaglyphArcRotateCamera
  38736. */
  38737. getClassName(): string;
  38738. }
  38739. }
  38740. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38741. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38742. import { Scene } from "babylonjs/scene";
  38743. import { Vector3 } from "babylonjs/Maths/math";
  38744. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38745. /**
  38746. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38748. */
  38749. export class AnaglyphFreeCamera extends FreeCamera {
  38750. /**
  38751. * Creates a new AnaglyphFreeCamera
  38752. * @param name defines camera name
  38753. * @param position defines initial position
  38754. * @param interaxialDistance defines distance between each color axis
  38755. * @param scene defines the hosting scene
  38756. */
  38757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38758. /**
  38759. * Gets camera class name
  38760. * @returns AnaglyphFreeCamera
  38761. */
  38762. getClassName(): string;
  38763. }
  38764. }
  38765. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38766. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38767. import { Scene } from "babylonjs/scene";
  38768. import { Vector3 } from "babylonjs/Maths/math";
  38769. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38770. /**
  38771. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38772. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38773. */
  38774. export class AnaglyphGamepadCamera extends GamepadCamera {
  38775. /**
  38776. * Creates a new AnaglyphGamepadCamera
  38777. * @param name defines camera name
  38778. * @param position defines initial position
  38779. * @param interaxialDistance defines distance between each color axis
  38780. * @param scene defines the hosting scene
  38781. */
  38782. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38783. /**
  38784. * Gets camera class name
  38785. * @returns AnaglyphGamepadCamera
  38786. */
  38787. getClassName(): string;
  38788. }
  38789. }
  38790. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38791. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38792. import { Scene } from "babylonjs/scene";
  38793. import { Vector3 } from "babylonjs/Maths/math";
  38794. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38795. /**
  38796. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38797. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38798. */
  38799. export class AnaglyphUniversalCamera extends UniversalCamera {
  38800. /**
  38801. * Creates a new AnaglyphUniversalCamera
  38802. * @param name defines camera name
  38803. * @param position defines initial position
  38804. * @param interaxialDistance defines distance between each color axis
  38805. * @param scene defines the hosting scene
  38806. */
  38807. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38808. /**
  38809. * Gets camera class name
  38810. * @returns AnaglyphUniversalCamera
  38811. */
  38812. getClassName(): string;
  38813. }
  38814. }
  38815. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38816. /** @hidden */
  38817. export var stereoscopicInterlacePixelShader: {
  38818. name: string;
  38819. shader: string;
  38820. };
  38821. }
  38822. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38823. import { Camera } from "babylonjs/Cameras/camera";
  38824. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38825. import { Engine } from "babylonjs/Engines/engine";
  38826. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38827. /**
  38828. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38829. */
  38830. export class StereoscopicInterlacePostProcess extends PostProcess {
  38831. private _stepSize;
  38832. private _passedProcess;
  38833. /**
  38834. * Initializes a StereoscopicInterlacePostProcess
  38835. * @param name The name of the effect.
  38836. * @param rigCameras The rig cameras to be appled to the post process
  38837. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38839. * @param engine The engine which the post process will be applied. (default: current engine)
  38840. * @param reusable If the post process can be reused on the same frame. (default: false)
  38841. */
  38842. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38843. }
  38844. }
  38845. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38846. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38847. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38848. import { Scene } from "babylonjs/scene";
  38849. import { Vector3 } from "babylonjs/Maths/math";
  38850. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38851. /**
  38852. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38853. * @see http://doc.babylonjs.com/features/cameras
  38854. */
  38855. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38856. /**
  38857. * Creates a new StereoscopicArcRotateCamera
  38858. * @param name defines camera name
  38859. * @param alpha defines alpha angle (in radians)
  38860. * @param beta defines beta angle (in radians)
  38861. * @param radius defines radius
  38862. * @param target defines camera target
  38863. * @param interaxialDistance defines distance between each color axis
  38864. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38865. * @param scene defines the hosting scene
  38866. */
  38867. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38868. /**
  38869. * Gets camera class name
  38870. * @returns StereoscopicArcRotateCamera
  38871. */
  38872. getClassName(): string;
  38873. }
  38874. }
  38875. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38877. import { Scene } from "babylonjs/scene";
  38878. import { Vector3 } from "babylonjs/Maths/math";
  38879. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38880. /**
  38881. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38882. * @see http://doc.babylonjs.com/features/cameras
  38883. */
  38884. export class StereoscopicFreeCamera extends FreeCamera {
  38885. /**
  38886. * Creates a new StereoscopicFreeCamera
  38887. * @param name defines camera name
  38888. * @param position defines initial position
  38889. * @param interaxialDistance defines distance between each color axis
  38890. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38891. * @param scene defines the hosting scene
  38892. */
  38893. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38894. /**
  38895. * Gets camera class name
  38896. * @returns StereoscopicFreeCamera
  38897. */
  38898. getClassName(): string;
  38899. }
  38900. }
  38901. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38902. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38903. import { Scene } from "babylonjs/scene";
  38904. import { Vector3 } from "babylonjs/Maths/math";
  38905. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38906. /**
  38907. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38908. * @see http://doc.babylonjs.com/features/cameras
  38909. */
  38910. export class StereoscopicGamepadCamera extends GamepadCamera {
  38911. /**
  38912. * Creates a new StereoscopicGamepadCamera
  38913. * @param name defines camera name
  38914. * @param position defines initial position
  38915. * @param interaxialDistance defines distance between each color axis
  38916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38917. * @param scene defines the hosting scene
  38918. */
  38919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38920. /**
  38921. * Gets camera class name
  38922. * @returns StereoscopicGamepadCamera
  38923. */
  38924. getClassName(): string;
  38925. }
  38926. }
  38927. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38928. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38929. import { Scene } from "babylonjs/scene";
  38930. import { Vector3 } from "babylonjs/Maths/math";
  38931. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38932. /**
  38933. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38934. * @see http://doc.babylonjs.com/features/cameras
  38935. */
  38936. export class StereoscopicUniversalCamera extends UniversalCamera {
  38937. /**
  38938. * Creates a new StereoscopicUniversalCamera
  38939. * @param name defines camera name
  38940. * @param position defines initial position
  38941. * @param interaxialDistance defines distance between each color axis
  38942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38943. * @param scene defines the hosting scene
  38944. */
  38945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38946. /**
  38947. * Gets camera class name
  38948. * @returns StereoscopicUniversalCamera
  38949. */
  38950. getClassName(): string;
  38951. }
  38952. }
  38953. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38954. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38955. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38956. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38957. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38958. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38959. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38960. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38961. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38962. }
  38963. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38965. import { Scene } from "babylonjs/scene";
  38966. import { Vector3 } from "babylonjs/Maths/math";
  38967. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38968. /**
  38969. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38970. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38971. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38972. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38973. */
  38974. export class VirtualJoysticksCamera extends FreeCamera {
  38975. /**
  38976. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38977. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38978. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38979. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38980. * @param name Define the name of the camera in the scene
  38981. * @param position Define the start position of the camera in the scene
  38982. * @param scene Define the scene the camera belongs to
  38983. */
  38984. constructor(name: string, position: Vector3, scene: Scene);
  38985. /**
  38986. * Gets the current object class name.
  38987. * @return the class name
  38988. */
  38989. getClassName(): string;
  38990. }
  38991. }
  38992. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38993. import { Matrix } from "babylonjs/Maths/math";
  38994. /**
  38995. * This represents all the required metrics to create a VR camera.
  38996. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38997. */
  38998. export class VRCameraMetrics {
  38999. /**
  39000. * Define the horizontal resolution off the screen.
  39001. */
  39002. hResolution: number;
  39003. /**
  39004. * Define the vertical resolution off the screen.
  39005. */
  39006. vResolution: number;
  39007. /**
  39008. * Define the horizontal screen size.
  39009. */
  39010. hScreenSize: number;
  39011. /**
  39012. * Define the vertical screen size.
  39013. */
  39014. vScreenSize: number;
  39015. /**
  39016. * Define the vertical screen center position.
  39017. */
  39018. vScreenCenter: number;
  39019. /**
  39020. * Define the distance of the eyes to the screen.
  39021. */
  39022. eyeToScreenDistance: number;
  39023. /**
  39024. * Define the distance between both lenses
  39025. */
  39026. lensSeparationDistance: number;
  39027. /**
  39028. * Define the distance between both viewer's eyes.
  39029. */
  39030. interpupillaryDistance: number;
  39031. /**
  39032. * Define the distortion factor of the VR postprocess.
  39033. * Please, touch with care.
  39034. */
  39035. distortionK: number[];
  39036. /**
  39037. * Define the chromatic aberration correction factors for the VR post process.
  39038. */
  39039. chromaAbCorrection: number[];
  39040. /**
  39041. * Define the scale factor of the post process.
  39042. * The smaller the better but the slower.
  39043. */
  39044. postProcessScaleFactor: number;
  39045. /**
  39046. * Define an offset for the lens center.
  39047. */
  39048. lensCenterOffset: number;
  39049. /**
  39050. * Define if the current vr camera should compensate the distortion of the lense or not.
  39051. */
  39052. compensateDistortion: boolean;
  39053. /**
  39054. * Defines if multiview should be enabled when rendering (Default: false)
  39055. */
  39056. multiviewEnabled: boolean;
  39057. /**
  39058. * Gets the rendering aspect ratio based on the provided resolutions.
  39059. */
  39060. readonly aspectRatio: number;
  39061. /**
  39062. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39063. */
  39064. readonly aspectRatioFov: number;
  39065. /**
  39066. * @hidden
  39067. */
  39068. readonly leftHMatrix: Matrix;
  39069. /**
  39070. * @hidden
  39071. */
  39072. readonly rightHMatrix: Matrix;
  39073. /**
  39074. * @hidden
  39075. */
  39076. readonly leftPreViewMatrix: Matrix;
  39077. /**
  39078. * @hidden
  39079. */
  39080. readonly rightPreViewMatrix: Matrix;
  39081. /**
  39082. * Get the default VRMetrics based on the most generic setup.
  39083. * @returns the default vr metrics
  39084. */
  39085. static GetDefault(): VRCameraMetrics;
  39086. }
  39087. }
  39088. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39089. /** @hidden */
  39090. export var vrDistortionCorrectionPixelShader: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39096. import { Camera } from "babylonjs/Cameras/camera";
  39097. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39099. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39100. /**
  39101. * VRDistortionCorrectionPostProcess used for mobile VR
  39102. */
  39103. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39104. private _isRightEye;
  39105. private _distortionFactors;
  39106. private _postProcessScaleFactor;
  39107. private _lensCenterOffset;
  39108. private _scaleIn;
  39109. private _scaleFactor;
  39110. private _lensCenter;
  39111. /**
  39112. * Initializes the VRDistortionCorrectionPostProcess
  39113. * @param name The name of the effect.
  39114. * @param camera The camera to apply the render pass to.
  39115. * @param isRightEye If this is for the right eye distortion
  39116. * @param vrMetrics All the required metrics for the VR camera
  39117. */
  39118. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39119. }
  39120. }
  39121. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39122. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39123. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39124. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39125. import { Scene } from "babylonjs/scene";
  39126. import { Vector3 } from "babylonjs/Maths/math";
  39127. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39128. import "babylonjs/Cameras/RigModes/vrRigMode";
  39129. /**
  39130. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39131. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39132. */
  39133. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39134. /**
  39135. * Creates a new VRDeviceOrientationArcRotateCamera
  39136. * @param name defines camera name
  39137. * @param alpha defines the camera rotation along the logitudinal axis
  39138. * @param beta defines the camera rotation along the latitudinal axis
  39139. * @param radius defines the camera distance from its target
  39140. * @param target defines the camera target
  39141. * @param scene defines the scene the camera belongs to
  39142. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39143. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39144. */
  39145. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39146. /**
  39147. * Gets camera class name
  39148. * @returns VRDeviceOrientationArcRotateCamera
  39149. */
  39150. getClassName(): string;
  39151. }
  39152. }
  39153. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39154. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39155. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39156. import { Scene } from "babylonjs/scene";
  39157. import { Vector3 } from "babylonjs/Maths/math";
  39158. import "babylonjs/Cameras/RigModes/vrRigMode";
  39159. /**
  39160. * Camera used to simulate VR rendering (based on FreeCamera)
  39161. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39162. */
  39163. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39164. /**
  39165. * Creates a new VRDeviceOrientationFreeCamera
  39166. * @param name defines camera name
  39167. * @param position defines the start position of the camera
  39168. * @param scene defines the scene the camera belongs to
  39169. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39170. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39171. */
  39172. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39173. /**
  39174. * Gets camera class name
  39175. * @returns VRDeviceOrientationFreeCamera
  39176. */
  39177. getClassName(): string;
  39178. }
  39179. }
  39180. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39181. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39182. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39183. import { Scene } from "babylonjs/scene";
  39184. import { Vector3 } from "babylonjs/Maths/math";
  39185. /**
  39186. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39187. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39188. */
  39189. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39190. /**
  39191. * Creates a new VRDeviceOrientationGamepadCamera
  39192. * @param name defines camera name
  39193. * @param position defines the start position of the camera
  39194. * @param scene defines the scene the camera belongs to
  39195. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39196. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39197. */
  39198. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39199. /**
  39200. * Gets camera class name
  39201. * @returns VRDeviceOrientationGamepadCamera
  39202. */
  39203. getClassName(): string;
  39204. }
  39205. }
  39206. declare module "babylonjs/Gamepads/xboxGamepad" {
  39207. import { Observable } from "babylonjs/Misc/observable";
  39208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39209. /**
  39210. * Defines supported buttons for XBox360 compatible gamepads
  39211. */
  39212. export enum Xbox360Button {
  39213. /** A */
  39214. A = 0,
  39215. /** B */
  39216. B = 1,
  39217. /** X */
  39218. X = 2,
  39219. /** Y */
  39220. Y = 3,
  39221. /** Start */
  39222. Start = 4,
  39223. /** Back */
  39224. Back = 5,
  39225. /** Left button */
  39226. LB = 6,
  39227. /** Right button */
  39228. RB = 7,
  39229. /** Left stick */
  39230. LeftStick = 8,
  39231. /** Right stick */
  39232. RightStick = 9
  39233. }
  39234. /** Defines values for XBox360 DPad */
  39235. export enum Xbox360Dpad {
  39236. /** Up */
  39237. Up = 0,
  39238. /** Down */
  39239. Down = 1,
  39240. /** Left */
  39241. Left = 2,
  39242. /** Right */
  39243. Right = 3
  39244. }
  39245. /**
  39246. * Defines a XBox360 gamepad
  39247. */
  39248. export class Xbox360Pad extends Gamepad {
  39249. private _leftTrigger;
  39250. private _rightTrigger;
  39251. private _onlefttriggerchanged;
  39252. private _onrighttriggerchanged;
  39253. private _onbuttondown;
  39254. private _onbuttonup;
  39255. private _ondpaddown;
  39256. private _ondpadup;
  39257. /** Observable raised when a button is pressed */
  39258. onButtonDownObservable: Observable<Xbox360Button>;
  39259. /** Observable raised when a button is released */
  39260. onButtonUpObservable: Observable<Xbox360Button>;
  39261. /** Observable raised when a pad is pressed */
  39262. onPadDownObservable: Observable<Xbox360Dpad>;
  39263. /** Observable raised when a pad is released */
  39264. onPadUpObservable: Observable<Xbox360Dpad>;
  39265. private _buttonA;
  39266. private _buttonB;
  39267. private _buttonX;
  39268. private _buttonY;
  39269. private _buttonBack;
  39270. private _buttonStart;
  39271. private _buttonLB;
  39272. private _buttonRB;
  39273. private _buttonLeftStick;
  39274. private _buttonRightStick;
  39275. private _dPadUp;
  39276. private _dPadDown;
  39277. private _dPadLeft;
  39278. private _dPadRight;
  39279. private _isXboxOnePad;
  39280. /**
  39281. * Creates a new XBox360 gamepad object
  39282. * @param id defines the id of this gamepad
  39283. * @param index defines its index
  39284. * @param gamepad defines the internal HTML gamepad object
  39285. * @param xboxOne defines if it is a XBox One gamepad
  39286. */
  39287. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39288. /**
  39289. * Defines the callback to call when left trigger is pressed
  39290. * @param callback defines the callback to use
  39291. */
  39292. onlefttriggerchanged(callback: (value: number) => void): void;
  39293. /**
  39294. * Defines the callback to call when right trigger is pressed
  39295. * @param callback defines the callback to use
  39296. */
  39297. onrighttriggerchanged(callback: (value: number) => void): void;
  39298. /**
  39299. * Gets the left trigger value
  39300. */
  39301. /**
  39302. * Sets the left trigger value
  39303. */
  39304. leftTrigger: number;
  39305. /**
  39306. * Gets the right trigger value
  39307. */
  39308. /**
  39309. * Sets the right trigger value
  39310. */
  39311. rightTrigger: number;
  39312. /**
  39313. * Defines the callback to call when a button is pressed
  39314. * @param callback defines the callback to use
  39315. */
  39316. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39317. /**
  39318. * Defines the callback to call when a button is released
  39319. * @param callback defines the callback to use
  39320. */
  39321. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39322. /**
  39323. * Defines the callback to call when a pad is pressed
  39324. * @param callback defines the callback to use
  39325. */
  39326. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39327. /**
  39328. * Defines the callback to call when a pad is released
  39329. * @param callback defines the callback to use
  39330. */
  39331. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39332. private _setButtonValue;
  39333. private _setDPadValue;
  39334. /**
  39335. * Gets the value of the `A` button
  39336. */
  39337. /**
  39338. * Sets the value of the `A` button
  39339. */
  39340. buttonA: number;
  39341. /**
  39342. * Gets the value of the `B` button
  39343. */
  39344. /**
  39345. * Sets the value of the `B` button
  39346. */
  39347. buttonB: number;
  39348. /**
  39349. * Gets the value of the `X` button
  39350. */
  39351. /**
  39352. * Sets the value of the `X` button
  39353. */
  39354. buttonX: number;
  39355. /**
  39356. * Gets the value of the `Y` button
  39357. */
  39358. /**
  39359. * Sets the value of the `Y` button
  39360. */
  39361. buttonY: number;
  39362. /**
  39363. * Gets the value of the `Start` button
  39364. */
  39365. /**
  39366. * Sets the value of the `Start` button
  39367. */
  39368. buttonStart: number;
  39369. /**
  39370. * Gets the value of the `Back` button
  39371. */
  39372. /**
  39373. * Sets the value of the `Back` button
  39374. */
  39375. buttonBack: number;
  39376. /**
  39377. * Gets the value of the `Left` button
  39378. */
  39379. /**
  39380. * Sets the value of the `Left` button
  39381. */
  39382. buttonLB: number;
  39383. /**
  39384. * Gets the value of the `Right` button
  39385. */
  39386. /**
  39387. * Sets the value of the `Right` button
  39388. */
  39389. buttonRB: number;
  39390. /**
  39391. * Gets the value of the Left joystick
  39392. */
  39393. /**
  39394. * Sets the value of the Left joystick
  39395. */
  39396. buttonLeftStick: number;
  39397. /**
  39398. * Gets the value of the Right joystick
  39399. */
  39400. /**
  39401. * Sets the value of the Right joystick
  39402. */
  39403. buttonRightStick: number;
  39404. /**
  39405. * Gets the value of D-pad up
  39406. */
  39407. /**
  39408. * Sets the value of D-pad up
  39409. */
  39410. dPadUp: number;
  39411. /**
  39412. * Gets the value of D-pad down
  39413. */
  39414. /**
  39415. * Sets the value of D-pad down
  39416. */
  39417. dPadDown: number;
  39418. /**
  39419. * Gets the value of D-pad left
  39420. */
  39421. /**
  39422. * Sets the value of D-pad left
  39423. */
  39424. dPadLeft: number;
  39425. /**
  39426. * Gets the value of D-pad right
  39427. */
  39428. /**
  39429. * Sets the value of D-pad right
  39430. */
  39431. dPadRight: number;
  39432. /**
  39433. * Force the gamepad to synchronize with device values
  39434. */
  39435. update(): void;
  39436. /**
  39437. * Disposes the gamepad
  39438. */
  39439. dispose(): void;
  39440. }
  39441. }
  39442. declare module "babylonjs/Materials/pushMaterial" {
  39443. import { Nullable } from "babylonjs/types";
  39444. import { Scene } from "babylonjs/scene";
  39445. import { Matrix } from "babylonjs/Maths/math";
  39446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39447. import { Mesh } from "babylonjs/Meshes/mesh";
  39448. import { Material } from "babylonjs/Materials/material";
  39449. import { Effect } from "babylonjs/Materials/effect";
  39450. /**
  39451. * Base class of materials working in push mode in babylon JS
  39452. * @hidden
  39453. */
  39454. export class PushMaterial extends Material {
  39455. protected _activeEffect: Effect;
  39456. protected _normalMatrix: Matrix;
  39457. /**
  39458. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39459. * This means that the material can keep using a previous shader while a new one is being compiled.
  39460. * This is mostly used when shader parallel compilation is supported (true by default)
  39461. */
  39462. allowShaderHotSwapping: boolean;
  39463. constructor(name: string, scene: Scene);
  39464. getEffect(): Effect;
  39465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39466. /**
  39467. * Binds the given world matrix to the active effect
  39468. *
  39469. * @param world the matrix to bind
  39470. */
  39471. bindOnlyWorldMatrix(world: Matrix): void;
  39472. /**
  39473. * Binds the given normal matrix to the active effect
  39474. *
  39475. * @param normalMatrix the matrix to bind
  39476. */
  39477. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39478. bind(world: Matrix, mesh?: Mesh): void;
  39479. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39480. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39481. }
  39482. }
  39483. declare module "babylonjs/Materials/materialFlags" {
  39484. /**
  39485. * This groups all the flags used to control the materials channel.
  39486. */
  39487. export class MaterialFlags {
  39488. private static _DiffuseTextureEnabled;
  39489. /**
  39490. * Are diffuse textures enabled in the application.
  39491. */
  39492. static DiffuseTextureEnabled: boolean;
  39493. private static _AmbientTextureEnabled;
  39494. /**
  39495. * Are ambient textures enabled in the application.
  39496. */
  39497. static AmbientTextureEnabled: boolean;
  39498. private static _OpacityTextureEnabled;
  39499. /**
  39500. * Are opacity textures enabled in the application.
  39501. */
  39502. static OpacityTextureEnabled: boolean;
  39503. private static _ReflectionTextureEnabled;
  39504. /**
  39505. * Are reflection textures enabled in the application.
  39506. */
  39507. static ReflectionTextureEnabled: boolean;
  39508. private static _EmissiveTextureEnabled;
  39509. /**
  39510. * Are emissive textures enabled in the application.
  39511. */
  39512. static EmissiveTextureEnabled: boolean;
  39513. private static _SpecularTextureEnabled;
  39514. /**
  39515. * Are specular textures enabled in the application.
  39516. */
  39517. static SpecularTextureEnabled: boolean;
  39518. private static _BumpTextureEnabled;
  39519. /**
  39520. * Are bump textures enabled in the application.
  39521. */
  39522. static BumpTextureEnabled: boolean;
  39523. private static _LightmapTextureEnabled;
  39524. /**
  39525. * Are lightmap textures enabled in the application.
  39526. */
  39527. static LightmapTextureEnabled: boolean;
  39528. private static _RefractionTextureEnabled;
  39529. /**
  39530. * Are refraction textures enabled in the application.
  39531. */
  39532. static RefractionTextureEnabled: boolean;
  39533. private static _ColorGradingTextureEnabled;
  39534. /**
  39535. * Are color grading textures enabled in the application.
  39536. */
  39537. static ColorGradingTextureEnabled: boolean;
  39538. private static _FresnelEnabled;
  39539. /**
  39540. * Are fresnels enabled in the application.
  39541. */
  39542. static FresnelEnabled: boolean;
  39543. private static _ClearCoatTextureEnabled;
  39544. /**
  39545. * Are clear coat textures enabled in the application.
  39546. */
  39547. static ClearCoatTextureEnabled: boolean;
  39548. private static _ClearCoatBumpTextureEnabled;
  39549. /**
  39550. * Are clear coat bump textures enabled in the application.
  39551. */
  39552. static ClearCoatBumpTextureEnabled: boolean;
  39553. private static _ClearCoatTintTextureEnabled;
  39554. /**
  39555. * Are clear coat tint textures enabled in the application.
  39556. */
  39557. static ClearCoatTintTextureEnabled: boolean;
  39558. private static _SheenTextureEnabled;
  39559. /**
  39560. * Are sheen textures enabled in the application.
  39561. */
  39562. static SheenTextureEnabled: boolean;
  39563. private static _AnisotropicTextureEnabled;
  39564. /**
  39565. * Are anisotropic textures enabled in the application.
  39566. */
  39567. static AnisotropicTextureEnabled: boolean;
  39568. private static _ThicknessTextureEnabled;
  39569. /**
  39570. * Are thickness textures enabled in the application.
  39571. */
  39572. static ThicknessTextureEnabled: boolean;
  39573. }
  39574. }
  39575. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39576. /** @hidden */
  39577. export var defaultFragmentDeclaration: {
  39578. name: string;
  39579. shader: string;
  39580. };
  39581. }
  39582. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39583. /** @hidden */
  39584. export var defaultUboDeclaration: {
  39585. name: string;
  39586. shader: string;
  39587. };
  39588. }
  39589. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39590. /** @hidden */
  39591. export var lightFragmentDeclaration: {
  39592. name: string;
  39593. shader: string;
  39594. };
  39595. }
  39596. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39597. /** @hidden */
  39598. export var lightUboDeclaration: {
  39599. name: string;
  39600. shader: string;
  39601. };
  39602. }
  39603. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39604. /** @hidden */
  39605. export var lightsFragmentFunctions: {
  39606. name: string;
  39607. shader: string;
  39608. };
  39609. }
  39610. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39611. /** @hidden */
  39612. export var shadowsFragmentFunctions: {
  39613. name: string;
  39614. shader: string;
  39615. };
  39616. }
  39617. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39618. /** @hidden */
  39619. export var fresnelFunction: {
  39620. name: string;
  39621. shader: string;
  39622. };
  39623. }
  39624. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39625. /** @hidden */
  39626. export var reflectionFunction: {
  39627. name: string;
  39628. shader: string;
  39629. };
  39630. }
  39631. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39632. /** @hidden */
  39633. export var bumpFragmentFunctions: {
  39634. name: string;
  39635. shader: string;
  39636. };
  39637. }
  39638. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39639. /** @hidden */
  39640. export var logDepthDeclaration: {
  39641. name: string;
  39642. shader: string;
  39643. };
  39644. }
  39645. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39646. /** @hidden */
  39647. export var bumpFragment: {
  39648. name: string;
  39649. shader: string;
  39650. };
  39651. }
  39652. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39653. /** @hidden */
  39654. export var depthPrePass: {
  39655. name: string;
  39656. shader: string;
  39657. };
  39658. }
  39659. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39660. /** @hidden */
  39661. export var lightFragment: {
  39662. name: string;
  39663. shader: string;
  39664. };
  39665. }
  39666. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39667. /** @hidden */
  39668. export var logDepthFragment: {
  39669. name: string;
  39670. shader: string;
  39671. };
  39672. }
  39673. declare module "babylonjs/Shaders/default.fragment" {
  39674. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39675. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39676. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39679. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39680. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39681. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39682. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39683. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39684. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39685. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39687. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39689. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39690. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39691. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39692. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39693. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39694. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39695. /** @hidden */
  39696. export var defaultPixelShader: {
  39697. name: string;
  39698. shader: string;
  39699. };
  39700. }
  39701. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39702. /** @hidden */
  39703. export var defaultVertexDeclaration: {
  39704. name: string;
  39705. shader: string;
  39706. };
  39707. }
  39708. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39709. /** @hidden */
  39710. export var bumpVertexDeclaration: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39716. /** @hidden */
  39717. export var bumpVertex: {
  39718. name: string;
  39719. shader: string;
  39720. };
  39721. }
  39722. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39723. /** @hidden */
  39724. export var fogVertex: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39730. /** @hidden */
  39731. export var shadowsVertex: {
  39732. name: string;
  39733. shader: string;
  39734. };
  39735. }
  39736. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39737. /** @hidden */
  39738. export var pointCloudVertex: {
  39739. name: string;
  39740. shader: string;
  39741. };
  39742. }
  39743. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39744. /** @hidden */
  39745. export var logDepthVertex: {
  39746. name: string;
  39747. shader: string;
  39748. };
  39749. }
  39750. declare module "babylonjs/Shaders/default.vertex" {
  39751. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39752. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39754. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39755. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39756. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39757. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39758. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39759. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39760. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39763. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39767. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39769. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39770. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39771. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39772. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39773. /** @hidden */
  39774. export var defaultVertexShader: {
  39775. name: string;
  39776. shader: string;
  39777. };
  39778. }
  39779. declare module "babylonjs/Materials/standardMaterial" {
  39780. import { SmartArray } from "babylonjs/Misc/smartArray";
  39781. import { IAnimatable } from "babylonjs/Misc/tools";
  39782. import { Nullable } from "babylonjs/types";
  39783. import { Scene } from "babylonjs/scene";
  39784. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39785. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39787. import { Mesh } from "babylonjs/Meshes/mesh";
  39788. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39789. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39790. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39791. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39792. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39795. import "babylonjs/Shaders/default.fragment";
  39796. import "babylonjs/Shaders/default.vertex";
  39797. /** @hidden */
  39798. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39799. MAINUV1: boolean;
  39800. MAINUV2: boolean;
  39801. DIFFUSE: boolean;
  39802. DIFFUSEDIRECTUV: number;
  39803. AMBIENT: boolean;
  39804. AMBIENTDIRECTUV: number;
  39805. OPACITY: boolean;
  39806. OPACITYDIRECTUV: number;
  39807. OPACITYRGB: boolean;
  39808. REFLECTION: boolean;
  39809. EMISSIVE: boolean;
  39810. EMISSIVEDIRECTUV: number;
  39811. SPECULAR: boolean;
  39812. SPECULARDIRECTUV: number;
  39813. BUMP: boolean;
  39814. BUMPDIRECTUV: number;
  39815. PARALLAX: boolean;
  39816. PARALLAXOCCLUSION: boolean;
  39817. SPECULAROVERALPHA: boolean;
  39818. CLIPPLANE: boolean;
  39819. CLIPPLANE2: boolean;
  39820. CLIPPLANE3: boolean;
  39821. CLIPPLANE4: boolean;
  39822. ALPHATEST: boolean;
  39823. DEPTHPREPASS: boolean;
  39824. ALPHAFROMDIFFUSE: boolean;
  39825. POINTSIZE: boolean;
  39826. FOG: boolean;
  39827. SPECULARTERM: boolean;
  39828. DIFFUSEFRESNEL: boolean;
  39829. OPACITYFRESNEL: boolean;
  39830. REFLECTIONFRESNEL: boolean;
  39831. REFRACTIONFRESNEL: boolean;
  39832. EMISSIVEFRESNEL: boolean;
  39833. FRESNEL: boolean;
  39834. NORMAL: boolean;
  39835. UV1: boolean;
  39836. UV2: boolean;
  39837. VERTEXCOLOR: boolean;
  39838. VERTEXALPHA: boolean;
  39839. NUM_BONE_INFLUENCERS: number;
  39840. BonesPerMesh: number;
  39841. BONETEXTURE: boolean;
  39842. INSTANCES: boolean;
  39843. GLOSSINESS: boolean;
  39844. ROUGHNESS: boolean;
  39845. EMISSIVEASILLUMINATION: boolean;
  39846. LINKEMISSIVEWITHDIFFUSE: boolean;
  39847. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39848. LIGHTMAP: boolean;
  39849. LIGHTMAPDIRECTUV: number;
  39850. OBJECTSPACE_NORMALMAP: boolean;
  39851. USELIGHTMAPASSHADOWMAP: boolean;
  39852. REFLECTIONMAP_3D: boolean;
  39853. REFLECTIONMAP_SPHERICAL: boolean;
  39854. REFLECTIONMAP_PLANAR: boolean;
  39855. REFLECTIONMAP_CUBIC: boolean;
  39856. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39857. REFLECTIONMAP_PROJECTION: boolean;
  39858. REFLECTIONMAP_SKYBOX: boolean;
  39859. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39860. REFLECTIONMAP_EXPLICIT: boolean;
  39861. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39862. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39863. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39864. INVERTCUBICMAP: boolean;
  39865. LOGARITHMICDEPTH: boolean;
  39866. REFRACTION: boolean;
  39867. REFRACTIONMAP_3D: boolean;
  39868. REFLECTIONOVERALPHA: boolean;
  39869. TWOSIDEDLIGHTING: boolean;
  39870. SHADOWFLOAT: boolean;
  39871. MORPHTARGETS: boolean;
  39872. MORPHTARGETS_NORMAL: boolean;
  39873. MORPHTARGETS_TANGENT: boolean;
  39874. NUM_MORPH_INFLUENCERS: number;
  39875. NONUNIFORMSCALING: boolean;
  39876. PREMULTIPLYALPHA: boolean;
  39877. IMAGEPROCESSING: boolean;
  39878. VIGNETTE: boolean;
  39879. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39880. VIGNETTEBLENDMODEOPAQUE: boolean;
  39881. TONEMAPPING: boolean;
  39882. TONEMAPPING_ACES: boolean;
  39883. CONTRAST: boolean;
  39884. COLORCURVES: boolean;
  39885. COLORGRADING: boolean;
  39886. COLORGRADING3D: boolean;
  39887. SAMPLER3DGREENDEPTH: boolean;
  39888. SAMPLER3DBGRMAP: boolean;
  39889. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39890. MULTIVIEW: boolean;
  39891. /**
  39892. * If the reflection texture on this material is in linear color space
  39893. * @hidden
  39894. */
  39895. IS_REFLECTION_LINEAR: boolean;
  39896. /**
  39897. * If the refraction texture on this material is in linear color space
  39898. * @hidden
  39899. */
  39900. IS_REFRACTION_LINEAR: boolean;
  39901. EXPOSURE: boolean;
  39902. constructor();
  39903. setReflectionMode(modeToEnable: string): void;
  39904. }
  39905. /**
  39906. * This is the default material used in Babylon. It is the best trade off between quality
  39907. * and performances.
  39908. * @see http://doc.babylonjs.com/babylon101/materials
  39909. */
  39910. export class StandardMaterial extends PushMaterial {
  39911. private _diffuseTexture;
  39912. /**
  39913. * The basic texture of the material as viewed under a light.
  39914. */
  39915. diffuseTexture: Nullable<BaseTexture>;
  39916. private _ambientTexture;
  39917. /**
  39918. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39919. */
  39920. ambientTexture: Nullable<BaseTexture>;
  39921. private _opacityTexture;
  39922. /**
  39923. * Define the transparency of the material from a texture.
  39924. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39925. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39926. */
  39927. opacityTexture: Nullable<BaseTexture>;
  39928. private _reflectionTexture;
  39929. /**
  39930. * Define the texture used to display the reflection.
  39931. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39932. */
  39933. reflectionTexture: Nullable<BaseTexture>;
  39934. private _emissiveTexture;
  39935. /**
  39936. * Define texture of the material as if self lit.
  39937. * This will be mixed in the final result even in the absence of light.
  39938. */
  39939. emissiveTexture: Nullable<BaseTexture>;
  39940. private _specularTexture;
  39941. /**
  39942. * Define how the color and intensity of the highlight given by the light in the material.
  39943. */
  39944. specularTexture: Nullable<BaseTexture>;
  39945. private _bumpTexture;
  39946. /**
  39947. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39948. * 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.
  39949. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39950. */
  39951. bumpTexture: Nullable<BaseTexture>;
  39952. private _lightmapTexture;
  39953. /**
  39954. * Complex lighting can be computationally expensive to compute at runtime.
  39955. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39956. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39957. */
  39958. lightmapTexture: Nullable<BaseTexture>;
  39959. private _refractionTexture;
  39960. /**
  39961. * Define the texture used to display the refraction.
  39962. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39963. */
  39964. refractionTexture: Nullable<BaseTexture>;
  39965. /**
  39966. * The color of the material lit by the environmental background lighting.
  39967. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39968. */
  39969. ambientColor: Color3;
  39970. /**
  39971. * The basic color of the material as viewed under a light.
  39972. */
  39973. diffuseColor: Color3;
  39974. /**
  39975. * Define how the color and intensity of the highlight given by the light in the material.
  39976. */
  39977. specularColor: Color3;
  39978. /**
  39979. * Define the color of the material as if self lit.
  39980. * This will be mixed in the final result even in the absence of light.
  39981. */
  39982. emissiveColor: Color3;
  39983. /**
  39984. * Defines how sharp are the highlights in the material.
  39985. * The bigger the value the sharper giving a more glossy feeling to the result.
  39986. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39987. */
  39988. specularPower: number;
  39989. private _useAlphaFromDiffuseTexture;
  39990. /**
  39991. * Does the transparency come from the diffuse texture alpha channel.
  39992. */
  39993. useAlphaFromDiffuseTexture: boolean;
  39994. private _useEmissiveAsIllumination;
  39995. /**
  39996. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39997. */
  39998. useEmissiveAsIllumination: boolean;
  39999. private _linkEmissiveWithDiffuse;
  40000. /**
  40001. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40002. * the emissive level when the final color is close to one.
  40003. */
  40004. linkEmissiveWithDiffuse: boolean;
  40005. private _useSpecularOverAlpha;
  40006. /**
  40007. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40008. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40009. */
  40010. useSpecularOverAlpha: boolean;
  40011. private _useReflectionOverAlpha;
  40012. /**
  40013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40015. */
  40016. useReflectionOverAlpha: boolean;
  40017. private _disableLighting;
  40018. /**
  40019. * Does lights from the scene impacts this material.
  40020. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40021. */
  40022. disableLighting: boolean;
  40023. private _useObjectSpaceNormalMap;
  40024. /**
  40025. * Allows using an object space normal map (instead of tangent space).
  40026. */
  40027. useObjectSpaceNormalMap: boolean;
  40028. private _useParallax;
  40029. /**
  40030. * Is parallax enabled or not.
  40031. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40032. */
  40033. useParallax: boolean;
  40034. private _useParallaxOcclusion;
  40035. /**
  40036. * Is parallax occlusion enabled or not.
  40037. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40038. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40039. */
  40040. useParallaxOcclusion: boolean;
  40041. /**
  40042. * 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.
  40043. */
  40044. parallaxScaleBias: number;
  40045. private _roughness;
  40046. /**
  40047. * Helps to define how blurry the reflections should appears in the material.
  40048. */
  40049. roughness: number;
  40050. /**
  40051. * In case of refraction, define the value of the indice of refraction.
  40052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40053. */
  40054. indexOfRefraction: number;
  40055. /**
  40056. * Invert the refraction texture alongside the y axis.
  40057. * It can be useful with procedural textures or probe for instance.
  40058. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40059. */
  40060. invertRefractionY: boolean;
  40061. /**
  40062. * Defines the alpha limits in alpha test mode.
  40063. */
  40064. alphaCutOff: number;
  40065. private _useLightmapAsShadowmap;
  40066. /**
  40067. * In case of light mapping, define whether the map contains light or shadow informations.
  40068. */
  40069. useLightmapAsShadowmap: boolean;
  40070. private _diffuseFresnelParameters;
  40071. /**
  40072. * Define the diffuse fresnel parameters of the material.
  40073. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40074. */
  40075. diffuseFresnelParameters: FresnelParameters;
  40076. private _opacityFresnelParameters;
  40077. /**
  40078. * Define the opacity fresnel parameters of the material.
  40079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40080. */
  40081. opacityFresnelParameters: FresnelParameters;
  40082. private _reflectionFresnelParameters;
  40083. /**
  40084. * Define the reflection fresnel parameters of the material.
  40085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40086. */
  40087. reflectionFresnelParameters: FresnelParameters;
  40088. private _refractionFresnelParameters;
  40089. /**
  40090. * Define the refraction fresnel parameters of the material.
  40091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40092. */
  40093. refractionFresnelParameters: FresnelParameters;
  40094. private _emissiveFresnelParameters;
  40095. /**
  40096. * Define the emissive fresnel parameters of the material.
  40097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40098. */
  40099. emissiveFresnelParameters: FresnelParameters;
  40100. private _useReflectionFresnelFromSpecular;
  40101. /**
  40102. * If true automatically deducts the fresnels values from the material specularity.
  40103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40104. */
  40105. useReflectionFresnelFromSpecular: boolean;
  40106. private _useGlossinessFromSpecularMapAlpha;
  40107. /**
  40108. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40109. */
  40110. useGlossinessFromSpecularMapAlpha: boolean;
  40111. private _maxSimultaneousLights;
  40112. /**
  40113. * Defines the maximum number of lights that can be used in the material
  40114. */
  40115. maxSimultaneousLights: number;
  40116. private _invertNormalMapX;
  40117. /**
  40118. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40119. */
  40120. invertNormalMapX: boolean;
  40121. private _invertNormalMapY;
  40122. /**
  40123. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40124. */
  40125. invertNormalMapY: boolean;
  40126. private _twoSidedLighting;
  40127. /**
  40128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40129. */
  40130. twoSidedLighting: boolean;
  40131. /**
  40132. * Default configuration related to image processing available in the standard Material.
  40133. */
  40134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40135. /**
  40136. * Gets the image processing configuration used either in this material.
  40137. */
  40138. /**
  40139. * Sets the Default image processing configuration used either in the this material.
  40140. *
  40141. * If sets to null, the scene one is in use.
  40142. */
  40143. imageProcessingConfiguration: ImageProcessingConfiguration;
  40144. /**
  40145. * Keep track of the image processing observer to allow dispose and replace.
  40146. */
  40147. private _imageProcessingObserver;
  40148. /**
  40149. * Attaches a new image processing configuration to the Standard Material.
  40150. * @param configuration
  40151. */
  40152. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40153. /**
  40154. * Gets wether the color curves effect is enabled.
  40155. */
  40156. /**
  40157. * Sets wether the color curves effect is enabled.
  40158. */
  40159. cameraColorCurvesEnabled: boolean;
  40160. /**
  40161. * Gets wether the color grading effect is enabled.
  40162. */
  40163. /**
  40164. * Gets wether the color grading effect is enabled.
  40165. */
  40166. cameraColorGradingEnabled: boolean;
  40167. /**
  40168. * Gets wether tonemapping is enabled or not.
  40169. */
  40170. /**
  40171. * Sets wether tonemapping is enabled or not
  40172. */
  40173. cameraToneMappingEnabled: boolean;
  40174. /**
  40175. * The camera exposure used on this material.
  40176. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40177. * This corresponds to a photographic exposure.
  40178. */
  40179. /**
  40180. * The camera exposure used on this material.
  40181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40182. * This corresponds to a photographic exposure.
  40183. */
  40184. cameraExposure: number;
  40185. /**
  40186. * Gets The camera contrast used on this material.
  40187. */
  40188. /**
  40189. * Sets The camera contrast used on this material.
  40190. */
  40191. cameraContrast: number;
  40192. /**
  40193. * Gets the Color Grading 2D Lookup Texture.
  40194. */
  40195. /**
  40196. * Sets the Color Grading 2D Lookup Texture.
  40197. */
  40198. cameraColorGradingTexture: Nullable<BaseTexture>;
  40199. /**
  40200. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40201. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40202. * 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;
  40203. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40204. */
  40205. /**
  40206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40208. * 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;
  40209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40210. */
  40211. cameraColorCurves: Nullable<ColorCurves>;
  40212. /**
  40213. * Custom callback helping to override the default shader used in the material.
  40214. */
  40215. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40216. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40217. protected _worldViewProjectionMatrix: Matrix;
  40218. protected _globalAmbientColor: Color3;
  40219. protected _useLogarithmicDepth: boolean;
  40220. /**
  40221. * Instantiates a new standard material.
  40222. * This is the default material used in Babylon. It is the best trade off between quality
  40223. * and performances.
  40224. * @see http://doc.babylonjs.com/babylon101/materials
  40225. * @param name Define the name of the material in the scene
  40226. * @param scene Define the scene the material belong to
  40227. */
  40228. constructor(name: string, scene: Scene);
  40229. /**
  40230. * Gets a boolean indicating that current material needs to register RTT
  40231. */
  40232. readonly hasRenderTargetTextures: boolean;
  40233. /**
  40234. * Gets the current class name of the material e.g. "StandardMaterial"
  40235. * Mainly use in serialization.
  40236. * @returns the class name
  40237. */
  40238. getClassName(): string;
  40239. /**
  40240. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40241. * You can try switching to logarithmic depth.
  40242. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40243. */
  40244. useLogarithmicDepth: boolean;
  40245. /**
  40246. * Specifies if the material will require alpha blending
  40247. * @returns a boolean specifying if alpha blending is needed
  40248. */
  40249. needAlphaBlending(): boolean;
  40250. /**
  40251. * Specifies if this material should be rendered in alpha test mode
  40252. * @returns a boolean specifying if an alpha test is needed.
  40253. */
  40254. needAlphaTesting(): boolean;
  40255. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40256. /**
  40257. * Get the texture used for alpha test purpose.
  40258. * @returns the diffuse texture in case of the standard material.
  40259. */
  40260. getAlphaTestTexture(): Nullable<BaseTexture>;
  40261. /**
  40262. * Get if the submesh is ready to be used and all its information available.
  40263. * Child classes can use it to update shaders
  40264. * @param mesh defines the mesh to check
  40265. * @param subMesh defines which submesh to check
  40266. * @param useInstances specifies that instances should be used
  40267. * @returns a boolean indicating that the submesh is ready or not
  40268. */
  40269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40270. /**
  40271. * Builds the material UBO layouts.
  40272. * Used internally during the effect preparation.
  40273. */
  40274. buildUniformLayout(): void;
  40275. /**
  40276. * Unbinds the material from the mesh
  40277. */
  40278. unbind(): void;
  40279. /**
  40280. * Binds the submesh to this material by preparing the effect and shader to draw
  40281. * @param world defines the world transformation matrix
  40282. * @param mesh defines the mesh containing the submesh
  40283. * @param subMesh defines the submesh to bind the material to
  40284. */
  40285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40286. /**
  40287. * Get the list of animatables in the material.
  40288. * @returns the list of animatables object used in the material
  40289. */
  40290. getAnimatables(): IAnimatable[];
  40291. /**
  40292. * Gets the active textures from the material
  40293. * @returns an array of textures
  40294. */
  40295. getActiveTextures(): BaseTexture[];
  40296. /**
  40297. * Specifies if the material uses a texture
  40298. * @param texture defines the texture to check against the material
  40299. * @returns a boolean specifying if the material uses the texture
  40300. */
  40301. hasTexture(texture: BaseTexture): boolean;
  40302. /**
  40303. * Disposes the material
  40304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40306. */
  40307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40308. /**
  40309. * Makes a duplicate of the material, and gives it a new name
  40310. * @param name defines the new name for the duplicated material
  40311. * @returns the cloned material
  40312. */
  40313. clone(name: string): StandardMaterial;
  40314. /**
  40315. * Serializes this material in a JSON representation
  40316. * @returns the serialized material object
  40317. */
  40318. serialize(): any;
  40319. /**
  40320. * Creates a standard material from parsed material data
  40321. * @param source defines the JSON representation of the material
  40322. * @param scene defines the hosting scene
  40323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40324. * @returns a new standard material
  40325. */
  40326. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40327. /**
  40328. * Are diffuse textures enabled in the application.
  40329. */
  40330. static DiffuseTextureEnabled: boolean;
  40331. /**
  40332. * Are ambient textures enabled in the application.
  40333. */
  40334. static AmbientTextureEnabled: boolean;
  40335. /**
  40336. * Are opacity textures enabled in the application.
  40337. */
  40338. static OpacityTextureEnabled: boolean;
  40339. /**
  40340. * Are reflection textures enabled in the application.
  40341. */
  40342. static ReflectionTextureEnabled: boolean;
  40343. /**
  40344. * Are emissive textures enabled in the application.
  40345. */
  40346. static EmissiveTextureEnabled: boolean;
  40347. /**
  40348. * Are specular textures enabled in the application.
  40349. */
  40350. static SpecularTextureEnabled: boolean;
  40351. /**
  40352. * Are bump textures enabled in the application.
  40353. */
  40354. static BumpTextureEnabled: boolean;
  40355. /**
  40356. * Are lightmap textures enabled in the application.
  40357. */
  40358. static LightmapTextureEnabled: boolean;
  40359. /**
  40360. * Are refraction textures enabled in the application.
  40361. */
  40362. static RefractionTextureEnabled: boolean;
  40363. /**
  40364. * Are color grading textures enabled in the application.
  40365. */
  40366. static ColorGradingTextureEnabled: boolean;
  40367. /**
  40368. * Are fresnels enabled in the application.
  40369. */
  40370. static FresnelEnabled: boolean;
  40371. }
  40372. }
  40373. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40374. import { Scene } from "babylonjs/scene";
  40375. import { Texture } from "babylonjs/Materials/Textures/texture";
  40376. /**
  40377. * A class extending Texture allowing drawing on a texture
  40378. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40379. */
  40380. export class DynamicTexture extends Texture {
  40381. private _generateMipMaps;
  40382. private _canvas;
  40383. private _context;
  40384. private _engine;
  40385. /**
  40386. * Creates a DynamicTexture
  40387. * @param name defines the name of the texture
  40388. * @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
  40389. * @param scene defines the scene where you want the texture
  40390. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40391. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40392. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40393. */
  40394. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40395. /**
  40396. * Get the current class name of the texture useful for serialization or dynamic coding.
  40397. * @returns "DynamicTexture"
  40398. */
  40399. getClassName(): string;
  40400. /**
  40401. * Gets the current state of canRescale
  40402. */
  40403. readonly canRescale: boolean;
  40404. private _recreate;
  40405. /**
  40406. * Scales the texture
  40407. * @param ratio the scale factor to apply to both width and height
  40408. */
  40409. scale(ratio: number): void;
  40410. /**
  40411. * Resizes the texture
  40412. * @param width the new width
  40413. * @param height the new height
  40414. */
  40415. scaleTo(width: number, height: number): void;
  40416. /**
  40417. * Gets the context of the canvas used by the texture
  40418. * @returns the canvas context of the dynamic texture
  40419. */
  40420. getContext(): CanvasRenderingContext2D;
  40421. /**
  40422. * Clears the texture
  40423. */
  40424. clear(): void;
  40425. /**
  40426. * Updates the texture
  40427. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40428. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40429. */
  40430. update(invertY?: boolean, premulAlpha?: boolean): void;
  40431. /**
  40432. * Draws text onto the texture
  40433. * @param text defines the text to be drawn
  40434. * @param x defines the placement of the text from the left
  40435. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40436. * @param font defines the font to be used with font-style, font-size, font-name
  40437. * @param color defines the color used for the text
  40438. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40439. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40440. * @param update defines whether texture is immediately update (default is true)
  40441. */
  40442. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40443. /**
  40444. * Clones the texture
  40445. * @returns the clone of the texture.
  40446. */
  40447. clone(): DynamicTexture;
  40448. /**
  40449. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40450. * @returns a serialized dynamic texture object
  40451. */
  40452. serialize(): any;
  40453. /** @hidden */
  40454. _rebuild(): void;
  40455. }
  40456. }
  40457. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40458. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40459. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40460. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40461. /** @hidden */
  40462. export var imageProcessingPixelShader: {
  40463. name: string;
  40464. shader: string;
  40465. };
  40466. }
  40467. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40468. import { Nullable } from "babylonjs/types";
  40469. import { Color4 } from "babylonjs/Maths/math";
  40470. import { Camera } from "babylonjs/Cameras/camera";
  40471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40472. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40473. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40475. import { Engine } from "babylonjs/Engines/engine";
  40476. import "babylonjs/Shaders/imageProcessing.fragment";
  40477. import "babylonjs/Shaders/postprocess.vertex";
  40478. /**
  40479. * ImageProcessingPostProcess
  40480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40481. */
  40482. export class ImageProcessingPostProcess extends PostProcess {
  40483. /**
  40484. * Default configuration related to image processing available in the PBR Material.
  40485. */
  40486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40487. /**
  40488. * Gets the image processing configuration used either in this material.
  40489. */
  40490. /**
  40491. * Sets the Default image processing configuration used either in the this material.
  40492. *
  40493. * If sets to null, the scene one is in use.
  40494. */
  40495. imageProcessingConfiguration: ImageProcessingConfiguration;
  40496. /**
  40497. * Keep track of the image processing observer to allow dispose and replace.
  40498. */
  40499. private _imageProcessingObserver;
  40500. /**
  40501. * Attaches a new image processing configuration to the PBR Material.
  40502. * @param configuration
  40503. */
  40504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40505. /**
  40506. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40507. */
  40508. /**
  40509. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40510. */
  40511. colorCurves: Nullable<ColorCurves>;
  40512. /**
  40513. * Gets wether the color curves effect is enabled.
  40514. */
  40515. /**
  40516. * Sets wether the color curves effect is enabled.
  40517. */
  40518. colorCurvesEnabled: boolean;
  40519. /**
  40520. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40521. */
  40522. /**
  40523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40524. */
  40525. colorGradingTexture: Nullable<BaseTexture>;
  40526. /**
  40527. * Gets wether the color grading effect is enabled.
  40528. */
  40529. /**
  40530. * Gets wether the color grading effect is enabled.
  40531. */
  40532. colorGradingEnabled: boolean;
  40533. /**
  40534. * Gets exposure used in the effect.
  40535. */
  40536. /**
  40537. * Sets exposure used in the effect.
  40538. */
  40539. exposure: number;
  40540. /**
  40541. * Gets wether tonemapping is enabled or not.
  40542. */
  40543. /**
  40544. * Sets wether tonemapping is enabled or not
  40545. */
  40546. toneMappingEnabled: boolean;
  40547. /**
  40548. * Gets the type of tone mapping effect.
  40549. */
  40550. /**
  40551. * Sets the type of tone mapping effect.
  40552. */
  40553. toneMappingType: number;
  40554. /**
  40555. * Gets contrast used in the effect.
  40556. */
  40557. /**
  40558. * Sets contrast used in the effect.
  40559. */
  40560. contrast: number;
  40561. /**
  40562. * Gets Vignette stretch size.
  40563. */
  40564. /**
  40565. * Sets Vignette stretch size.
  40566. */
  40567. vignetteStretch: number;
  40568. /**
  40569. * Gets Vignette centre X Offset.
  40570. */
  40571. /**
  40572. * Sets Vignette centre X Offset.
  40573. */
  40574. vignetteCentreX: number;
  40575. /**
  40576. * Gets Vignette centre Y Offset.
  40577. */
  40578. /**
  40579. * Sets Vignette centre Y Offset.
  40580. */
  40581. vignetteCentreY: number;
  40582. /**
  40583. * Gets Vignette weight or intensity of the vignette effect.
  40584. */
  40585. /**
  40586. * Sets Vignette weight or intensity of the vignette effect.
  40587. */
  40588. vignetteWeight: number;
  40589. /**
  40590. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40591. * if vignetteEnabled is set to true.
  40592. */
  40593. /**
  40594. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40595. * if vignetteEnabled is set to true.
  40596. */
  40597. vignetteColor: Color4;
  40598. /**
  40599. * Gets Camera field of view used by the Vignette effect.
  40600. */
  40601. /**
  40602. * Sets Camera field of view used by the Vignette effect.
  40603. */
  40604. vignetteCameraFov: number;
  40605. /**
  40606. * Gets the vignette blend mode allowing different kind of effect.
  40607. */
  40608. /**
  40609. * Sets the vignette blend mode allowing different kind of effect.
  40610. */
  40611. vignetteBlendMode: number;
  40612. /**
  40613. * Gets wether the vignette effect is enabled.
  40614. */
  40615. /**
  40616. * Sets wether the vignette effect is enabled.
  40617. */
  40618. vignetteEnabled: boolean;
  40619. private _fromLinearSpace;
  40620. /**
  40621. * Gets wether the input of the processing is in Gamma or Linear Space.
  40622. */
  40623. /**
  40624. * Sets wether the input of the processing is in Gamma or Linear Space.
  40625. */
  40626. fromLinearSpace: boolean;
  40627. /**
  40628. * Defines cache preventing GC.
  40629. */
  40630. private _defines;
  40631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40632. /**
  40633. * "ImageProcessingPostProcess"
  40634. * @returns "ImageProcessingPostProcess"
  40635. */
  40636. getClassName(): string;
  40637. protected _updateParameters(): void;
  40638. dispose(camera?: Camera): void;
  40639. }
  40640. }
  40641. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40642. import { Scene } from "babylonjs/scene";
  40643. import { Color3 } from "babylonjs/Maths/math";
  40644. import { Mesh } from "babylonjs/Meshes/mesh";
  40645. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40646. import { Nullable } from "babylonjs/types";
  40647. /**
  40648. * Class containing static functions to help procedurally build meshes
  40649. */
  40650. export class GroundBuilder {
  40651. /**
  40652. * Creates a ground mesh
  40653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40656. * @param name defines the name of the mesh
  40657. * @param options defines the options used to create the mesh
  40658. * @param scene defines the hosting scene
  40659. * @returns the ground mesh
  40660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40661. */
  40662. static CreateGround(name: string, options: {
  40663. width?: number;
  40664. height?: number;
  40665. subdivisions?: number;
  40666. subdivisionsX?: number;
  40667. subdivisionsY?: number;
  40668. updatable?: boolean;
  40669. }, scene: any): Mesh;
  40670. /**
  40671. * Creates a tiled ground mesh
  40672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40674. * * 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
  40675. * * 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
  40676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40677. * @param name defines the name of the mesh
  40678. * @param options defines the options used to create the mesh
  40679. * @param scene defines the hosting scene
  40680. * @returns the tiled ground mesh
  40681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40682. */
  40683. static CreateTiledGround(name: string, options: {
  40684. xmin: number;
  40685. zmin: number;
  40686. xmax: number;
  40687. zmax: number;
  40688. subdivisions?: {
  40689. w: number;
  40690. h: number;
  40691. };
  40692. precision?: {
  40693. w: number;
  40694. h: number;
  40695. };
  40696. updatable?: boolean;
  40697. }, scene?: Nullable<Scene>): Mesh;
  40698. /**
  40699. * Creates a ground mesh from a height map
  40700. * * The parameter `url` sets the URL of the height map image resource.
  40701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40705. * * 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.
  40706. * * 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).
  40707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40709. * @param name defines the name of the mesh
  40710. * @param url defines the url to the height map
  40711. * @param options defines the options used to create the mesh
  40712. * @param scene defines the hosting scene
  40713. * @returns the ground mesh
  40714. * @see https://doc.babylonjs.com/babylon101/height_map
  40715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40716. */
  40717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40718. width?: number;
  40719. height?: number;
  40720. subdivisions?: number;
  40721. minHeight?: number;
  40722. maxHeight?: number;
  40723. colorFilter?: Color3;
  40724. alphaFilter?: number;
  40725. updatable?: boolean;
  40726. onReady?: (mesh: GroundMesh) => void;
  40727. }, scene?: Nullable<Scene>): GroundMesh;
  40728. }
  40729. }
  40730. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40731. import { Vector4 } from "babylonjs/Maths/math";
  40732. import { Mesh } from "babylonjs/Meshes/mesh";
  40733. /**
  40734. * Class containing static functions to help procedurally build meshes
  40735. */
  40736. export class TorusBuilder {
  40737. /**
  40738. * Creates a torus mesh
  40739. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40740. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40741. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40745. * @param name defines the name of the mesh
  40746. * @param options defines the options used to create the mesh
  40747. * @param scene defines the hosting scene
  40748. * @returns the torus mesh
  40749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40750. */
  40751. static CreateTorus(name: string, options: {
  40752. diameter?: number;
  40753. thickness?: number;
  40754. tessellation?: number;
  40755. updatable?: boolean;
  40756. sideOrientation?: number;
  40757. frontUVs?: Vector4;
  40758. backUVs?: Vector4;
  40759. }, scene: any): Mesh;
  40760. }
  40761. }
  40762. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40763. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40764. import { Mesh } from "babylonjs/Meshes/mesh";
  40765. /**
  40766. * Class containing static functions to help procedurally build meshes
  40767. */
  40768. export class CylinderBuilder {
  40769. /**
  40770. * Creates a cylinder or a cone mesh
  40771. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40772. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40773. * * 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.
  40774. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40775. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40776. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40777. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40778. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40779. * * 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).
  40780. * * 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
  40781. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40782. * * 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
  40783. * * 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.
  40784. * * If `enclose` is false, a ring surface is one element.
  40785. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40786. * * 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
  40787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40790. * @param name defines the name of the mesh
  40791. * @param options defines the options used to create the mesh
  40792. * @param scene defines the hosting scene
  40793. * @returns the cylinder mesh
  40794. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40795. */
  40796. static CreateCylinder(name: string, options: {
  40797. height?: number;
  40798. diameterTop?: number;
  40799. diameterBottom?: number;
  40800. diameter?: number;
  40801. tessellation?: number;
  40802. subdivisions?: number;
  40803. arc?: number;
  40804. faceColors?: Color4[];
  40805. faceUV?: Vector4[];
  40806. updatable?: boolean;
  40807. hasRings?: boolean;
  40808. enclose?: boolean;
  40809. sideOrientation?: number;
  40810. frontUVs?: Vector4;
  40811. backUVs?: Vector4;
  40812. }, scene: any): Mesh;
  40813. }
  40814. }
  40815. declare module "babylonjs/Gamepads/gamepadManager" {
  40816. import { Observable } from "babylonjs/Misc/observable";
  40817. import { Nullable } from "babylonjs/types";
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40820. /**
  40821. * Manager for handling gamepads
  40822. */
  40823. export class GamepadManager {
  40824. private _scene?;
  40825. private _babylonGamepads;
  40826. private _oneGamepadConnected;
  40827. /** @hidden */
  40828. _isMonitoring: boolean;
  40829. private _gamepadEventSupported;
  40830. private _gamepadSupport;
  40831. /**
  40832. * observable to be triggered when the gamepad controller has been connected
  40833. */
  40834. onGamepadConnectedObservable: Observable<Gamepad>;
  40835. /**
  40836. * observable to be triggered when the gamepad controller has been disconnected
  40837. */
  40838. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40839. private _onGamepadConnectedEvent;
  40840. private _onGamepadDisconnectedEvent;
  40841. /**
  40842. * Initializes the gamepad manager
  40843. * @param _scene BabylonJS scene
  40844. */
  40845. constructor(_scene?: Scene | undefined);
  40846. /**
  40847. * The gamepads in the game pad manager
  40848. */
  40849. readonly gamepads: Gamepad[];
  40850. /**
  40851. * Get the gamepad controllers based on type
  40852. * @param type The type of gamepad controller
  40853. * @returns Nullable gamepad
  40854. */
  40855. getGamepadByType(type?: number): Nullable<Gamepad>;
  40856. /**
  40857. * Disposes the gamepad manager
  40858. */
  40859. dispose(): void;
  40860. private _addNewGamepad;
  40861. private _startMonitoringGamepads;
  40862. private _stopMonitoringGamepads;
  40863. /** @hidden */
  40864. _checkGamepadsStatus(): void;
  40865. private _updateGamepadObjects;
  40866. }
  40867. }
  40868. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40869. import { Nullable } from "babylonjs/types";
  40870. import { Scene } from "babylonjs/scene";
  40871. import { ISceneComponent } from "babylonjs/sceneComponent";
  40872. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40873. module "babylonjs/scene" {
  40874. interface Scene {
  40875. /** @hidden */
  40876. _gamepadManager: Nullable<GamepadManager>;
  40877. /**
  40878. * Gets the gamepad manager associated with the scene
  40879. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40880. */
  40881. gamepadManager: GamepadManager;
  40882. }
  40883. }
  40884. module "babylonjs/Cameras/freeCameraInputsManager" {
  40885. /**
  40886. * Interface representing a free camera inputs manager
  40887. */
  40888. interface FreeCameraInputsManager {
  40889. /**
  40890. * Adds gamepad input support to the FreeCameraInputsManager.
  40891. * @returns the FreeCameraInputsManager
  40892. */
  40893. addGamepad(): FreeCameraInputsManager;
  40894. }
  40895. }
  40896. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40897. /**
  40898. * Interface representing an arc rotate camera inputs manager
  40899. */
  40900. interface ArcRotateCameraInputsManager {
  40901. /**
  40902. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40903. * @returns the camera inputs manager
  40904. */
  40905. addGamepad(): ArcRotateCameraInputsManager;
  40906. }
  40907. }
  40908. /**
  40909. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40910. */
  40911. export class GamepadSystemSceneComponent implements ISceneComponent {
  40912. /**
  40913. * The component name helpfull to identify the component in the list of scene components.
  40914. */
  40915. readonly name: string;
  40916. /**
  40917. * The scene the component belongs to.
  40918. */
  40919. scene: Scene;
  40920. /**
  40921. * Creates a new instance of the component for the given scene
  40922. * @param scene Defines the scene to register the component in
  40923. */
  40924. constructor(scene: Scene);
  40925. /**
  40926. * Registers the component in a given scene
  40927. */
  40928. register(): void;
  40929. /**
  40930. * Rebuilds the elements related to this component in case of
  40931. * context lost for instance.
  40932. */
  40933. rebuild(): void;
  40934. /**
  40935. * Disposes the component and the associated ressources
  40936. */
  40937. dispose(): void;
  40938. private _beforeCameraUpdate;
  40939. }
  40940. }
  40941. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40942. import { Observable } from "babylonjs/Misc/observable";
  40943. import { Nullable } from "babylonjs/types";
  40944. import { Camera } from "babylonjs/Cameras/camera";
  40945. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40946. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40947. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40948. import { Scene } from "babylonjs/scene";
  40949. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40952. import { Mesh } from "babylonjs/Meshes/mesh";
  40953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40954. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40955. import "babylonjs/Meshes/Builders/groundBuilder";
  40956. import "babylonjs/Meshes/Builders/torusBuilder";
  40957. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40958. import "babylonjs/Gamepads/gamepadSceneComponent";
  40959. import "babylonjs/Animations/animatable";
  40960. /**
  40961. * Options to modify the vr teleportation behavior.
  40962. */
  40963. export interface VRTeleportationOptions {
  40964. /**
  40965. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40966. */
  40967. floorMeshName?: string;
  40968. /**
  40969. * A list of meshes to be used as the teleportation floor. (default: empty)
  40970. */
  40971. floorMeshes?: Mesh[];
  40972. }
  40973. /**
  40974. * Options to modify the vr experience helper's behavior.
  40975. */
  40976. export interface VRExperienceHelperOptions extends WebVROptions {
  40977. /**
  40978. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40979. */
  40980. createDeviceOrientationCamera?: boolean;
  40981. /**
  40982. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40983. */
  40984. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40985. /**
  40986. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40987. */
  40988. laserToggle?: boolean;
  40989. /**
  40990. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40991. */
  40992. floorMeshes?: Mesh[];
  40993. /**
  40994. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40995. */
  40996. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40997. }
  40998. /**
  40999. * Event containing information after VR has been entered
  41000. */
  41001. export class OnAfterEnteringVRObservableEvent {
  41002. /**
  41003. * If entering vr was successful
  41004. */
  41005. success: boolean;
  41006. }
  41007. /**
  41008. * Helps to quickly add VR support to an existing scene.
  41009. * See http://doc.babylonjs.com/how_to/webvr_helper
  41010. */
  41011. export class VRExperienceHelper {
  41012. /** Options to modify the vr experience helper's behavior. */
  41013. webVROptions: VRExperienceHelperOptions;
  41014. private _scene;
  41015. private _position;
  41016. private _btnVR;
  41017. private _btnVRDisplayed;
  41018. private _webVRsupported;
  41019. private _webVRready;
  41020. private _webVRrequesting;
  41021. private _webVRpresenting;
  41022. private _hasEnteredVR;
  41023. private _fullscreenVRpresenting;
  41024. private _canvas;
  41025. private _webVRCamera;
  41026. private _vrDeviceOrientationCamera;
  41027. private _deviceOrientationCamera;
  41028. private _existingCamera;
  41029. private _onKeyDown;
  41030. private _onVrDisplayPresentChange;
  41031. private _onVRDisplayChanged;
  41032. private _onVRRequestPresentStart;
  41033. private _onVRRequestPresentComplete;
  41034. /**
  41035. * Observable raised right before entering VR.
  41036. */
  41037. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41038. /**
  41039. * Observable raised when entering VR has completed.
  41040. */
  41041. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41042. /**
  41043. * Observable raised when exiting VR.
  41044. */
  41045. onExitingVRObservable: Observable<VRExperienceHelper>;
  41046. /**
  41047. * Observable raised when controller mesh is loaded.
  41048. */
  41049. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41050. /** Return this.onEnteringVRObservable
  41051. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41052. */
  41053. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41054. /** Return this.onExitingVRObservable
  41055. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41056. */
  41057. readonly onExitingVR: Observable<VRExperienceHelper>;
  41058. /** Return this.onControllerMeshLoadedObservable
  41059. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41060. */
  41061. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41062. private _rayLength;
  41063. private _useCustomVRButton;
  41064. private _teleportationRequested;
  41065. private _teleportActive;
  41066. private _floorMeshName;
  41067. private _floorMeshesCollection;
  41068. private _rotationAllowed;
  41069. private _teleportBackwardsVector;
  41070. private _teleportationTarget;
  41071. private _isDefaultTeleportationTarget;
  41072. private _postProcessMove;
  41073. private _teleportationFillColor;
  41074. private _teleportationBorderColor;
  41075. private _rotationAngle;
  41076. private _haloCenter;
  41077. private _cameraGazer;
  41078. private _padSensibilityUp;
  41079. private _padSensibilityDown;
  41080. private _leftController;
  41081. private _rightController;
  41082. /**
  41083. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41084. */
  41085. onNewMeshSelected: Observable<AbstractMesh>;
  41086. /**
  41087. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41088. */
  41089. onNewMeshPicked: Observable<PickingInfo>;
  41090. private _circleEase;
  41091. /**
  41092. * Observable raised before camera teleportation
  41093. */
  41094. onBeforeCameraTeleport: Observable<Vector3>;
  41095. /**
  41096. * Observable raised after camera teleportation
  41097. */
  41098. onAfterCameraTeleport: Observable<Vector3>;
  41099. /**
  41100. * Observable raised when current selected mesh gets unselected
  41101. */
  41102. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41103. private _raySelectionPredicate;
  41104. /**
  41105. * To be optionaly changed by user to define custom ray selection
  41106. */
  41107. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41108. /**
  41109. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41110. */
  41111. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41112. /**
  41113. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41114. */
  41115. teleportationEnabled: boolean;
  41116. private _defaultHeight;
  41117. private _teleportationInitialized;
  41118. private _interactionsEnabled;
  41119. private _interactionsRequested;
  41120. private _displayGaze;
  41121. private _displayLaserPointer;
  41122. /**
  41123. * The mesh used to display where the user is going to teleport.
  41124. */
  41125. /**
  41126. * Sets the mesh to be used to display where the user is going to teleport.
  41127. */
  41128. teleportationTarget: Mesh;
  41129. /**
  41130. * 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
  41131. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41132. * See http://doc.babylonjs.com/resources/baking_transformations
  41133. */
  41134. gazeTrackerMesh: Mesh;
  41135. /**
  41136. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41137. */
  41138. updateGazeTrackerScale: boolean;
  41139. /**
  41140. * If the gaze trackers color should be updated when selecting meshes
  41141. */
  41142. updateGazeTrackerColor: boolean;
  41143. /**
  41144. * The gaze tracking mesh corresponding to the left controller
  41145. */
  41146. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41147. /**
  41148. * The gaze tracking mesh corresponding to the right controller
  41149. */
  41150. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41151. /**
  41152. * If the ray of the gaze should be displayed.
  41153. */
  41154. /**
  41155. * Sets if the ray of the gaze should be displayed.
  41156. */
  41157. displayGaze: boolean;
  41158. /**
  41159. * If the ray of the LaserPointer should be displayed.
  41160. */
  41161. /**
  41162. * Sets if the ray of the LaserPointer should be displayed.
  41163. */
  41164. displayLaserPointer: boolean;
  41165. /**
  41166. * The deviceOrientationCamera used as the camera when not in VR.
  41167. */
  41168. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41169. /**
  41170. * Based on the current WebVR support, returns the current VR camera used.
  41171. */
  41172. readonly currentVRCamera: Nullable<Camera>;
  41173. /**
  41174. * The webVRCamera which is used when in VR.
  41175. */
  41176. readonly webVRCamera: WebVRFreeCamera;
  41177. /**
  41178. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41179. */
  41180. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41181. private readonly _teleportationRequestInitiated;
  41182. /**
  41183. * Defines wether or not Pointer lock should be requested when switching to
  41184. * full screen.
  41185. */
  41186. requestPointerLockOnFullScreen: boolean;
  41187. /**
  41188. * Instantiates a VRExperienceHelper.
  41189. * Helps to quickly add VR support to an existing scene.
  41190. * @param scene The scene the VRExperienceHelper belongs to.
  41191. * @param webVROptions Options to modify the vr experience helper's behavior.
  41192. */
  41193. constructor(scene: Scene,
  41194. /** Options to modify the vr experience helper's behavior. */
  41195. webVROptions?: VRExperienceHelperOptions);
  41196. private _onDefaultMeshLoaded;
  41197. private _onResize;
  41198. private _onFullscreenChange;
  41199. /**
  41200. * Gets a value indicating if we are currently in VR mode.
  41201. */
  41202. readonly isInVRMode: boolean;
  41203. private onVrDisplayPresentChange;
  41204. private onVRDisplayChanged;
  41205. private moveButtonToBottomRight;
  41206. private displayVRButton;
  41207. private updateButtonVisibility;
  41208. private _cachedAngularSensibility;
  41209. /**
  41210. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41211. * Otherwise, will use the fullscreen API.
  41212. */
  41213. enterVR(): void;
  41214. /**
  41215. * Attempt to exit VR, or fullscreen.
  41216. */
  41217. exitVR(): void;
  41218. /**
  41219. * The position of the vr experience helper.
  41220. */
  41221. /**
  41222. * Sets the position of the vr experience helper.
  41223. */
  41224. position: Vector3;
  41225. /**
  41226. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41227. */
  41228. enableInteractions(): void;
  41229. private readonly _noControllerIsActive;
  41230. private beforeRender;
  41231. private _isTeleportationFloor;
  41232. /**
  41233. * Adds a floor mesh to be used for teleportation.
  41234. * @param floorMesh the mesh to be used for teleportation.
  41235. */
  41236. addFloorMesh(floorMesh: Mesh): void;
  41237. /**
  41238. * Removes a floor mesh from being used for teleportation.
  41239. * @param floorMesh the mesh to be removed.
  41240. */
  41241. removeFloorMesh(floorMesh: Mesh): void;
  41242. /**
  41243. * Enables interactions and teleportation using the VR controllers and gaze.
  41244. * @param vrTeleportationOptions options to modify teleportation behavior.
  41245. */
  41246. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41247. private _onNewGamepadConnected;
  41248. private _tryEnableInteractionOnController;
  41249. private _onNewGamepadDisconnected;
  41250. private _enableInteractionOnController;
  41251. private _checkTeleportWithRay;
  41252. private _checkRotate;
  41253. private _checkTeleportBackwards;
  41254. private _enableTeleportationOnController;
  41255. private _createTeleportationCircles;
  41256. private _displayTeleportationTarget;
  41257. private _hideTeleportationTarget;
  41258. private _rotateCamera;
  41259. private _moveTeleportationSelectorTo;
  41260. private _workingVector;
  41261. private _workingQuaternion;
  41262. private _workingMatrix;
  41263. /**
  41264. * Teleports the users feet to the desired location
  41265. * @param location The location where the user's feet should be placed
  41266. */
  41267. teleportCamera(location: Vector3): void;
  41268. private _convertNormalToDirectionOfRay;
  41269. private _castRayAndSelectObject;
  41270. private _notifySelectedMeshUnselected;
  41271. /**
  41272. * Sets the color of the laser ray from the vr controllers.
  41273. * @param color new color for the ray.
  41274. */
  41275. changeLaserColor(color: Color3): void;
  41276. /**
  41277. * Sets the color of the ray from the vr headsets gaze.
  41278. * @param color new color for the ray.
  41279. */
  41280. changeGazeColor(color: Color3): void;
  41281. /**
  41282. * Exits VR and disposes of the vr experience helper
  41283. */
  41284. dispose(): void;
  41285. /**
  41286. * Gets the name of the VRExperienceHelper class
  41287. * @returns "VRExperienceHelper"
  41288. */
  41289. getClassName(): string;
  41290. }
  41291. }
  41292. declare module "babylonjs/Cameras/VR/index" {
  41293. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41294. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41295. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41296. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41297. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41298. export * from "babylonjs/Cameras/VR/webVRCamera";
  41299. }
  41300. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41301. import { Observable } from "babylonjs/Misc/observable";
  41302. import { Nullable } from "babylonjs/types";
  41303. import { IDisposable, Scene } from "babylonjs/scene";
  41304. import { Vector3 } from "babylonjs/Maths/math";
  41305. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41306. import { Ray } from "babylonjs/Culling/ray";
  41307. /**
  41308. * Manages an XRSession
  41309. * @see https://doc.babylonjs.com/how_to/webxr
  41310. */
  41311. export class WebXRSessionManager implements IDisposable {
  41312. private scene;
  41313. /**
  41314. * Fires every time a new xrFrame arrives which can be used to update the camera
  41315. */
  41316. onXRFrameObservable: Observable<any>;
  41317. /**
  41318. * Fires when the xr session is ended either by the device or manually done
  41319. */
  41320. onXRSessionEnded: Observable<any>;
  41321. /** @hidden */
  41322. _xrSession: XRSession;
  41323. /** @hidden */
  41324. _frameOfReference: XRFrameOfReference;
  41325. /** @hidden */
  41326. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41327. /** @hidden */
  41328. _currentXRFrame: Nullable<XRFrame>;
  41329. private _xrNavigator;
  41330. private _xrDevice;
  41331. private _tmpMatrix;
  41332. /**
  41333. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41334. * @param scene The scene which the session should be created for
  41335. */
  41336. constructor(scene: Scene);
  41337. /**
  41338. * Initializes the manager
  41339. * After initialization enterXR can be called to start an XR session
  41340. * @returns Promise which resolves after it is initialized
  41341. */
  41342. initializeAsync(): Promise<void>;
  41343. /**
  41344. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41345. * @param sessionCreationOptions xr options to create the session with
  41346. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41347. * @returns Promise which resolves after it enters XR
  41348. */
  41349. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41350. /**
  41351. * Stops the xrSession and restores the renderloop
  41352. * @returns Promise which resolves after it exits XR
  41353. */
  41354. exitXRAsync(): Promise<void>;
  41355. /**
  41356. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41357. * @param ray ray to cast into the environment
  41358. * @returns Promise which resolves with a collision point in the environment if it exists
  41359. */
  41360. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41361. /**
  41362. * Checks if a session would be supported for the creation options specified
  41363. * @param options creation options to check if they are supported
  41364. * @returns true if supported
  41365. */
  41366. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41367. /**
  41368. * @hidden
  41369. * Converts the render layer of xrSession to a render target
  41370. * @param session session to create render target for
  41371. * @param scene scene the new render target should be created for
  41372. */
  41373. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41374. /**
  41375. * Disposes of the session manager
  41376. */
  41377. dispose(): void;
  41378. }
  41379. }
  41380. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41381. import { Scene } from "babylonjs/scene";
  41382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41383. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41384. /**
  41385. * WebXR Camera which holds the views for the xrSession
  41386. * @see https://doc.babylonjs.com/how_to/webxr
  41387. */
  41388. export class WebXRCamera extends FreeCamera {
  41389. private static _TmpMatrix;
  41390. /**
  41391. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41392. * @param name the name of the camera
  41393. * @param scene the scene to add the camera to
  41394. */
  41395. constructor(name: string, scene: Scene);
  41396. private _updateNumberOfRigCameras;
  41397. /** @hidden */
  41398. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41399. /**
  41400. * Updates the cameras position from the current pose information of the XR session
  41401. * @param xrSessionManager the session containing pose information
  41402. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41403. */
  41404. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41405. }
  41406. }
  41407. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41408. import { Nullable } from "babylonjs/types";
  41409. import { Observable } from "babylonjs/Misc/observable";
  41410. import { IDisposable, Scene } from "babylonjs/scene";
  41411. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41413. import { Ray } from "babylonjs/Culling/ray";
  41414. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41415. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41416. /**
  41417. * States of the webXR experience
  41418. */
  41419. export enum WebXRState {
  41420. /**
  41421. * Transitioning to being in XR mode
  41422. */
  41423. ENTERING_XR = 0,
  41424. /**
  41425. * Transitioning to non XR mode
  41426. */
  41427. EXITING_XR = 1,
  41428. /**
  41429. * In XR mode and presenting
  41430. */
  41431. IN_XR = 2,
  41432. /**
  41433. * Not entered XR mode
  41434. */
  41435. NOT_IN_XR = 3
  41436. }
  41437. /**
  41438. * Helper class used to enable XR
  41439. * @see https://doc.babylonjs.com/how_to/webxr
  41440. */
  41441. export class WebXRExperienceHelper implements IDisposable {
  41442. private scene;
  41443. /**
  41444. * 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
  41445. */
  41446. container: AbstractMesh;
  41447. /**
  41448. * Camera used to render xr content
  41449. */
  41450. camera: WebXRCamera;
  41451. /**
  41452. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41453. */
  41454. state: WebXRState;
  41455. private _setState;
  41456. private static _TmpVector;
  41457. /**
  41458. * Fires when the state of the experience helper has changed
  41459. */
  41460. onStateChangedObservable: Observable<WebXRState>;
  41461. /** @hidden */
  41462. _sessionManager: WebXRSessionManager;
  41463. private _nonVRCamera;
  41464. private _originalSceneAutoClear;
  41465. private _supported;
  41466. /**
  41467. * Creates the experience helper
  41468. * @param scene the scene to attach the experience helper to
  41469. * @returns a promise for the experience helper
  41470. */
  41471. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41472. /**
  41473. * Creates a WebXRExperienceHelper
  41474. * @param scene The scene the helper should be created in
  41475. */
  41476. private constructor();
  41477. /**
  41478. * Exits XR mode and returns the scene to its original state
  41479. * @returns promise that resolves after xr mode has exited
  41480. */
  41481. exitXRAsync(): Promise<void>;
  41482. /**
  41483. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41484. * @param sessionCreationOptions options for the XR session
  41485. * @param frameOfReference frame of reference of the XR session
  41486. * @returns promise that resolves after xr mode has entered
  41487. */
  41488. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41489. /**
  41490. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41491. * @param ray ray to cast into the environment
  41492. * @returns Promise which resolves with a collision point in the environment if it exists
  41493. */
  41494. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41495. /**
  41496. * Updates the global position of the camera by moving the camera's container
  41497. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41498. * @param position The desired global position of the camera
  41499. */
  41500. setPositionOfCameraUsingContainer(position: Vector3): void;
  41501. /**
  41502. * Rotates the xr camera by rotating the camera's container around the camera's position
  41503. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41504. * @param rotation the desired quaternion rotation to apply to the camera
  41505. */
  41506. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41507. /**
  41508. * Checks if the creation options are supported by the xr session
  41509. * @param options creation options
  41510. * @returns true if supported
  41511. */
  41512. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41513. /**
  41514. * Disposes of the experience helper
  41515. */
  41516. dispose(): void;
  41517. }
  41518. }
  41519. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41520. import { Nullable } from "babylonjs/types";
  41521. import { Observable } from "babylonjs/Misc/observable";
  41522. import { IDisposable, Scene } from "babylonjs/scene";
  41523. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41524. /**
  41525. * Button which can be used to enter a different mode of XR
  41526. */
  41527. export class WebXREnterExitUIButton {
  41528. /** button element */
  41529. element: HTMLElement;
  41530. /** XR initialization options for the button */
  41531. initializationOptions: XRSessionCreationOptions;
  41532. /**
  41533. * Creates a WebXREnterExitUIButton
  41534. * @param element button element
  41535. * @param initializationOptions XR initialization options for the button
  41536. */
  41537. constructor(
  41538. /** button element */
  41539. element: HTMLElement,
  41540. /** XR initialization options for the button */
  41541. initializationOptions: XRSessionCreationOptions);
  41542. /**
  41543. * Overwritable function which can be used to update the button's visuals when the state changes
  41544. * @param activeButton the current active button in the UI
  41545. */
  41546. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41547. }
  41548. /**
  41549. * Options to create the webXR UI
  41550. */
  41551. export class WebXREnterExitUIOptions {
  41552. /**
  41553. * Context to enter xr with
  41554. */
  41555. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41556. /**
  41557. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41558. */
  41559. customButtons?: Array<WebXREnterExitUIButton>;
  41560. }
  41561. /**
  41562. * UI to allow the user to enter/exit XR mode
  41563. */
  41564. export class WebXREnterExitUI implements IDisposable {
  41565. private scene;
  41566. private _overlay;
  41567. private _buttons;
  41568. private _activeButton;
  41569. /**
  41570. * Fired every time the active button is changed.
  41571. *
  41572. * When xr is entered via a button that launches xr that button will be the callback parameter
  41573. *
  41574. * When exiting xr the callback parameter will be null)
  41575. */
  41576. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41577. /**
  41578. * Creates UI to allow the user to enter/exit XR mode
  41579. * @param scene the scene to add the ui to
  41580. * @param helper the xr experience helper to enter/exit xr with
  41581. * @param options options to configure the UI
  41582. * @returns the created ui
  41583. */
  41584. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41585. private constructor();
  41586. private _updateButtons;
  41587. /**
  41588. * Disposes of the object
  41589. */
  41590. dispose(): void;
  41591. }
  41592. }
  41593. declare module "babylonjs/Cameras/XR/webXRInput" {
  41594. import { IDisposable, Scene } from "babylonjs/scene";
  41595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41596. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41597. /**
  41598. * Represents an XR input
  41599. */
  41600. export class WebXRController {
  41601. /**
  41602. * 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
  41603. */
  41604. grip?: AbstractMesh;
  41605. /**
  41606. * Pointer which can be used to select objects or attach a visible laser to
  41607. */
  41608. pointer: AbstractMesh;
  41609. /**
  41610. * Creates the controller
  41611. * @see https://doc.babylonjs.com/how_to/webxr
  41612. * @param scene the scene which the controller should be associated to
  41613. */
  41614. constructor(scene: Scene);
  41615. /**
  41616. * Disposes of the object
  41617. */
  41618. dispose(): void;
  41619. }
  41620. /**
  41621. * XR input used to track XR inputs such as controllers/rays
  41622. */
  41623. export class WebXRInput implements IDisposable {
  41624. private helper;
  41625. /**
  41626. * XR controllers being tracked
  41627. */
  41628. controllers: Array<WebXRController>;
  41629. private _tmpMatrix;
  41630. private _frameObserver;
  41631. /**
  41632. * Initializes the WebXRInput
  41633. * @param helper experience helper which the input should be created for
  41634. */
  41635. constructor(helper: WebXRExperienceHelper);
  41636. /**
  41637. * Disposes of the object
  41638. */
  41639. dispose(): void;
  41640. }
  41641. }
  41642. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41643. import { Nullable } from "babylonjs/types";
  41644. import { IDisposable } from "babylonjs/scene";
  41645. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41646. /**
  41647. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41648. */
  41649. export class WebXRManagedOutputCanvas implements IDisposable {
  41650. private _canvas;
  41651. /**
  41652. * xrpresent context of the canvas which can be used to display/mirror xr content
  41653. */
  41654. canvasContext: Nullable<WebGLRenderingContext>;
  41655. /**
  41656. * Initializes the canvas to be added/removed upon entering/exiting xr
  41657. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41658. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41659. */
  41660. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41661. /**
  41662. * Disposes of the object
  41663. */
  41664. dispose(): void;
  41665. private _setManagedOutputCanvas;
  41666. private _addCanvas;
  41667. private _removeCanvas;
  41668. }
  41669. }
  41670. declare module "babylonjs/Cameras/XR/index" {
  41671. export * from "babylonjs/Cameras/XR/webXRCamera";
  41672. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41673. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41674. export * from "babylonjs/Cameras/XR/webXRInput";
  41675. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41676. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41677. }
  41678. declare module "babylonjs/Cameras/RigModes/index" {
  41679. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41680. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41681. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41682. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41683. }
  41684. declare module "babylonjs/Cameras/index" {
  41685. export * from "babylonjs/Cameras/Inputs/index";
  41686. export * from "babylonjs/Cameras/cameraInputsManager";
  41687. export * from "babylonjs/Cameras/camera";
  41688. export * from "babylonjs/Cameras/targetCamera";
  41689. export * from "babylonjs/Cameras/freeCamera";
  41690. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41691. export * from "babylonjs/Cameras/touchCamera";
  41692. export * from "babylonjs/Cameras/arcRotateCamera";
  41693. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41694. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41695. export * from "babylonjs/Cameras/flyCamera";
  41696. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41697. export * from "babylonjs/Cameras/followCamera";
  41698. export * from "babylonjs/Cameras/gamepadCamera";
  41699. export * from "babylonjs/Cameras/Stereoscopic/index";
  41700. export * from "babylonjs/Cameras/universalCamera";
  41701. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41702. export * from "babylonjs/Cameras/VR/index";
  41703. export * from "babylonjs/Cameras/XR/index";
  41704. export * from "babylonjs/Cameras/RigModes/index";
  41705. }
  41706. declare module "babylonjs/Collisions/index" {
  41707. export * from "babylonjs/Collisions/collider";
  41708. export * from "babylonjs/Collisions/collisionCoordinator";
  41709. export * from "babylonjs/Collisions/pickingInfo";
  41710. export * from "babylonjs/Collisions/intersectionInfo";
  41711. }
  41712. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41713. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41714. import { Vector3, Plane } from "babylonjs/Maths/math";
  41715. import { Ray } from "babylonjs/Culling/ray";
  41716. /**
  41717. * Contains an array of blocks representing the octree
  41718. */
  41719. export interface IOctreeContainer<T> {
  41720. /**
  41721. * Blocks within the octree
  41722. */
  41723. blocks: Array<OctreeBlock<T>>;
  41724. }
  41725. /**
  41726. * Class used to store a cell in an octree
  41727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41728. */
  41729. export class OctreeBlock<T> {
  41730. /**
  41731. * Gets the content of the current block
  41732. */
  41733. entries: T[];
  41734. /**
  41735. * Gets the list of block children
  41736. */
  41737. blocks: Array<OctreeBlock<T>>;
  41738. private _depth;
  41739. private _maxDepth;
  41740. private _capacity;
  41741. private _minPoint;
  41742. private _maxPoint;
  41743. private _boundingVectors;
  41744. private _creationFunc;
  41745. /**
  41746. * Creates a new block
  41747. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41748. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41749. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41750. * @param depth defines the current depth of this block in the octree
  41751. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41752. * @param creationFunc defines a callback to call when an element is added to the block
  41753. */
  41754. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41755. /**
  41756. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41757. */
  41758. readonly capacity: number;
  41759. /**
  41760. * Gets the minimum vector (in world space) of the block's bounding box
  41761. */
  41762. readonly minPoint: Vector3;
  41763. /**
  41764. * Gets the maximum vector (in world space) of the block's bounding box
  41765. */
  41766. readonly maxPoint: Vector3;
  41767. /**
  41768. * Add a new element to this block
  41769. * @param entry defines the element to add
  41770. */
  41771. addEntry(entry: T): void;
  41772. /**
  41773. * Remove an element from this block
  41774. * @param entry defines the element to remove
  41775. */
  41776. removeEntry(entry: T): void;
  41777. /**
  41778. * Add an array of elements to this block
  41779. * @param entries defines the array of elements to add
  41780. */
  41781. addEntries(entries: T[]): void;
  41782. /**
  41783. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41784. * @param frustumPlanes defines the frustum planes to test
  41785. * @param selection defines the array to store current content if selection is positive
  41786. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41787. */
  41788. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41789. /**
  41790. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41791. * @param sphereCenter defines the bounding sphere center
  41792. * @param sphereRadius defines the bounding sphere radius
  41793. * @param selection defines the array to store current content if selection is positive
  41794. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41795. */
  41796. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41797. /**
  41798. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41799. * @param ray defines the ray to test with
  41800. * @param selection defines the array to store current content if selection is positive
  41801. */
  41802. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41803. /**
  41804. * Subdivide the content into child blocks (this block will then be empty)
  41805. */
  41806. createInnerBlocks(): void;
  41807. /**
  41808. * @hidden
  41809. */
  41810. 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;
  41811. }
  41812. }
  41813. declare module "babylonjs/Culling/Octrees/octree" {
  41814. import { SmartArray } from "babylonjs/Misc/smartArray";
  41815. import { Vector3, Plane } from "babylonjs/Maths/math";
  41816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41818. import { Ray } from "babylonjs/Culling/ray";
  41819. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41820. /**
  41821. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41822. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41823. */
  41824. export class Octree<T> {
  41825. /** 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.) */
  41826. maxDepth: number;
  41827. /**
  41828. * Blocks within the octree containing objects
  41829. */
  41830. blocks: Array<OctreeBlock<T>>;
  41831. /**
  41832. * Content stored in the octree
  41833. */
  41834. dynamicContent: T[];
  41835. private _maxBlockCapacity;
  41836. private _selectionContent;
  41837. private _creationFunc;
  41838. /**
  41839. * Creates a octree
  41840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41841. * @param creationFunc function to be used to instatiate the octree
  41842. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41843. * @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.)
  41844. */
  41845. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41846. /** 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.) */
  41847. maxDepth?: number);
  41848. /**
  41849. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41850. * @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);
  41851. * @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);
  41852. * @param entries meshes to be added to the octree blocks
  41853. */
  41854. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41855. /**
  41856. * Adds a mesh to the octree
  41857. * @param entry Mesh to add to the octree
  41858. */
  41859. addMesh(entry: T): void;
  41860. /**
  41861. * Remove an element from the octree
  41862. * @param entry defines the element to remove
  41863. */
  41864. removeMesh(entry: T): void;
  41865. /**
  41866. * Selects an array of meshes within the frustum
  41867. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41868. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41869. * @returns array of meshes within the frustum
  41870. */
  41871. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41872. /**
  41873. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41874. * @param sphereCenter defines the bounding sphere center
  41875. * @param sphereRadius defines the bounding sphere radius
  41876. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41877. * @returns an array of objects that intersect the sphere
  41878. */
  41879. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41880. /**
  41881. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41882. * @param ray defines the ray to test with
  41883. * @returns array of intersected objects
  41884. */
  41885. intersectsRay(ray: Ray): SmartArray<T>;
  41886. /**
  41887. * Adds a mesh into the octree block if it intersects the block
  41888. */
  41889. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41890. /**
  41891. * Adds a submesh into the octree block if it intersects the block
  41892. */
  41893. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41894. }
  41895. }
  41896. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41897. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41898. import { Scene } from "babylonjs/scene";
  41899. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41901. import { Ray } from "babylonjs/Culling/ray";
  41902. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41903. import { Collider } from "babylonjs/Collisions/collider";
  41904. module "babylonjs/scene" {
  41905. interface Scene {
  41906. /**
  41907. * @hidden
  41908. * Backing Filed
  41909. */
  41910. _selectionOctree: Octree<AbstractMesh>;
  41911. /**
  41912. * Gets the octree used to boost mesh selection (picking)
  41913. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41914. */
  41915. selectionOctree: Octree<AbstractMesh>;
  41916. /**
  41917. * Creates or updates the octree used to boost selection (picking)
  41918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41919. * @param maxCapacity defines the maximum capacity per leaf
  41920. * @param maxDepth defines the maximum depth of the octree
  41921. * @returns an octree of AbstractMesh
  41922. */
  41923. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41924. }
  41925. }
  41926. module "babylonjs/Meshes/abstractMesh" {
  41927. interface AbstractMesh {
  41928. /**
  41929. * @hidden
  41930. * Backing Field
  41931. */
  41932. _submeshesOctree: Octree<SubMesh>;
  41933. /**
  41934. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41935. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41936. * @param maxCapacity defines the maximum size of each block (64 by default)
  41937. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41938. * @returns the new octree
  41939. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41941. */
  41942. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41943. }
  41944. }
  41945. /**
  41946. * Defines the octree scene component responsible to manage any octrees
  41947. * in a given scene.
  41948. */
  41949. export class OctreeSceneComponent {
  41950. /**
  41951. * The component name help to identify the component in the list of scene components.
  41952. */
  41953. readonly name: string;
  41954. /**
  41955. * The scene the component belongs to.
  41956. */
  41957. scene: Scene;
  41958. /**
  41959. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41960. */
  41961. readonly checksIsEnabled: boolean;
  41962. /**
  41963. * Creates a new instance of the component for the given scene
  41964. * @param scene Defines the scene to register the component in
  41965. */
  41966. constructor(scene: Scene);
  41967. /**
  41968. * Registers the component in a given scene
  41969. */
  41970. register(): void;
  41971. /**
  41972. * Return the list of active meshes
  41973. * @returns the list of active meshes
  41974. */
  41975. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41976. /**
  41977. * Return the list of active sub meshes
  41978. * @param mesh The mesh to get the candidates sub meshes from
  41979. * @returns the list of active sub meshes
  41980. */
  41981. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41982. private _tempRay;
  41983. /**
  41984. * Return the list of sub meshes intersecting with a given local ray
  41985. * @param mesh defines the mesh to find the submesh for
  41986. * @param localRay defines the ray in local space
  41987. * @returns the list of intersecting sub meshes
  41988. */
  41989. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41990. /**
  41991. * Return the list of sub meshes colliding with a collider
  41992. * @param mesh defines the mesh to find the submesh for
  41993. * @param collider defines the collider to evaluate the collision against
  41994. * @returns the list of colliding sub meshes
  41995. */
  41996. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41997. /**
  41998. * Rebuilds the elements related to this component in case of
  41999. * context lost for instance.
  42000. */
  42001. rebuild(): void;
  42002. /**
  42003. * Disposes the component and the associated ressources.
  42004. */
  42005. dispose(): void;
  42006. }
  42007. }
  42008. declare module "babylonjs/Culling/Octrees/index" {
  42009. export * from "babylonjs/Culling/Octrees/octree";
  42010. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42011. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42012. }
  42013. declare module "babylonjs/Culling/index" {
  42014. export * from "babylonjs/Culling/boundingBox";
  42015. export * from "babylonjs/Culling/boundingInfo";
  42016. export * from "babylonjs/Culling/boundingSphere";
  42017. export * from "babylonjs/Culling/Octrees/index";
  42018. export * from "babylonjs/Culling/ray";
  42019. }
  42020. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42021. import { IDisposable, Scene } from "babylonjs/scene";
  42022. import { Nullable } from "babylonjs/types";
  42023. import { Observable } from "babylonjs/Misc/observable";
  42024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42025. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42026. /**
  42027. * Renders a layer on top of an existing scene
  42028. */
  42029. export class UtilityLayerRenderer implements IDisposable {
  42030. /** the original scene that will be rendered on top of */
  42031. originalScene: Scene;
  42032. private _pointerCaptures;
  42033. private _lastPointerEvents;
  42034. private static _DefaultUtilityLayer;
  42035. private static _DefaultKeepDepthUtilityLayer;
  42036. private _sharedGizmoLight;
  42037. /**
  42038. * @hidden
  42039. * Light which used by gizmos to get light shading
  42040. */
  42041. _getSharedGizmoLight(): HemisphericLight;
  42042. /**
  42043. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42044. */
  42045. pickUtilitySceneFirst: boolean;
  42046. /**
  42047. * 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)
  42048. */
  42049. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42050. /**
  42051. * 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)
  42052. */
  42053. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42054. /**
  42055. * The scene that is rendered on top of the original scene
  42056. */
  42057. utilityLayerScene: Scene;
  42058. /**
  42059. * If the utility layer should automatically be rendered on top of existing scene
  42060. */
  42061. shouldRender: boolean;
  42062. /**
  42063. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42064. */
  42065. onlyCheckPointerDownEvents: boolean;
  42066. /**
  42067. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42068. */
  42069. processAllEvents: boolean;
  42070. /**
  42071. * Observable raised when the pointer move from the utility layer scene to the main scene
  42072. */
  42073. onPointerOutObservable: Observable<number>;
  42074. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42075. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42076. private _afterRenderObserver;
  42077. private _sceneDisposeObserver;
  42078. private _originalPointerObserver;
  42079. /**
  42080. * Instantiates a UtilityLayerRenderer
  42081. * @param originalScene the original scene that will be rendered on top of
  42082. * @param handleEvents boolean indicating if the utility layer should handle events
  42083. */
  42084. constructor(
  42085. /** the original scene that will be rendered on top of */
  42086. originalScene: Scene, handleEvents?: boolean);
  42087. private _notifyObservers;
  42088. /**
  42089. * Renders the utility layers scene on top of the original scene
  42090. */
  42091. render(): void;
  42092. /**
  42093. * Disposes of the renderer
  42094. */
  42095. dispose(): void;
  42096. private _updateCamera;
  42097. }
  42098. }
  42099. declare module "babylonjs/Gizmos/gizmo" {
  42100. import { Nullable } from "babylonjs/types";
  42101. import { IDisposable } from "babylonjs/scene";
  42102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42103. import { Mesh } from "babylonjs/Meshes/mesh";
  42104. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42105. /**
  42106. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42107. */
  42108. export class Gizmo implements IDisposable {
  42109. /** The utility layer the gizmo will be added to */
  42110. gizmoLayer: UtilityLayerRenderer;
  42111. /**
  42112. * The root mesh of the gizmo
  42113. */
  42114. _rootMesh: Mesh;
  42115. private _attachedMesh;
  42116. /**
  42117. * Ratio for the scale of the gizmo (Default: 1)
  42118. */
  42119. scaleRatio: number;
  42120. /**
  42121. * If a custom mesh has been set (Default: false)
  42122. */
  42123. protected _customMeshSet: boolean;
  42124. /**
  42125. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42126. * * When set, interactions will be enabled
  42127. */
  42128. attachedMesh: Nullable<AbstractMesh>;
  42129. /**
  42130. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42131. * @param mesh The mesh to replace the default mesh of the gizmo
  42132. */
  42133. setCustomMesh(mesh: Mesh): void;
  42134. /**
  42135. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42136. */
  42137. updateGizmoRotationToMatchAttachedMesh: boolean;
  42138. /**
  42139. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42140. */
  42141. updateGizmoPositionToMatchAttachedMesh: boolean;
  42142. /**
  42143. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42144. */
  42145. protected _updateScale: boolean;
  42146. protected _interactionsEnabled: boolean;
  42147. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42148. private _beforeRenderObserver;
  42149. private _tempVector;
  42150. /**
  42151. * Creates a gizmo
  42152. * @param gizmoLayer The utility layer the gizmo will be added to
  42153. */
  42154. constructor(
  42155. /** The utility layer the gizmo will be added to */
  42156. gizmoLayer?: UtilityLayerRenderer);
  42157. /**
  42158. * Updates the gizmo to match the attached mesh's position/rotation
  42159. */
  42160. protected _update(): void;
  42161. /**
  42162. * Disposes of the gizmo
  42163. */
  42164. dispose(): void;
  42165. }
  42166. }
  42167. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42168. import { Observable } from "babylonjs/Misc/observable";
  42169. import { Nullable } from "babylonjs/types";
  42170. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42171. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42173. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42174. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42176. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42177. import { Scene } from "babylonjs/scene";
  42178. /**
  42179. * Single axis drag gizmo
  42180. */
  42181. export class AxisDragGizmo extends Gizmo {
  42182. /**
  42183. * Drag behavior responsible for the gizmos dragging interactions
  42184. */
  42185. dragBehavior: PointerDragBehavior;
  42186. private _pointerObserver;
  42187. /**
  42188. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42189. */
  42190. snapDistance: number;
  42191. /**
  42192. * Event that fires each time the gizmo snaps to a new location.
  42193. * * snapDistance is the the change in distance
  42194. */
  42195. onSnapObservable: Observable<{
  42196. snapDistance: number;
  42197. }>;
  42198. /** @hidden */
  42199. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42200. /** @hidden */
  42201. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42202. /**
  42203. * Creates an AxisDragGizmo
  42204. * @param gizmoLayer The utility layer the gizmo will be added to
  42205. * @param dragAxis The axis which the gizmo will be able to drag on
  42206. * @param color The color of the gizmo
  42207. */
  42208. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42210. /**
  42211. * Disposes of the gizmo
  42212. */
  42213. dispose(): void;
  42214. }
  42215. }
  42216. declare module "babylonjs/Debug/axesViewer" {
  42217. import { Vector3 } from "babylonjs/Maths/math";
  42218. import { Nullable } from "babylonjs/types";
  42219. import { Scene } from "babylonjs/scene";
  42220. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42221. /**
  42222. * The Axes viewer will show 3 axes in a specific point in space
  42223. */
  42224. export class AxesViewer {
  42225. private _xAxis;
  42226. private _yAxis;
  42227. private _zAxis;
  42228. private _scaleLinesFactor;
  42229. private _instanced;
  42230. /**
  42231. * Gets the hosting scene
  42232. */
  42233. scene: Scene;
  42234. /**
  42235. * Gets or sets a number used to scale line length
  42236. */
  42237. scaleLines: number;
  42238. /** Gets the node hierarchy used to render x-axis */
  42239. readonly xAxis: TransformNode;
  42240. /** Gets the node hierarchy used to render y-axis */
  42241. readonly yAxis: TransformNode;
  42242. /** Gets the node hierarchy used to render z-axis */
  42243. readonly zAxis: TransformNode;
  42244. /**
  42245. * Creates a new AxesViewer
  42246. * @param scene defines the hosting scene
  42247. * @param scaleLines defines a number used to scale line length (1 by default)
  42248. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42249. * @param xAxis defines the node hierarchy used to render the x-axis
  42250. * @param yAxis defines the node hierarchy used to render the y-axis
  42251. * @param zAxis defines the node hierarchy used to render the z-axis
  42252. */
  42253. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42254. /**
  42255. * Force the viewer to update
  42256. * @param position defines the position of the viewer
  42257. * @param xaxis defines the x axis of the viewer
  42258. * @param yaxis defines the y axis of the viewer
  42259. * @param zaxis defines the z axis of the viewer
  42260. */
  42261. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42262. /**
  42263. * Creates an instance of this axes viewer.
  42264. * @returns a new axes viewer with instanced meshes
  42265. */
  42266. createInstance(): AxesViewer;
  42267. /** Releases resources */
  42268. dispose(): void;
  42269. private static _SetRenderingGroupId;
  42270. }
  42271. }
  42272. declare module "babylonjs/Debug/boneAxesViewer" {
  42273. import { Nullable } from "babylonjs/types";
  42274. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42275. import { Vector3 } from "babylonjs/Maths/math";
  42276. import { Mesh } from "babylonjs/Meshes/mesh";
  42277. import { Bone } from "babylonjs/Bones/bone";
  42278. import { Scene } from "babylonjs/scene";
  42279. /**
  42280. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42281. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42282. */
  42283. export class BoneAxesViewer extends AxesViewer {
  42284. /**
  42285. * Gets or sets the target mesh where to display the axes viewer
  42286. */
  42287. mesh: Nullable<Mesh>;
  42288. /**
  42289. * Gets or sets the target bone where to display the axes viewer
  42290. */
  42291. bone: Nullable<Bone>;
  42292. /** Gets current position */
  42293. pos: Vector3;
  42294. /** Gets direction of X axis */
  42295. xaxis: Vector3;
  42296. /** Gets direction of Y axis */
  42297. yaxis: Vector3;
  42298. /** Gets direction of Z axis */
  42299. zaxis: Vector3;
  42300. /**
  42301. * Creates a new BoneAxesViewer
  42302. * @param scene defines the hosting scene
  42303. * @param bone defines the target bone
  42304. * @param mesh defines the target mesh
  42305. * @param scaleLines defines a scaling factor for line length (1 by default)
  42306. */
  42307. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42308. /**
  42309. * Force the viewer to update
  42310. */
  42311. update(): void;
  42312. /** Releases resources */
  42313. dispose(): void;
  42314. }
  42315. }
  42316. declare module "babylonjs/Debug/debugLayer" {
  42317. import { Observable } from "babylonjs/Misc/observable";
  42318. import { Scene } from "babylonjs/scene";
  42319. /**
  42320. * Interface used to define scene explorer extensibility option
  42321. */
  42322. export interface IExplorerExtensibilityOption {
  42323. /**
  42324. * Define the option label
  42325. */
  42326. label: string;
  42327. /**
  42328. * Defines the action to execute on click
  42329. */
  42330. action: (entity: any) => void;
  42331. }
  42332. /**
  42333. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42334. */
  42335. export interface IExplorerExtensibilityGroup {
  42336. /**
  42337. * Defines a predicate to test if a given type mut be extended
  42338. */
  42339. predicate: (entity: any) => boolean;
  42340. /**
  42341. * Gets the list of options added to a type
  42342. */
  42343. entries: IExplorerExtensibilityOption[];
  42344. }
  42345. /**
  42346. * Interface used to define the options to use to create the Inspector
  42347. */
  42348. export interface IInspectorOptions {
  42349. /**
  42350. * Display in overlay mode (default: false)
  42351. */
  42352. overlay?: boolean;
  42353. /**
  42354. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42355. */
  42356. globalRoot?: HTMLElement;
  42357. /**
  42358. * Display the Scene explorer
  42359. */
  42360. showExplorer?: boolean;
  42361. /**
  42362. * Display the property inspector
  42363. */
  42364. showInspector?: boolean;
  42365. /**
  42366. * Display in embed mode (both panes on the right)
  42367. */
  42368. embedMode?: boolean;
  42369. /**
  42370. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42371. */
  42372. handleResize?: boolean;
  42373. /**
  42374. * Allow the panes to popup (default: true)
  42375. */
  42376. enablePopup?: boolean;
  42377. /**
  42378. * Allow the panes to be closed by users (default: true)
  42379. */
  42380. enableClose?: boolean;
  42381. /**
  42382. * Optional list of extensibility entries
  42383. */
  42384. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42385. /**
  42386. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42387. */
  42388. inspectorURL?: string;
  42389. }
  42390. module "babylonjs/scene" {
  42391. interface Scene {
  42392. /**
  42393. * @hidden
  42394. * Backing field
  42395. */
  42396. _debugLayer: DebugLayer;
  42397. /**
  42398. * Gets the debug layer (aka Inspector) associated with the scene
  42399. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42400. */
  42401. debugLayer: DebugLayer;
  42402. }
  42403. }
  42404. /**
  42405. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42406. * what is happening in your scene
  42407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42408. */
  42409. export class DebugLayer {
  42410. /**
  42411. * Define the url to get the inspector script from.
  42412. * By default it uses the babylonjs CDN.
  42413. * @ignoreNaming
  42414. */
  42415. static InspectorURL: string;
  42416. private _scene;
  42417. private BJSINSPECTOR;
  42418. /**
  42419. * Observable triggered when a property is changed through the inspector.
  42420. */
  42421. onPropertyChangedObservable: Observable<{
  42422. object: any;
  42423. property: string;
  42424. value: any;
  42425. initialValue: any;
  42426. }>;
  42427. /**
  42428. * Instantiates a new debug layer.
  42429. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42430. * what is happening in your scene
  42431. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42432. * @param scene Defines the scene to inspect
  42433. */
  42434. constructor(scene: Scene);
  42435. /** Creates the inspector window. */
  42436. private _createInspector;
  42437. /**
  42438. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42439. * @param entity defines the entity to select
  42440. * @param lineContainerTitle defines the specific block to highlight
  42441. */
  42442. select(entity: any, lineContainerTitle?: string): void;
  42443. /** Get the inspector from bundle or global */
  42444. private _getGlobalInspector;
  42445. /**
  42446. * Get if the inspector is visible or not.
  42447. * @returns true if visible otherwise, false
  42448. */
  42449. isVisible(): boolean;
  42450. /**
  42451. * Hide the inspector and close its window.
  42452. */
  42453. hide(): void;
  42454. /**
  42455. * Launch the debugLayer.
  42456. * @param config Define the configuration of the inspector
  42457. * @return a promise fulfilled when the debug layer is visible
  42458. */
  42459. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42460. }
  42461. }
  42462. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42463. import { Nullable } from "babylonjs/types";
  42464. import { Scene } from "babylonjs/scene";
  42465. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42466. import { Mesh } from "babylonjs/Meshes/mesh";
  42467. /**
  42468. * Class containing static functions to help procedurally build meshes
  42469. */
  42470. export class BoxBuilder {
  42471. /**
  42472. * Creates a box mesh
  42473. * * The parameter `size` sets the size (float) of each box side (default 1)
  42474. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42475. * * 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)
  42476. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42480. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42481. * @param name defines the name of the mesh
  42482. * @param options defines the options used to create the mesh
  42483. * @param scene defines the hosting scene
  42484. * @returns the box mesh
  42485. */
  42486. static CreateBox(name: string, options: {
  42487. size?: number;
  42488. width?: number;
  42489. height?: number;
  42490. depth?: number;
  42491. faceUV?: Vector4[];
  42492. faceColors?: Color4[];
  42493. sideOrientation?: number;
  42494. frontUVs?: Vector4;
  42495. backUVs?: Vector4;
  42496. wrap?: boolean;
  42497. topBaseAt?: number;
  42498. bottomBaseAt?: number;
  42499. updatable?: boolean;
  42500. }, scene?: Nullable<Scene>): Mesh;
  42501. }
  42502. }
  42503. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42504. import { Vector4 } from "babylonjs/Maths/math";
  42505. import { Mesh } from "babylonjs/Meshes/mesh";
  42506. /**
  42507. * Class containing static functions to help procedurally build meshes
  42508. */
  42509. export class SphereBuilder {
  42510. /**
  42511. * Creates a sphere mesh
  42512. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42513. * * 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`)
  42514. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42515. * * 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
  42516. * * 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)
  42517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42520. * @param name defines the name of the mesh
  42521. * @param options defines the options used to create the mesh
  42522. * @param scene defines the hosting scene
  42523. * @returns the sphere mesh
  42524. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42525. */
  42526. static CreateSphere(name: string, options: {
  42527. segments?: number;
  42528. diameter?: number;
  42529. diameterX?: number;
  42530. diameterY?: number;
  42531. diameterZ?: number;
  42532. arc?: number;
  42533. slice?: number;
  42534. sideOrientation?: number;
  42535. frontUVs?: Vector4;
  42536. backUVs?: Vector4;
  42537. updatable?: boolean;
  42538. }, scene: any): Mesh;
  42539. }
  42540. }
  42541. declare module "babylonjs/Debug/physicsViewer" {
  42542. import { Nullable } from "babylonjs/types";
  42543. import { Scene } from "babylonjs/scene";
  42544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42545. import { Mesh } from "babylonjs/Meshes/mesh";
  42546. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42547. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42548. /**
  42549. * Used to show the physics impostor around the specific mesh
  42550. */
  42551. export class PhysicsViewer {
  42552. /** @hidden */
  42553. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42554. /** @hidden */
  42555. protected _meshes: Array<Nullable<AbstractMesh>>;
  42556. /** @hidden */
  42557. protected _scene: Nullable<Scene>;
  42558. /** @hidden */
  42559. protected _numMeshes: number;
  42560. /** @hidden */
  42561. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42562. private _renderFunction;
  42563. private _utilityLayer;
  42564. private _debugBoxMesh;
  42565. private _debugSphereMesh;
  42566. private _debugCylinderMesh;
  42567. private _debugMaterial;
  42568. private _debugMeshMeshes;
  42569. /**
  42570. * Creates a new PhysicsViewer
  42571. * @param scene defines the hosting scene
  42572. */
  42573. constructor(scene: Scene);
  42574. /** @hidden */
  42575. protected _updateDebugMeshes(): void;
  42576. /**
  42577. * Renders a specified physic impostor
  42578. * @param impostor defines the impostor to render
  42579. * @param targetMesh defines the mesh represented by the impostor
  42580. * @returns the new debug mesh used to render the impostor
  42581. */
  42582. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42583. /**
  42584. * Hides a specified physic impostor
  42585. * @param impostor defines the impostor to hide
  42586. */
  42587. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42588. private _getDebugMaterial;
  42589. private _getDebugBoxMesh;
  42590. private _getDebugSphereMesh;
  42591. private _getDebugCylinderMesh;
  42592. private _getDebugMeshMesh;
  42593. private _getDebugMesh;
  42594. /** Releases all resources */
  42595. dispose(): void;
  42596. }
  42597. }
  42598. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42599. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42600. import { Nullable } from "babylonjs/types";
  42601. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42602. import { Scene } from "babylonjs/scene";
  42603. /**
  42604. * Class containing static functions to help procedurally build meshes
  42605. */
  42606. export class LinesBuilder {
  42607. /**
  42608. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42609. * * 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
  42610. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42611. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42612. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42613. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42614. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42615. * * 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
  42616. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42619. * @param name defines the name of the new line system
  42620. * @param options defines the options used to create the line system
  42621. * @param scene defines the hosting scene
  42622. * @returns a new line system mesh
  42623. */
  42624. static CreateLineSystem(name: string, options: {
  42625. lines: Vector3[][];
  42626. updatable?: boolean;
  42627. instance?: Nullable<LinesMesh>;
  42628. colors?: Nullable<Color4[][]>;
  42629. useVertexAlpha?: boolean;
  42630. }, scene: Nullable<Scene>): LinesMesh;
  42631. /**
  42632. * Creates a line mesh
  42633. * 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
  42634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42635. * * The parameter `points` is an array successive Vector3
  42636. * * 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
  42637. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42638. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42639. * * When updating an instance, remember that only point positions can change, not the number of points
  42640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42642. * @param name defines the name of the new line system
  42643. * @param options defines the options used to create the line system
  42644. * @param scene defines the hosting scene
  42645. * @returns a new line mesh
  42646. */
  42647. static CreateLines(name: string, options: {
  42648. points: Vector3[];
  42649. updatable?: boolean;
  42650. instance?: Nullable<LinesMesh>;
  42651. colors?: Color4[];
  42652. useVertexAlpha?: boolean;
  42653. }, scene?: Nullable<Scene>): LinesMesh;
  42654. /**
  42655. * Creates a dashed line mesh
  42656. * * 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
  42657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42658. * * The parameter `points` is an array successive Vector3
  42659. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42660. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42661. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42662. * * 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
  42663. * * When updating an instance, remember that only point positions can change, not the number of points
  42664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42665. * @param name defines the name of the mesh
  42666. * @param options defines the options used to create the mesh
  42667. * @param scene defines the hosting scene
  42668. * @returns the dashed line mesh
  42669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42670. */
  42671. static CreateDashedLines(name: string, options: {
  42672. points: Vector3[];
  42673. dashSize?: number;
  42674. gapSize?: number;
  42675. dashNb?: number;
  42676. updatable?: boolean;
  42677. instance?: LinesMesh;
  42678. }, scene?: Nullable<Scene>): LinesMesh;
  42679. }
  42680. }
  42681. declare module "babylonjs/Debug/rayHelper" {
  42682. import { Nullable } from "babylonjs/types";
  42683. import { Ray } from "babylonjs/Culling/ray";
  42684. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42685. import { Scene } from "babylonjs/scene";
  42686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42687. import "babylonjs/Meshes/Builders/linesBuilder";
  42688. /**
  42689. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42690. * in order to better appreciate the issue one might have.
  42691. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42692. */
  42693. export class RayHelper {
  42694. /**
  42695. * Defines the ray we are currently tryin to visualize.
  42696. */
  42697. ray: Nullable<Ray>;
  42698. private _renderPoints;
  42699. private _renderLine;
  42700. private _renderFunction;
  42701. private _scene;
  42702. private _updateToMeshFunction;
  42703. private _attachedToMesh;
  42704. private _meshSpaceDirection;
  42705. private _meshSpaceOrigin;
  42706. /**
  42707. * Helper function to create a colored helper in a scene in one line.
  42708. * @param ray Defines the ray we are currently tryin to visualize
  42709. * @param scene Defines the scene the ray is used in
  42710. * @param color Defines the color we want to see the ray in
  42711. * @returns The newly created ray helper.
  42712. */
  42713. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42714. /**
  42715. * Instantiate a new ray helper.
  42716. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42717. * in order to better appreciate the issue one might have.
  42718. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42719. * @param ray Defines the ray we are currently tryin to visualize
  42720. */
  42721. constructor(ray: Ray);
  42722. /**
  42723. * Shows the ray we are willing to debug.
  42724. * @param scene Defines the scene the ray needs to be rendered in
  42725. * @param color Defines the color the ray needs to be rendered in
  42726. */
  42727. show(scene: Scene, color?: Color3): void;
  42728. /**
  42729. * Hides the ray we are debugging.
  42730. */
  42731. hide(): void;
  42732. private _render;
  42733. /**
  42734. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42735. * @param mesh Defines the mesh we want the helper attached to
  42736. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42737. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42738. * @param length Defines the length of the ray
  42739. */
  42740. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42741. /**
  42742. * Detach the ray helper from the mesh it has previously been attached to.
  42743. */
  42744. detachFromMesh(): void;
  42745. private _updateToMesh;
  42746. /**
  42747. * Dispose the helper and release its associated resources.
  42748. */
  42749. dispose(): void;
  42750. }
  42751. }
  42752. declare module "babylonjs/Debug/skeletonViewer" {
  42753. import { Color3 } from "babylonjs/Maths/math";
  42754. import { Scene } from "babylonjs/scene";
  42755. import { Nullable } from "babylonjs/types";
  42756. import { Skeleton } from "babylonjs/Bones/skeleton";
  42757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42758. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42759. /**
  42760. * Class used to render a debug view of a given skeleton
  42761. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42762. */
  42763. export class SkeletonViewer {
  42764. /** defines the skeleton to render */
  42765. skeleton: Skeleton;
  42766. /** defines the mesh attached to the skeleton */
  42767. mesh: AbstractMesh;
  42768. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42769. autoUpdateBonesMatrices: boolean;
  42770. /** defines the rendering group id to use with the viewer */
  42771. renderingGroupId: number;
  42772. /** Gets or sets the color used to render the skeleton */
  42773. color: Color3;
  42774. private _scene;
  42775. private _debugLines;
  42776. private _debugMesh;
  42777. private _isEnabled;
  42778. private _renderFunction;
  42779. private _utilityLayer;
  42780. /**
  42781. * Returns the mesh used to render the bones
  42782. */
  42783. readonly debugMesh: Nullable<LinesMesh>;
  42784. /**
  42785. * Creates a new SkeletonViewer
  42786. * @param skeleton defines the skeleton to render
  42787. * @param mesh defines the mesh attached to the skeleton
  42788. * @param scene defines the hosting scene
  42789. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42790. * @param renderingGroupId defines the rendering group id to use with the viewer
  42791. */
  42792. constructor(
  42793. /** defines the skeleton to render */
  42794. skeleton: Skeleton,
  42795. /** defines the mesh attached to the skeleton */
  42796. mesh: AbstractMesh, scene: Scene,
  42797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42798. autoUpdateBonesMatrices?: boolean,
  42799. /** defines the rendering group id to use with the viewer */
  42800. renderingGroupId?: number);
  42801. /** Gets or sets a boolean indicating if the viewer is enabled */
  42802. isEnabled: boolean;
  42803. private _getBonePosition;
  42804. private _getLinesForBonesWithLength;
  42805. private _getLinesForBonesNoLength;
  42806. /** Update the viewer to sync with current skeleton state */
  42807. update(): void;
  42808. /** Release associated resources */
  42809. dispose(): void;
  42810. }
  42811. }
  42812. declare module "babylonjs/Debug/index" {
  42813. export * from "babylonjs/Debug/axesViewer";
  42814. export * from "babylonjs/Debug/boneAxesViewer";
  42815. export * from "babylonjs/Debug/debugLayer";
  42816. export * from "babylonjs/Debug/physicsViewer";
  42817. export * from "babylonjs/Debug/rayHelper";
  42818. export * from "babylonjs/Debug/skeletonViewer";
  42819. }
  42820. declare module "babylonjs/Engines/nullEngine" {
  42821. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42822. import { Scene } from "babylonjs/scene";
  42823. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42824. import { Engine } from "babylonjs/Engines/engine";
  42825. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42826. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42827. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42828. import { Effect } from "babylonjs/Materials/effect";
  42829. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42830. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42831. /**
  42832. * Options to create the null engine
  42833. */
  42834. export class NullEngineOptions {
  42835. /**
  42836. * Render width (Default: 512)
  42837. */
  42838. renderWidth: number;
  42839. /**
  42840. * Render height (Default: 256)
  42841. */
  42842. renderHeight: number;
  42843. /**
  42844. * Texture size (Default: 512)
  42845. */
  42846. textureSize: number;
  42847. /**
  42848. * If delta time between frames should be constant
  42849. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42850. */
  42851. deterministicLockstep: boolean;
  42852. /**
  42853. * Maximum about of steps between frames (Default: 4)
  42854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42855. */
  42856. lockstepMaxSteps: number;
  42857. }
  42858. /**
  42859. * The null engine class provides support for headless version of babylon.js.
  42860. * This can be used in server side scenario or for testing purposes
  42861. */
  42862. export class NullEngine extends Engine {
  42863. private _options;
  42864. /**
  42865. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42866. */
  42867. isDeterministicLockStep(): boolean;
  42868. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42869. getLockstepMaxSteps(): number;
  42870. /**
  42871. * Sets hardware scaling, used to save performance if needed
  42872. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42873. */
  42874. getHardwareScalingLevel(): number;
  42875. constructor(options?: NullEngineOptions);
  42876. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42877. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42878. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42879. getRenderWidth(useScreen?: boolean): number;
  42880. getRenderHeight(useScreen?: boolean): number;
  42881. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42882. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42883. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42884. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42885. bindSamplers(effect: Effect): void;
  42886. enableEffect(effect: Effect): void;
  42887. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42888. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42889. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42890. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42891. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42893. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42894. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42895. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42896. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42897. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42898. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42899. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42900. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42901. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42902. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42903. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42904. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42905. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42906. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42907. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42908. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42909. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42910. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42911. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42912. bindBuffers(vertexBuffers: {
  42913. [key: string]: VertexBuffer;
  42914. }, indexBuffer: DataBuffer, effect: Effect): void;
  42915. wipeCaches(bruteForce?: boolean): void;
  42916. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42917. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42918. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42919. /** @hidden */
  42920. _createTexture(): WebGLTexture;
  42921. /** @hidden */
  42922. _releaseTexture(texture: InternalTexture): void;
  42923. 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;
  42924. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42925. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42926. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42927. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42928. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42929. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42930. areAllEffectsReady(): boolean;
  42931. /**
  42932. * @hidden
  42933. * Get the current error code of the webGL context
  42934. * @returns the error code
  42935. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42936. */
  42937. getError(): number;
  42938. /** @hidden */
  42939. _getUnpackAlignement(): number;
  42940. /** @hidden */
  42941. _unpackFlipY(value: boolean): void;
  42942. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42943. /**
  42944. * Updates a dynamic vertex buffer.
  42945. * @param vertexBuffer the vertex buffer to update
  42946. * @param data the data used to update the vertex buffer
  42947. * @param byteOffset the byte offset of the data (optional)
  42948. * @param byteLength the byte length of the data (optional)
  42949. */
  42950. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42951. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42952. /** @hidden */
  42953. _bindTexture(channel: number, texture: InternalTexture): void;
  42954. /** @hidden */
  42955. _releaseBuffer(buffer: DataBuffer): boolean;
  42956. releaseEffects(): void;
  42957. displayLoadingUI(): void;
  42958. hideLoadingUI(): void;
  42959. /** @hidden */
  42960. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42961. /** @hidden */
  42962. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42963. /** @hidden */
  42964. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42965. /** @hidden */
  42966. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42967. }
  42968. }
  42969. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42970. import { Nullable, int } from "babylonjs/types";
  42971. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42972. /** @hidden */
  42973. export class _OcclusionDataStorage {
  42974. /** @hidden */
  42975. occlusionInternalRetryCounter: number;
  42976. /** @hidden */
  42977. isOcclusionQueryInProgress: boolean;
  42978. /** @hidden */
  42979. isOccluded: boolean;
  42980. /** @hidden */
  42981. occlusionRetryCount: number;
  42982. /** @hidden */
  42983. occlusionType: number;
  42984. /** @hidden */
  42985. occlusionQueryAlgorithmType: number;
  42986. }
  42987. module "babylonjs/Engines/engine" {
  42988. interface Engine {
  42989. /**
  42990. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42991. * @return the new query
  42992. */
  42993. createQuery(): WebGLQuery;
  42994. /**
  42995. * Delete and release a webGL query
  42996. * @param query defines the query to delete
  42997. * @return the current engine
  42998. */
  42999. deleteQuery(query: WebGLQuery): Engine;
  43000. /**
  43001. * Check if a given query has resolved and got its value
  43002. * @param query defines the query to check
  43003. * @returns true if the query got its value
  43004. */
  43005. isQueryResultAvailable(query: WebGLQuery): boolean;
  43006. /**
  43007. * Gets the value of a given query
  43008. * @param query defines the query to check
  43009. * @returns the value of the query
  43010. */
  43011. getQueryResult(query: WebGLQuery): number;
  43012. /**
  43013. * Initiates an occlusion query
  43014. * @param algorithmType defines the algorithm to use
  43015. * @param query defines the query to use
  43016. * @returns the current engine
  43017. * @see http://doc.babylonjs.com/features/occlusionquery
  43018. */
  43019. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43020. /**
  43021. * Ends an occlusion query
  43022. * @see http://doc.babylonjs.com/features/occlusionquery
  43023. * @param algorithmType defines the algorithm to use
  43024. * @returns the current engine
  43025. */
  43026. endOcclusionQuery(algorithmType: number): Engine;
  43027. /**
  43028. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43029. * Please note that only one query can be issued at a time
  43030. * @returns a time token used to track the time span
  43031. */
  43032. startTimeQuery(): Nullable<_TimeToken>;
  43033. /**
  43034. * Ends a time query
  43035. * @param token defines the token used to measure the time span
  43036. * @returns the time spent (in ns)
  43037. */
  43038. endTimeQuery(token: _TimeToken): int;
  43039. /** @hidden */
  43040. _currentNonTimestampToken: Nullable<_TimeToken>;
  43041. /** @hidden */
  43042. _createTimeQuery(): WebGLQuery;
  43043. /** @hidden */
  43044. _deleteTimeQuery(query: WebGLQuery): void;
  43045. /** @hidden */
  43046. _getGlAlgorithmType(algorithmType: number): number;
  43047. /** @hidden */
  43048. _getTimeQueryResult(query: WebGLQuery): any;
  43049. /** @hidden */
  43050. _getTimeQueryAvailability(query: WebGLQuery): any;
  43051. }
  43052. }
  43053. module "babylonjs/Meshes/abstractMesh" {
  43054. interface AbstractMesh {
  43055. /**
  43056. * Backing filed
  43057. * @hidden
  43058. */
  43059. __occlusionDataStorage: _OcclusionDataStorage;
  43060. /**
  43061. * Access property
  43062. * @hidden
  43063. */
  43064. _occlusionDataStorage: _OcclusionDataStorage;
  43065. /**
  43066. * 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.
  43067. * The default value is -1 which means don't break the query and wait till the result
  43068. * @see http://doc.babylonjs.com/features/occlusionquery
  43069. */
  43070. occlusionRetryCount: number;
  43071. /**
  43072. * 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:
  43073. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43074. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43075. * * 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.
  43076. * @see http://doc.babylonjs.com/features/occlusionquery
  43077. */
  43078. occlusionType: number;
  43079. /**
  43080. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43081. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43082. * * 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.
  43083. * @see http://doc.babylonjs.com/features/occlusionquery
  43084. */
  43085. occlusionQueryAlgorithmType: number;
  43086. /**
  43087. * 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
  43088. * @see http://doc.babylonjs.com/features/occlusionquery
  43089. */
  43090. isOccluded: boolean;
  43091. /**
  43092. * Flag to check the progress status of the query
  43093. * @see http://doc.babylonjs.com/features/occlusionquery
  43094. */
  43095. isOcclusionQueryInProgress: boolean;
  43096. }
  43097. }
  43098. }
  43099. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43100. import { Nullable } from "babylonjs/types";
  43101. /** @hidden */
  43102. export var _forceTransformFeedbackToBundle: boolean;
  43103. module "babylonjs/Engines/engine" {
  43104. interface Engine {
  43105. /**
  43106. * Creates a webGL transform feedback object
  43107. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43108. * @returns the webGL transform feedback object
  43109. */
  43110. createTransformFeedback(): WebGLTransformFeedback;
  43111. /**
  43112. * Delete a webGL transform feedback object
  43113. * @param value defines the webGL transform feedback object to delete
  43114. */
  43115. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43116. /**
  43117. * Bind a webGL transform feedback object to the webgl context
  43118. * @param value defines the webGL transform feedback object to bind
  43119. */
  43120. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43121. /**
  43122. * Begins a transform feedback operation
  43123. * @param usePoints defines if points or triangles must be used
  43124. */
  43125. beginTransformFeedback(usePoints: boolean): void;
  43126. /**
  43127. * Ends a transform feedback operation
  43128. */
  43129. endTransformFeedback(): void;
  43130. /**
  43131. * Specify the varyings to use with transform feedback
  43132. * @param program defines the associated webGL program
  43133. * @param value defines the list of strings representing the varying names
  43134. */
  43135. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43136. /**
  43137. * Bind a webGL buffer for a transform feedback operation
  43138. * @param value defines the webGL buffer to bind
  43139. */
  43140. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43141. }
  43142. }
  43143. }
  43144. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43145. import { Scene } from "babylonjs/scene";
  43146. import { Engine } from "babylonjs/Engines/engine";
  43147. import { Texture } from "babylonjs/Materials/Textures/texture";
  43148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43149. import "babylonjs/Engines/Extensions/engine.multiRender";
  43150. /**
  43151. * Creation options of the multi render target texture.
  43152. */
  43153. export interface IMultiRenderTargetOptions {
  43154. /**
  43155. * Define if the texture needs to create mip maps after render.
  43156. */
  43157. generateMipMaps?: boolean;
  43158. /**
  43159. * Define the types of all the draw buffers we want to create
  43160. */
  43161. types?: number[];
  43162. /**
  43163. * Define the sampling modes of all the draw buffers we want to create
  43164. */
  43165. samplingModes?: number[];
  43166. /**
  43167. * Define if a depth buffer is required
  43168. */
  43169. generateDepthBuffer?: boolean;
  43170. /**
  43171. * Define if a stencil buffer is required
  43172. */
  43173. generateStencilBuffer?: boolean;
  43174. /**
  43175. * Define if a depth texture is required instead of a depth buffer
  43176. */
  43177. generateDepthTexture?: boolean;
  43178. /**
  43179. * Define the number of desired draw buffers
  43180. */
  43181. textureCount?: number;
  43182. /**
  43183. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43184. */
  43185. doNotChangeAspectRatio?: boolean;
  43186. /**
  43187. * Define the default type of the buffers we are creating
  43188. */
  43189. defaultType?: number;
  43190. }
  43191. /**
  43192. * A multi render target, like a render target provides the ability to render to a texture.
  43193. * Unlike the render target, it can render to several draw buffers in one draw.
  43194. * This is specially interesting in deferred rendering or for any effects requiring more than
  43195. * just one color from a single pass.
  43196. */
  43197. export class MultiRenderTarget extends RenderTargetTexture {
  43198. private _internalTextures;
  43199. private _textures;
  43200. private _multiRenderTargetOptions;
  43201. /**
  43202. * Get if draw buffers are currently supported by the used hardware and browser.
  43203. */
  43204. readonly isSupported: boolean;
  43205. /**
  43206. * Get the list of textures generated by the multi render target.
  43207. */
  43208. readonly textures: Texture[];
  43209. /**
  43210. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43211. */
  43212. readonly depthTexture: Texture;
  43213. /**
  43214. * Set the wrapping mode on U of all the textures we are rendering to.
  43215. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43216. */
  43217. wrapU: number;
  43218. /**
  43219. * Set the wrapping mode on V of all the textures we are rendering to.
  43220. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43221. */
  43222. wrapV: number;
  43223. /**
  43224. * Instantiate a new multi render target texture.
  43225. * A multi render target, like a render target provides the ability to render to a texture.
  43226. * Unlike the render target, it can render to several draw buffers in one draw.
  43227. * This is specially interesting in deferred rendering or for any effects requiring more than
  43228. * just one color from a single pass.
  43229. * @param name Define the name of the texture
  43230. * @param size Define the size of the buffers to render to
  43231. * @param count Define the number of target we are rendering into
  43232. * @param scene Define the scene the texture belongs to
  43233. * @param options Define the options used to create the multi render target
  43234. */
  43235. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43236. /** @hidden */
  43237. _rebuild(): void;
  43238. private _createInternalTextures;
  43239. private _createTextures;
  43240. /**
  43241. * Define the number of samples used if MSAA is enabled.
  43242. */
  43243. samples: number;
  43244. /**
  43245. * Resize all the textures in the multi render target.
  43246. * Be carrefull as it will recreate all the data in the new texture.
  43247. * @param size Define the new size
  43248. */
  43249. resize(size: any): void;
  43250. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43251. /**
  43252. * Dispose the render targets and their associated resources
  43253. */
  43254. dispose(): void;
  43255. /**
  43256. * Release all the underlying texture used as draw buffers.
  43257. */
  43258. releaseInternalTextures(): void;
  43259. }
  43260. }
  43261. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43263. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43264. import { Nullable } from "babylonjs/types";
  43265. module "babylonjs/Engines/engine" {
  43266. interface Engine {
  43267. /**
  43268. * Unbind a list of render target textures from the webGL context
  43269. * This is used only when drawBuffer extension or webGL2 are active
  43270. * @param textures defines the render target textures to unbind
  43271. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43272. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43273. */
  43274. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43275. /**
  43276. * Create a multi render target texture
  43277. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43278. * @param size defines the size of the texture
  43279. * @param options defines the creation options
  43280. * @returns the cube texture as an InternalTexture
  43281. */
  43282. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43283. /**
  43284. * Update the sample count for a given multiple render target texture
  43285. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43286. * @param textures defines the textures to update
  43287. * @param samples defines the sample count to set
  43288. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43289. */
  43290. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43291. }
  43292. }
  43293. }
  43294. declare module "babylonjs/Engines/Extensions/index" {
  43295. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43296. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43297. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43298. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43299. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43300. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43301. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43302. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43303. }
  43304. declare module "babylonjs/Engines/index" {
  43305. export * from "babylonjs/Engines/constants";
  43306. export * from "babylonjs/Engines/engine";
  43307. export * from "babylonjs/Engines/engineStore";
  43308. export * from "babylonjs/Engines/nullEngine";
  43309. export * from "babylonjs/Engines/Extensions/index";
  43310. export * from "babylonjs/Engines/IPipelineContext";
  43311. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43312. }
  43313. declare module "babylonjs/Events/clipboardEvents" {
  43314. /**
  43315. * Gather the list of clipboard event types as constants.
  43316. */
  43317. export class ClipboardEventTypes {
  43318. /**
  43319. * The clipboard event is fired when a copy command is active (pressed).
  43320. */
  43321. static readonly COPY: number;
  43322. /**
  43323. * The clipboard event is fired when a cut command is active (pressed).
  43324. */
  43325. static readonly CUT: number;
  43326. /**
  43327. * The clipboard event is fired when a paste command is active (pressed).
  43328. */
  43329. static readonly PASTE: number;
  43330. }
  43331. /**
  43332. * This class is used to store clipboard related info for the onClipboardObservable event.
  43333. */
  43334. export class ClipboardInfo {
  43335. /**
  43336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43337. */
  43338. type: number;
  43339. /**
  43340. * Defines the related dom event
  43341. */
  43342. event: ClipboardEvent;
  43343. /**
  43344. *Creates an instance of ClipboardInfo.
  43345. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43346. * @param event Defines the related dom event
  43347. */
  43348. constructor(
  43349. /**
  43350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43351. */
  43352. type: number,
  43353. /**
  43354. * Defines the related dom event
  43355. */
  43356. event: ClipboardEvent);
  43357. /**
  43358. * Get the clipboard event's type from the keycode.
  43359. * @param keyCode Defines the keyCode for the current keyboard event.
  43360. * @return {number}
  43361. */
  43362. static GetTypeFromCharacter(keyCode: number): number;
  43363. }
  43364. }
  43365. declare module "babylonjs/Events/index" {
  43366. export * from "babylonjs/Events/keyboardEvents";
  43367. export * from "babylonjs/Events/pointerEvents";
  43368. export * from "babylonjs/Events/clipboardEvents";
  43369. }
  43370. declare module "babylonjs/Loading/sceneLoader" {
  43371. import { Observable } from "babylonjs/Misc/observable";
  43372. import { Nullable } from "babylonjs/types";
  43373. import { Scene } from "babylonjs/scene";
  43374. import { Engine } from "babylonjs/Engines/engine";
  43375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43376. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43377. import { AssetContainer } from "babylonjs/assetContainer";
  43378. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43379. import { Skeleton } from "babylonjs/Bones/skeleton";
  43380. /**
  43381. * Class used to represent data loading progression
  43382. */
  43383. export class SceneLoaderProgressEvent {
  43384. /** defines if data length to load can be evaluated */
  43385. readonly lengthComputable: boolean;
  43386. /** defines the loaded data length */
  43387. readonly loaded: number;
  43388. /** defines the data length to load */
  43389. readonly total: number;
  43390. /**
  43391. * Create a new progress event
  43392. * @param lengthComputable defines if data length to load can be evaluated
  43393. * @param loaded defines the loaded data length
  43394. * @param total defines the data length to load
  43395. */
  43396. constructor(
  43397. /** defines if data length to load can be evaluated */
  43398. lengthComputable: boolean,
  43399. /** defines the loaded data length */
  43400. loaded: number,
  43401. /** defines the data length to load */
  43402. total: number);
  43403. /**
  43404. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43405. * @param event defines the source event
  43406. * @returns a new SceneLoaderProgressEvent
  43407. */
  43408. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43409. }
  43410. /**
  43411. * Interface used by SceneLoader plugins to define supported file extensions
  43412. */
  43413. export interface ISceneLoaderPluginExtensions {
  43414. /**
  43415. * Defines the list of supported extensions
  43416. */
  43417. [extension: string]: {
  43418. isBinary: boolean;
  43419. };
  43420. }
  43421. /**
  43422. * Interface used by SceneLoader plugin factory
  43423. */
  43424. export interface ISceneLoaderPluginFactory {
  43425. /**
  43426. * Defines the name of the factory
  43427. */
  43428. name: string;
  43429. /**
  43430. * Function called to create a new plugin
  43431. * @return the new plugin
  43432. */
  43433. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43434. /**
  43435. * Boolean indicating if the plugin can direct load specific data
  43436. */
  43437. canDirectLoad?: (data: string) => boolean;
  43438. }
  43439. /**
  43440. * Interface used to define a SceneLoader plugin
  43441. */
  43442. export interface ISceneLoaderPlugin {
  43443. /**
  43444. * The friendly name of this plugin.
  43445. */
  43446. name: string;
  43447. /**
  43448. * The file extensions supported by this plugin.
  43449. */
  43450. extensions: string | ISceneLoaderPluginExtensions;
  43451. /**
  43452. * Import meshes into a scene.
  43453. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43454. * @param scene The scene to import into
  43455. * @param data The data to import
  43456. * @param rootUrl The root url for scene and resources
  43457. * @param meshes The meshes array to import into
  43458. * @param particleSystems The particle systems array to import into
  43459. * @param skeletons The skeletons array to import into
  43460. * @param onError The callback when import fails
  43461. * @returns True if successful or false otherwise
  43462. */
  43463. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43464. /**
  43465. * Load into a scene.
  43466. * @param scene The scene to load into
  43467. * @param data The data to import
  43468. * @param rootUrl The root url for scene and resources
  43469. * @param onError The callback when import fails
  43470. * @returns true if successful or false otherwise
  43471. */
  43472. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43473. /**
  43474. * The callback that returns true if the data can be directly loaded.
  43475. */
  43476. canDirectLoad?: (data: string) => boolean;
  43477. /**
  43478. * The callback that allows custom handling of the root url based on the response url.
  43479. */
  43480. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43481. /**
  43482. * Load into an asset container.
  43483. * @param scene The scene to load into
  43484. * @param data The data to import
  43485. * @param rootUrl The root url for scene and resources
  43486. * @param onError The callback when import fails
  43487. * @returns The loaded asset container
  43488. */
  43489. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43490. }
  43491. /**
  43492. * Interface used to define an async SceneLoader plugin
  43493. */
  43494. export interface ISceneLoaderPluginAsync {
  43495. /**
  43496. * The friendly name of this plugin.
  43497. */
  43498. name: string;
  43499. /**
  43500. * The file extensions supported by this plugin.
  43501. */
  43502. extensions: string | ISceneLoaderPluginExtensions;
  43503. /**
  43504. * Import meshes into a scene.
  43505. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43506. * @param scene The scene to import into
  43507. * @param data The data to import
  43508. * @param rootUrl The root url for scene and resources
  43509. * @param onProgress The callback when the load progresses
  43510. * @param fileName Defines the name of the file to load
  43511. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43512. */
  43513. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43514. meshes: AbstractMesh[];
  43515. particleSystems: IParticleSystem[];
  43516. skeletons: Skeleton[];
  43517. animationGroups: AnimationGroup[];
  43518. }>;
  43519. /**
  43520. * Load into a scene.
  43521. * @param scene The scene to load into
  43522. * @param data The data to import
  43523. * @param rootUrl The root url for scene and resources
  43524. * @param onProgress The callback when the load progresses
  43525. * @param fileName Defines the name of the file to load
  43526. * @returns Nothing
  43527. */
  43528. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43529. /**
  43530. * The callback that returns true if the data can be directly loaded.
  43531. */
  43532. canDirectLoad?: (data: string) => boolean;
  43533. /**
  43534. * The callback that allows custom handling of the root url based on the response url.
  43535. */
  43536. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43537. /**
  43538. * Load into an asset container.
  43539. * @param scene The scene to load into
  43540. * @param data The data to import
  43541. * @param rootUrl The root url for scene and resources
  43542. * @param onProgress The callback when the load progresses
  43543. * @param fileName Defines the name of the file to load
  43544. * @returns The loaded asset container
  43545. */
  43546. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43547. }
  43548. /**
  43549. * Class used to load scene from various file formats using registered plugins
  43550. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43551. */
  43552. export class SceneLoader {
  43553. /**
  43554. * No logging while loading
  43555. */
  43556. static readonly NO_LOGGING: number;
  43557. /**
  43558. * Minimal logging while loading
  43559. */
  43560. static readonly MINIMAL_LOGGING: number;
  43561. /**
  43562. * Summary logging while loading
  43563. */
  43564. static readonly SUMMARY_LOGGING: number;
  43565. /**
  43566. * Detailled logging while loading
  43567. */
  43568. static readonly DETAILED_LOGGING: number;
  43569. /**
  43570. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43571. */
  43572. static ForceFullSceneLoadingForIncremental: boolean;
  43573. /**
  43574. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43575. */
  43576. static ShowLoadingScreen: boolean;
  43577. /**
  43578. * Defines the current logging level (while loading the scene)
  43579. * @ignorenaming
  43580. */
  43581. static loggingLevel: number;
  43582. /**
  43583. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43584. */
  43585. static CleanBoneMatrixWeights: boolean;
  43586. /**
  43587. * Event raised when a plugin is used to load a scene
  43588. */
  43589. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43590. private static _registeredPlugins;
  43591. private static _getDefaultPlugin;
  43592. private static _getPluginForExtension;
  43593. private static _getPluginForDirectLoad;
  43594. private static _getPluginForFilename;
  43595. private static _getDirectLoad;
  43596. private static _loadData;
  43597. private static _getFileInfo;
  43598. /**
  43599. * Gets a plugin that can load the given extension
  43600. * @param extension defines the extension to load
  43601. * @returns a plugin or null if none works
  43602. */
  43603. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43604. /**
  43605. * Gets a boolean indicating that the given extension can be loaded
  43606. * @param extension defines the extension to load
  43607. * @returns true if the extension is supported
  43608. */
  43609. static IsPluginForExtensionAvailable(extension: string): boolean;
  43610. /**
  43611. * Adds a new plugin to the list of registered plugins
  43612. * @param plugin defines the plugin to add
  43613. */
  43614. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43615. /**
  43616. * Import meshes into a scene
  43617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43618. * @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)
  43619. * @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)
  43620. * @param scene the instance of BABYLON.Scene to append to
  43621. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43622. * @param onProgress a callback with a progress event for each file being loaded
  43623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43624. * @param pluginExtension the extension used to determine the plugin
  43625. * @returns The loaded plugin
  43626. */
  43627. 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>;
  43628. /**
  43629. * Import meshes into a scene
  43630. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43631. * @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)
  43632. * @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)
  43633. * @param scene the instance of BABYLON.Scene to append to
  43634. * @param onProgress a callback with a progress event for each file being loaded
  43635. * @param pluginExtension the extension used to determine the plugin
  43636. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43637. */
  43638. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43639. meshes: AbstractMesh[];
  43640. particleSystems: IParticleSystem[];
  43641. skeletons: Skeleton[];
  43642. animationGroups: AnimationGroup[];
  43643. }>;
  43644. /**
  43645. * Load a scene
  43646. * @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)
  43647. * @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)
  43648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43649. * @param onSuccess a callback with the scene when import succeeds
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43652. * @param pluginExtension the extension used to determine the plugin
  43653. * @returns The loaded plugin
  43654. */
  43655. 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>;
  43656. /**
  43657. * Load a scene
  43658. * @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)
  43659. * @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)
  43660. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43661. * @param onProgress a callback with a progress event for each file being loaded
  43662. * @param pluginExtension the extension used to determine the plugin
  43663. * @returns The loaded scene
  43664. */
  43665. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43666. /**
  43667. * Append a scene
  43668. * @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)
  43669. * @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)
  43670. * @param scene is the instance of BABYLON.Scene to append to
  43671. * @param onSuccess a callback with the scene when import succeeds
  43672. * @param onProgress a callback with a progress event for each file being loaded
  43673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43674. * @param pluginExtension the extension used to determine the plugin
  43675. * @returns The loaded plugin
  43676. */
  43677. 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>;
  43678. /**
  43679. * Append a scene
  43680. * @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)
  43681. * @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)
  43682. * @param scene is the instance of BABYLON.Scene to append to
  43683. * @param onProgress a callback with a progress event for each file being loaded
  43684. * @param pluginExtension the extension used to determine the plugin
  43685. * @returns The given scene
  43686. */
  43687. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43688. /**
  43689. * Load a scene into an asset container
  43690. * @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)
  43691. * @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)
  43692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43693. * @param onSuccess a callback with the scene when import succeeds
  43694. * @param onProgress a callback with a progress event for each file being loaded
  43695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43696. * @param pluginExtension the extension used to determine the plugin
  43697. * @returns The loaded plugin
  43698. */
  43699. 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>;
  43700. /**
  43701. * Load a scene into an asset container
  43702. * @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)
  43703. * @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)
  43704. * @param scene is the instance of Scene to append to
  43705. * @param onProgress a callback with a progress event for each file being loaded
  43706. * @param pluginExtension the extension used to determine the plugin
  43707. * @returns The loaded asset container
  43708. */
  43709. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43710. }
  43711. }
  43712. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43713. import { Scene } from "babylonjs/scene";
  43714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43715. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43717. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43718. /**
  43719. * Google Daydream controller
  43720. */
  43721. export class DaydreamController extends WebVRController {
  43722. /**
  43723. * Base Url for the controller model.
  43724. */
  43725. static MODEL_BASE_URL: string;
  43726. /**
  43727. * File name for the controller model.
  43728. */
  43729. static MODEL_FILENAME: string;
  43730. /**
  43731. * Gamepad Id prefix used to identify Daydream Controller.
  43732. */
  43733. static readonly GAMEPAD_ID_PREFIX: string;
  43734. /**
  43735. * Creates a new DaydreamController from a gamepad
  43736. * @param vrGamepad the gamepad that the controller should be created from
  43737. */
  43738. constructor(vrGamepad: any);
  43739. /**
  43740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43741. * @param scene scene in which to add meshes
  43742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43743. */
  43744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43745. /**
  43746. * Called once for each button that changed state since the last frame
  43747. * @param buttonIdx Which button index changed
  43748. * @param state New state of the button
  43749. * @param changes Which properties on the state changed since last frame
  43750. */
  43751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43752. }
  43753. }
  43754. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43755. import { Scene } from "babylonjs/scene";
  43756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43757. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43758. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43759. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43760. /**
  43761. * Gear VR Controller
  43762. */
  43763. export class GearVRController extends WebVRController {
  43764. /**
  43765. * Base Url for the controller model.
  43766. */
  43767. static MODEL_BASE_URL: string;
  43768. /**
  43769. * File name for the controller model.
  43770. */
  43771. static MODEL_FILENAME: string;
  43772. /**
  43773. * Gamepad Id prefix used to identify this controller.
  43774. */
  43775. static readonly GAMEPAD_ID_PREFIX: string;
  43776. private readonly _buttonIndexToObservableNameMap;
  43777. /**
  43778. * Creates a new GearVRController from a gamepad
  43779. * @param vrGamepad the gamepad that the controller should be created from
  43780. */
  43781. constructor(vrGamepad: any);
  43782. /**
  43783. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43784. * @param scene scene in which to add meshes
  43785. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43786. */
  43787. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43788. /**
  43789. * Called once for each button that changed state since the last frame
  43790. * @param buttonIdx Which button index changed
  43791. * @param state New state of the button
  43792. * @param changes Which properties on the state changed since last frame
  43793. */
  43794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43795. }
  43796. }
  43797. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43798. import { Scene } from "babylonjs/scene";
  43799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43800. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43801. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43802. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43803. /**
  43804. * Generic Controller
  43805. */
  43806. export class GenericController extends WebVRController {
  43807. /**
  43808. * Base Url for the controller model.
  43809. */
  43810. static readonly MODEL_BASE_URL: string;
  43811. /**
  43812. * File name for the controller model.
  43813. */
  43814. static readonly MODEL_FILENAME: string;
  43815. /**
  43816. * Creates a new GenericController from a gamepad
  43817. * @param vrGamepad the gamepad that the controller should be created from
  43818. */
  43819. constructor(vrGamepad: any);
  43820. /**
  43821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43822. * @param scene scene in which to add meshes
  43823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43824. */
  43825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43826. /**
  43827. * Called once for each button that changed state since the last frame
  43828. * @param buttonIdx Which button index changed
  43829. * @param state New state of the button
  43830. * @param changes Which properties on the state changed since last frame
  43831. */
  43832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43833. }
  43834. }
  43835. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43836. import { Observable } from "babylonjs/Misc/observable";
  43837. import { Scene } from "babylonjs/scene";
  43838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43839. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43840. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43841. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43842. /**
  43843. * Oculus Touch Controller
  43844. */
  43845. export class OculusTouchController extends WebVRController {
  43846. /**
  43847. * Base Url for the controller model.
  43848. */
  43849. static MODEL_BASE_URL: string;
  43850. /**
  43851. * File name for the left controller model.
  43852. */
  43853. static MODEL_LEFT_FILENAME: string;
  43854. /**
  43855. * File name for the right controller model.
  43856. */
  43857. static MODEL_RIGHT_FILENAME: string;
  43858. /**
  43859. * Fired when the secondary trigger on this controller is modified
  43860. */
  43861. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43862. /**
  43863. * Fired when the thumb rest on this controller is modified
  43864. */
  43865. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43866. /**
  43867. * Creates a new OculusTouchController from a gamepad
  43868. * @param vrGamepad the gamepad that the controller should be created from
  43869. */
  43870. constructor(vrGamepad: any);
  43871. /**
  43872. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43873. * @param scene scene in which to add meshes
  43874. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43875. */
  43876. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43877. /**
  43878. * Fired when the A button on this controller is modified
  43879. */
  43880. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43881. /**
  43882. * Fired when the B button on this controller is modified
  43883. */
  43884. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43885. /**
  43886. * Fired when the X button on this controller is modified
  43887. */
  43888. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the Y button on this controller is modified
  43891. */
  43892. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Called once for each button that changed state since the last frame
  43895. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43896. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43897. * 2) secondary trigger (same)
  43898. * 3) A (right) X (left), touch, pressed = value
  43899. * 4) B / Y
  43900. * 5) thumb rest
  43901. * @param buttonIdx Which button index changed
  43902. * @param state New state of the button
  43903. * @param changes Which properties on the state changed since last frame
  43904. */
  43905. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43906. }
  43907. }
  43908. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43909. import { Scene } from "babylonjs/scene";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43912. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43913. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43914. import { Observable } from "babylonjs/Misc/observable";
  43915. /**
  43916. * Vive Controller
  43917. */
  43918. export class ViveController extends WebVRController {
  43919. /**
  43920. * Base Url for the controller model.
  43921. */
  43922. static MODEL_BASE_URL: string;
  43923. /**
  43924. * File name for the controller model.
  43925. */
  43926. static MODEL_FILENAME: string;
  43927. /**
  43928. * Creates a new ViveController from a gamepad
  43929. * @param vrGamepad the gamepad that the controller should be created from
  43930. */
  43931. constructor(vrGamepad: any);
  43932. /**
  43933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43934. * @param scene scene in which to add meshes
  43935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43936. */
  43937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43938. /**
  43939. * Fired when the left button on this controller is modified
  43940. */
  43941. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43942. /**
  43943. * Fired when the right button on this controller is modified
  43944. */
  43945. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43946. /**
  43947. * Fired when the menu button on this controller is modified
  43948. */
  43949. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Called once for each button that changed state since the last frame
  43952. * Vive mapping:
  43953. * 0: touchpad
  43954. * 1: trigger
  43955. * 2: left AND right buttons
  43956. * 3: menu button
  43957. * @param buttonIdx Which button index changed
  43958. * @param state New state of the button
  43959. * @param changes Which properties on the state changed since last frame
  43960. */
  43961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43962. }
  43963. }
  43964. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43965. import { Observable } from "babylonjs/Misc/observable";
  43966. import { Scene } from "babylonjs/scene";
  43967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43968. import { Ray } from "babylonjs/Culling/ray";
  43969. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43970. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43971. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43972. /**
  43973. * Defines the WindowsMotionController object that the state of the windows motion controller
  43974. */
  43975. export class WindowsMotionController extends WebVRController {
  43976. /**
  43977. * The base url used to load the left and right controller models
  43978. */
  43979. static MODEL_BASE_URL: string;
  43980. /**
  43981. * The name of the left controller model file
  43982. */
  43983. static MODEL_LEFT_FILENAME: string;
  43984. /**
  43985. * The name of the right controller model file
  43986. */
  43987. static MODEL_RIGHT_FILENAME: string;
  43988. /**
  43989. * The controller name prefix for this controller type
  43990. */
  43991. static readonly GAMEPAD_ID_PREFIX: string;
  43992. /**
  43993. * The controller id pattern for this controller type
  43994. */
  43995. private static readonly GAMEPAD_ID_PATTERN;
  43996. private _loadedMeshInfo;
  43997. private readonly _mapping;
  43998. /**
  43999. * Fired when the trackpad on this controller is clicked
  44000. */
  44001. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44002. /**
  44003. * Fired when the trackpad on this controller is modified
  44004. */
  44005. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44006. /**
  44007. * The current x and y values of this controller's trackpad
  44008. */
  44009. trackpad: StickValues;
  44010. /**
  44011. * Creates a new WindowsMotionController from a gamepad
  44012. * @param vrGamepad the gamepad that the controller should be created from
  44013. */
  44014. constructor(vrGamepad: any);
  44015. /**
  44016. * Fired when the trigger on this controller is modified
  44017. */
  44018. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44019. /**
  44020. * Fired when the menu button on this controller is modified
  44021. */
  44022. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44023. /**
  44024. * Fired when the grip button on this controller is modified
  44025. */
  44026. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44027. /**
  44028. * Fired when the thumbstick button on this controller is modified
  44029. */
  44030. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44031. /**
  44032. * Fired when the touchpad button on this controller is modified
  44033. */
  44034. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44035. /**
  44036. * Fired when the touchpad values on this controller are modified
  44037. */
  44038. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44039. private _updateTrackpad;
  44040. /**
  44041. * Called once per frame by the engine.
  44042. */
  44043. update(): void;
  44044. /**
  44045. * Called once for each button that changed state since the last frame
  44046. * @param buttonIdx Which button index changed
  44047. * @param state New state of the button
  44048. * @param changes Which properties on the state changed since last frame
  44049. */
  44050. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44051. /**
  44052. * Moves the buttons on the controller mesh based on their current state
  44053. * @param buttonName the name of the button to move
  44054. * @param buttonValue the value of the button which determines the buttons new position
  44055. */
  44056. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44057. /**
  44058. * Moves the axis on the controller mesh based on its current state
  44059. * @param axis the index of the axis
  44060. * @param axisValue the value of the axis which determines the meshes new position
  44061. * @hidden
  44062. */
  44063. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44064. /**
  44065. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44066. * @param scene scene in which to add meshes
  44067. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44068. */
  44069. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44070. /**
  44071. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44072. * can be transformed by button presses and axes values, based on this._mapping.
  44073. *
  44074. * @param scene scene in which the meshes exist
  44075. * @param meshes list of meshes that make up the controller model to process
  44076. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44077. */
  44078. private processModel;
  44079. private createMeshInfo;
  44080. /**
  44081. * Gets the ray of the controller in the direction the controller is pointing
  44082. * @param length the length the resulting ray should be
  44083. * @returns a ray in the direction the controller is pointing
  44084. */
  44085. getForwardRay(length?: number): Ray;
  44086. /**
  44087. * Disposes of the controller
  44088. */
  44089. dispose(): void;
  44090. }
  44091. }
  44092. declare module "babylonjs/Gamepads/Controllers/index" {
  44093. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44094. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44095. export * from "babylonjs/Gamepads/Controllers/genericController";
  44096. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44097. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44098. export * from "babylonjs/Gamepads/Controllers/viveController";
  44099. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44100. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44101. }
  44102. declare module "babylonjs/Gamepads/index" {
  44103. export * from "babylonjs/Gamepads/Controllers/index";
  44104. export * from "babylonjs/Gamepads/gamepad";
  44105. export * from "babylonjs/Gamepads/gamepadManager";
  44106. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44107. export * from "babylonjs/Gamepads/xboxGamepad";
  44108. }
  44109. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44110. import { Observable } from "babylonjs/Misc/observable";
  44111. import { Nullable } from "babylonjs/types";
  44112. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44114. import { Mesh } from "babylonjs/Meshes/mesh";
  44115. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44116. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44117. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44118. /**
  44119. * Single axis scale gizmo
  44120. */
  44121. export class AxisScaleGizmo extends Gizmo {
  44122. private _coloredMaterial;
  44123. /**
  44124. * Drag behavior responsible for the gizmos dragging interactions
  44125. */
  44126. dragBehavior: PointerDragBehavior;
  44127. private _pointerObserver;
  44128. /**
  44129. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44130. */
  44131. snapDistance: number;
  44132. /**
  44133. * Event that fires each time the gizmo snaps to a new location.
  44134. * * snapDistance is the the change in distance
  44135. */
  44136. onSnapObservable: Observable<{
  44137. snapDistance: number;
  44138. }>;
  44139. /**
  44140. * If the scaling operation should be done on all axis (default: false)
  44141. */
  44142. uniformScaling: boolean;
  44143. /**
  44144. * Creates an AxisScaleGizmo
  44145. * @param gizmoLayer The utility layer the gizmo will be added to
  44146. * @param dragAxis The axis which the gizmo will be able to scale on
  44147. * @param color The color of the gizmo
  44148. */
  44149. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44150. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44151. /**
  44152. * Disposes of the gizmo
  44153. */
  44154. dispose(): void;
  44155. /**
  44156. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44157. * @param mesh The mesh to replace the default mesh of the gizmo
  44158. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44159. */
  44160. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44161. }
  44162. }
  44163. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44164. import { Observable } from "babylonjs/Misc/observable";
  44165. import { Nullable } from "babylonjs/types";
  44166. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44168. import { Mesh } from "babylonjs/Meshes/mesh";
  44169. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44170. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44171. import "babylonjs/Meshes/Builders/boxBuilder";
  44172. /**
  44173. * Bounding box gizmo
  44174. */
  44175. export class BoundingBoxGizmo extends Gizmo {
  44176. private _lineBoundingBox;
  44177. private _rotateSpheresParent;
  44178. private _scaleBoxesParent;
  44179. private _boundingDimensions;
  44180. private _renderObserver;
  44181. private _pointerObserver;
  44182. private _scaleDragSpeed;
  44183. private _tmpQuaternion;
  44184. private _tmpVector;
  44185. private _tmpRotationMatrix;
  44186. /**
  44187. * 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)
  44188. */
  44189. ignoreChildren: boolean;
  44190. /**
  44191. * 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)
  44192. */
  44193. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44194. /**
  44195. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44196. */
  44197. rotationSphereSize: number;
  44198. /**
  44199. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44200. */
  44201. scaleBoxSize: number;
  44202. /**
  44203. * 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)
  44204. */
  44205. fixedDragMeshScreenSize: boolean;
  44206. /**
  44207. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44208. */
  44209. fixedDragMeshScreenSizeDistanceFactor: number;
  44210. /**
  44211. * Fired when a rotation sphere or scale box is dragged
  44212. */
  44213. onDragStartObservable: Observable<{}>;
  44214. /**
  44215. * Fired when a scale box is dragged
  44216. */
  44217. onScaleBoxDragObservable: Observable<{}>;
  44218. /**
  44219. * Fired when a scale box drag is ended
  44220. */
  44221. onScaleBoxDragEndObservable: Observable<{}>;
  44222. /**
  44223. * Fired when a rotation sphere is dragged
  44224. */
  44225. onRotationSphereDragObservable: Observable<{}>;
  44226. /**
  44227. * Fired when a rotation sphere drag is ended
  44228. */
  44229. onRotationSphereDragEndObservable: Observable<{}>;
  44230. /**
  44231. * 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)
  44232. */
  44233. scalePivot: Nullable<Vector3>;
  44234. /**
  44235. * Mesh used as a pivot to rotate the attached mesh
  44236. */
  44237. private _anchorMesh;
  44238. private _existingMeshScale;
  44239. private _dragMesh;
  44240. private pointerDragBehavior;
  44241. private coloredMaterial;
  44242. private hoverColoredMaterial;
  44243. /**
  44244. * Sets the color of the bounding box gizmo
  44245. * @param color the color to set
  44246. */
  44247. setColor(color: Color3): void;
  44248. /**
  44249. * Creates an BoundingBoxGizmo
  44250. * @param gizmoLayer The utility layer the gizmo will be added to
  44251. * @param color The color of the gizmo
  44252. */
  44253. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44254. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44255. private _selectNode;
  44256. /**
  44257. * Updates the bounding box information for the Gizmo
  44258. */
  44259. updateBoundingBox(): void;
  44260. private _updateRotationSpheres;
  44261. private _updateScaleBoxes;
  44262. /**
  44263. * Enables rotation on the specified axis and disables rotation on the others
  44264. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44265. */
  44266. setEnabledRotationAxis(axis: string): void;
  44267. /**
  44268. * Enables/disables scaling
  44269. * @param enable if scaling should be enabled
  44270. */
  44271. setEnabledScaling(enable: boolean): void;
  44272. private _updateDummy;
  44273. /**
  44274. * Enables a pointer drag behavior on the bounding box of the gizmo
  44275. */
  44276. enableDragBehavior(): void;
  44277. /**
  44278. * Disposes of the gizmo
  44279. */
  44280. dispose(): void;
  44281. /**
  44282. * 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)
  44283. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44284. * @returns the bounding box mesh with the passed in mesh as a child
  44285. */
  44286. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44287. /**
  44288. * CustomMeshes are not supported by this gizmo
  44289. * @param mesh The mesh to replace the default mesh of the gizmo
  44290. */
  44291. setCustomMesh(mesh: Mesh): void;
  44292. }
  44293. }
  44294. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44295. import { Observable } from "babylonjs/Misc/observable";
  44296. import { Nullable } from "babylonjs/types";
  44297. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44299. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44300. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44301. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44302. import "babylonjs/Meshes/Builders/linesBuilder";
  44303. /**
  44304. * Single plane rotation gizmo
  44305. */
  44306. export class PlaneRotationGizmo extends Gizmo {
  44307. /**
  44308. * Drag behavior responsible for the gizmos dragging interactions
  44309. */
  44310. dragBehavior: PointerDragBehavior;
  44311. private _pointerObserver;
  44312. /**
  44313. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44314. */
  44315. snapDistance: number;
  44316. /**
  44317. * Event that fires each time the gizmo snaps to a new location.
  44318. * * snapDistance is the the change in distance
  44319. */
  44320. onSnapObservable: Observable<{
  44321. snapDistance: number;
  44322. }>;
  44323. /**
  44324. * Creates a PlaneRotationGizmo
  44325. * @param gizmoLayer The utility layer the gizmo will be added to
  44326. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44327. * @param color The color of the gizmo
  44328. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44329. */
  44330. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44331. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44332. /**
  44333. * Disposes of the gizmo
  44334. */
  44335. dispose(): void;
  44336. }
  44337. }
  44338. declare module "babylonjs/Gizmos/rotationGizmo" {
  44339. import { Observable } from "babylonjs/Misc/observable";
  44340. import { Nullable } from "babylonjs/types";
  44341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44342. import { Mesh } from "babylonjs/Meshes/mesh";
  44343. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44344. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44345. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44346. /**
  44347. * Gizmo that enables rotating a mesh along 3 axis
  44348. */
  44349. export class RotationGizmo extends Gizmo {
  44350. /**
  44351. * Internal gizmo used for interactions on the x axis
  44352. */
  44353. xGizmo: PlaneRotationGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the y axis
  44356. */
  44357. yGizmo: PlaneRotationGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the z axis
  44360. */
  44361. zGizmo: PlaneRotationGizmo;
  44362. /** Fires an event when any of it's sub gizmos are dragged */
  44363. onDragStartObservable: Observable<{}>;
  44364. /** Fires an event when any of it's sub gizmos are released from dragging */
  44365. onDragEndObservable: Observable<{}>;
  44366. attachedMesh: Nullable<AbstractMesh>;
  44367. /**
  44368. * Creates a RotationGizmo
  44369. * @param gizmoLayer The utility layer the gizmo will be added to
  44370. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44371. */
  44372. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44373. updateGizmoRotationToMatchAttachedMesh: boolean;
  44374. /**
  44375. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44376. */
  44377. snapDistance: number;
  44378. /**
  44379. * Ratio for the scale of the gizmo (Default: 1)
  44380. */
  44381. scaleRatio: number;
  44382. /**
  44383. * Disposes of the gizmo
  44384. */
  44385. dispose(): void;
  44386. /**
  44387. * CustomMeshes are not supported by this gizmo
  44388. * @param mesh The mesh to replace the default mesh of the gizmo
  44389. */
  44390. setCustomMesh(mesh: Mesh): void;
  44391. }
  44392. }
  44393. declare module "babylonjs/Gizmos/positionGizmo" {
  44394. import { Observable } from "babylonjs/Misc/observable";
  44395. import { Nullable } from "babylonjs/types";
  44396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44397. import { Mesh } from "babylonjs/Meshes/mesh";
  44398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44399. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44400. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44401. /**
  44402. * Gizmo that enables dragging a mesh along 3 axis
  44403. */
  44404. export class PositionGizmo extends Gizmo {
  44405. /**
  44406. * Internal gizmo used for interactions on the x axis
  44407. */
  44408. xGizmo: AxisDragGizmo;
  44409. /**
  44410. * Internal gizmo used for interactions on the y axis
  44411. */
  44412. yGizmo: AxisDragGizmo;
  44413. /**
  44414. * Internal gizmo used for interactions on the z axis
  44415. */
  44416. zGizmo: AxisDragGizmo;
  44417. /** Fires an event when any of it's sub gizmos are dragged */
  44418. onDragStartObservable: Observable<{}>;
  44419. /** Fires an event when any of it's sub gizmos are released from dragging */
  44420. onDragEndObservable: Observable<{}>;
  44421. attachedMesh: Nullable<AbstractMesh>;
  44422. /**
  44423. * Creates a PositionGizmo
  44424. * @param gizmoLayer The utility layer the gizmo will be added to
  44425. */
  44426. constructor(gizmoLayer?: UtilityLayerRenderer);
  44427. updateGizmoRotationToMatchAttachedMesh: boolean;
  44428. /**
  44429. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44430. */
  44431. snapDistance: number;
  44432. /**
  44433. * Ratio for the scale of the gizmo (Default: 1)
  44434. */
  44435. scaleRatio: number;
  44436. /**
  44437. * Disposes of the gizmo
  44438. */
  44439. dispose(): void;
  44440. /**
  44441. * CustomMeshes are not supported by this gizmo
  44442. * @param mesh The mesh to replace the default mesh of the gizmo
  44443. */
  44444. setCustomMesh(mesh: Mesh): void;
  44445. }
  44446. }
  44447. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44448. import { Scene } from "babylonjs/scene";
  44449. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44450. import { Mesh } from "babylonjs/Meshes/mesh";
  44451. import { Nullable } from "babylonjs/types";
  44452. /**
  44453. * Class containing static functions to help procedurally build meshes
  44454. */
  44455. export class PolyhedronBuilder {
  44456. /**
  44457. * Creates a polyhedron mesh
  44458. * * 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
  44459. * * The parameter `size` (positive float, default 1) sets the polygon size
  44460. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44461. * * 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`
  44462. * * 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
  44463. * * 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)`)
  44464. * * 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
  44465. * * 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
  44466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44469. * @param name defines the name of the mesh
  44470. * @param options defines the options used to create the mesh
  44471. * @param scene defines the hosting scene
  44472. * @returns the polyhedron mesh
  44473. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44474. */
  44475. static CreatePolyhedron(name: string, options: {
  44476. type?: number;
  44477. size?: number;
  44478. sizeX?: number;
  44479. sizeY?: number;
  44480. sizeZ?: number;
  44481. custom?: any;
  44482. faceUV?: Vector4[];
  44483. faceColors?: Color4[];
  44484. flat?: boolean;
  44485. updatable?: boolean;
  44486. sideOrientation?: number;
  44487. frontUVs?: Vector4;
  44488. backUVs?: Vector4;
  44489. }, scene?: Nullable<Scene>): Mesh;
  44490. }
  44491. }
  44492. declare module "babylonjs/Gizmos/scaleGizmo" {
  44493. import { Observable } from "babylonjs/Misc/observable";
  44494. import { Nullable } from "babylonjs/types";
  44495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44496. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44497. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44498. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44499. /**
  44500. * Gizmo that enables scaling a mesh along 3 axis
  44501. */
  44502. export class ScaleGizmo extends Gizmo {
  44503. /**
  44504. * Internal gizmo used for interactions on the x axis
  44505. */
  44506. xGizmo: AxisScaleGizmo;
  44507. /**
  44508. * Internal gizmo used for interactions on the y axis
  44509. */
  44510. yGizmo: AxisScaleGizmo;
  44511. /**
  44512. * Internal gizmo used for interactions on the z axis
  44513. */
  44514. zGizmo: AxisScaleGizmo;
  44515. /**
  44516. * Internal gizmo used to scale all axis equally
  44517. */
  44518. uniformScaleGizmo: AxisScaleGizmo;
  44519. /** Fires an event when any of it's sub gizmos are dragged */
  44520. onDragStartObservable: Observable<{}>;
  44521. /** Fires an event when any of it's sub gizmos are released from dragging */
  44522. onDragEndObservable: Observable<{}>;
  44523. attachedMesh: Nullable<AbstractMesh>;
  44524. /**
  44525. * Creates a ScaleGizmo
  44526. * @param gizmoLayer The utility layer the gizmo will be added to
  44527. */
  44528. constructor(gizmoLayer?: UtilityLayerRenderer);
  44529. updateGizmoRotationToMatchAttachedMesh: boolean;
  44530. /**
  44531. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44532. */
  44533. snapDistance: number;
  44534. /**
  44535. * Ratio for the scale of the gizmo (Default: 1)
  44536. */
  44537. scaleRatio: number;
  44538. /**
  44539. * Disposes of the gizmo
  44540. */
  44541. dispose(): void;
  44542. }
  44543. }
  44544. declare module "babylonjs/Gizmos/gizmoManager" {
  44545. import { Observable } from "babylonjs/Misc/observable";
  44546. import { Nullable } from "babylonjs/types";
  44547. import { Scene, IDisposable } from "babylonjs/scene";
  44548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44549. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44550. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44551. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44552. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44553. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44554. /**
  44555. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44556. */
  44557. export class GizmoManager implements IDisposable {
  44558. private scene;
  44559. /**
  44560. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44561. */
  44562. gizmos: {
  44563. positionGizmo: Nullable<PositionGizmo>;
  44564. rotationGizmo: Nullable<RotationGizmo>;
  44565. scaleGizmo: Nullable<ScaleGizmo>;
  44566. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44567. };
  44568. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44569. clearGizmoOnEmptyPointerEvent: boolean;
  44570. /** Fires an event when the manager is attached to a mesh */
  44571. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44572. private _gizmosEnabled;
  44573. private _pointerObserver;
  44574. private _attachedMesh;
  44575. private _boundingBoxColor;
  44576. private _defaultUtilityLayer;
  44577. private _defaultKeepDepthUtilityLayer;
  44578. /**
  44579. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44580. */
  44581. boundingBoxDragBehavior: SixDofDragBehavior;
  44582. /**
  44583. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44584. */
  44585. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44586. /**
  44587. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44588. */
  44589. usePointerToAttachGizmos: boolean;
  44590. /**
  44591. * Instatiates a gizmo manager
  44592. * @param scene the scene to overlay the gizmos on top of
  44593. */
  44594. constructor(scene: Scene);
  44595. /**
  44596. * Attaches a set of gizmos to the specified mesh
  44597. * @param mesh The mesh the gizmo's should be attached to
  44598. */
  44599. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44600. /**
  44601. * If the position gizmo is enabled
  44602. */
  44603. positionGizmoEnabled: boolean;
  44604. /**
  44605. * If the rotation gizmo is enabled
  44606. */
  44607. rotationGizmoEnabled: boolean;
  44608. /**
  44609. * If the scale gizmo is enabled
  44610. */
  44611. scaleGizmoEnabled: boolean;
  44612. /**
  44613. * If the boundingBox gizmo is enabled
  44614. */
  44615. boundingBoxGizmoEnabled: boolean;
  44616. /**
  44617. * Disposes of the gizmo manager
  44618. */
  44619. dispose(): void;
  44620. }
  44621. }
  44622. declare module "babylonjs/Lights/directionalLight" {
  44623. import { Camera } from "babylonjs/Cameras/camera";
  44624. import { Scene } from "babylonjs/scene";
  44625. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44627. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44628. import { Effect } from "babylonjs/Materials/effect";
  44629. /**
  44630. * A directional light is defined by a direction (what a surprise!).
  44631. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44632. * 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.
  44633. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44634. */
  44635. export class DirectionalLight extends ShadowLight {
  44636. private _shadowFrustumSize;
  44637. /**
  44638. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44639. */
  44640. /**
  44641. * Specifies a fix frustum size for the shadow generation.
  44642. */
  44643. shadowFrustumSize: number;
  44644. private _shadowOrthoScale;
  44645. /**
  44646. * Gets the shadow projection scale against the optimal computed one.
  44647. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44648. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44649. */
  44650. /**
  44651. * Sets the shadow projection scale against the optimal computed one.
  44652. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44653. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44654. */
  44655. shadowOrthoScale: number;
  44656. /**
  44657. * Automatically compute the projection matrix to best fit (including all the casters)
  44658. * on each frame.
  44659. */
  44660. autoUpdateExtends: boolean;
  44661. private _orthoLeft;
  44662. private _orthoRight;
  44663. private _orthoTop;
  44664. private _orthoBottom;
  44665. /**
  44666. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44667. * The directional light is emitted from everywhere in the given direction.
  44668. * It can cast shadows.
  44669. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44670. * @param name The friendly name of the light
  44671. * @param direction The direction of the light
  44672. * @param scene The scene the light belongs to
  44673. */
  44674. constructor(name: string, direction: Vector3, scene: Scene);
  44675. /**
  44676. * Returns the string "DirectionalLight".
  44677. * @return The class name
  44678. */
  44679. getClassName(): string;
  44680. /**
  44681. * Returns the integer 1.
  44682. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44683. */
  44684. getTypeID(): number;
  44685. /**
  44686. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44687. * Returns the DirectionalLight Shadow projection matrix.
  44688. */
  44689. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44690. /**
  44691. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44692. * Returns the DirectionalLight Shadow projection matrix.
  44693. */
  44694. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44695. /**
  44696. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44697. * Returns the DirectionalLight Shadow projection matrix.
  44698. */
  44699. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44700. protected _buildUniformLayout(): void;
  44701. /**
  44702. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44703. * @param effect The effect to update
  44704. * @param lightIndex The index of the light in the effect to update
  44705. * @returns The directional light
  44706. */
  44707. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44708. /**
  44709. * Gets the minZ used for shadow according to both the scene and the light.
  44710. *
  44711. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44712. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44713. * @param activeCamera The camera we are returning the min for
  44714. * @returns the depth min z
  44715. */
  44716. getDepthMinZ(activeCamera: Camera): number;
  44717. /**
  44718. * Gets the maxZ used for shadow according to both the scene and the light.
  44719. *
  44720. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44721. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44722. * @param activeCamera The camera we are returning the max for
  44723. * @returns the depth max z
  44724. */
  44725. getDepthMaxZ(activeCamera: Camera): number;
  44726. /**
  44727. * Prepares the list of defines specific to the light type.
  44728. * @param defines the list of defines
  44729. * @param lightIndex defines the index of the light for the effect
  44730. */
  44731. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44732. }
  44733. }
  44734. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44735. import { Mesh } from "babylonjs/Meshes/mesh";
  44736. /**
  44737. * Class containing static functions to help procedurally build meshes
  44738. */
  44739. export class HemisphereBuilder {
  44740. /**
  44741. * Creates a hemisphere mesh
  44742. * @param name defines the name of the mesh
  44743. * @param options defines the options used to create the mesh
  44744. * @param scene defines the hosting scene
  44745. * @returns the hemisphere mesh
  44746. */
  44747. static CreateHemisphere(name: string, options: {
  44748. segments?: number;
  44749. diameter?: number;
  44750. sideOrientation?: number;
  44751. }, scene: any): Mesh;
  44752. }
  44753. }
  44754. declare module "babylonjs/Lights/spotLight" {
  44755. import { Nullable } from "babylonjs/types";
  44756. import { Scene } from "babylonjs/scene";
  44757. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44759. import { Effect } from "babylonjs/Materials/effect";
  44760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44761. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44762. /**
  44763. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44764. * These values define a cone of light starting from the position, emitting toward the direction.
  44765. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44766. * and the exponent defines the speed of the decay of the light with distance (reach).
  44767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44768. */
  44769. export class SpotLight extends ShadowLight {
  44770. private _angle;
  44771. private _innerAngle;
  44772. private _cosHalfAngle;
  44773. private _lightAngleScale;
  44774. private _lightAngleOffset;
  44775. /**
  44776. * Gets the cone angle of the spot light in Radians.
  44777. */
  44778. /**
  44779. * Sets the cone angle of the spot light in Radians.
  44780. */
  44781. angle: number;
  44782. /**
  44783. * Only used in gltf falloff mode, this defines the angle where
  44784. * the directional falloff will start before cutting at angle which could be seen
  44785. * as outer angle.
  44786. */
  44787. /**
  44788. * Only used in gltf falloff mode, this defines the angle where
  44789. * the directional falloff will start before cutting at angle which could be seen
  44790. * as outer angle.
  44791. */
  44792. innerAngle: number;
  44793. private _shadowAngleScale;
  44794. /**
  44795. * Allows scaling the angle of the light for shadow generation only.
  44796. */
  44797. /**
  44798. * Allows scaling the angle of the light for shadow generation only.
  44799. */
  44800. shadowAngleScale: number;
  44801. /**
  44802. * The light decay speed with the distance from the emission spot.
  44803. */
  44804. exponent: number;
  44805. private _projectionTextureMatrix;
  44806. /**
  44807. * Allows reading the projecton texture
  44808. */
  44809. readonly projectionTextureMatrix: Matrix;
  44810. protected _projectionTextureLightNear: number;
  44811. /**
  44812. * Gets the near clip of the Spotlight for texture projection.
  44813. */
  44814. /**
  44815. * Sets the near clip of the Spotlight for texture projection.
  44816. */
  44817. projectionTextureLightNear: number;
  44818. protected _projectionTextureLightFar: number;
  44819. /**
  44820. * Gets the far clip of the Spotlight for texture projection.
  44821. */
  44822. /**
  44823. * Sets the far clip of the Spotlight for texture projection.
  44824. */
  44825. projectionTextureLightFar: number;
  44826. protected _projectionTextureUpDirection: Vector3;
  44827. /**
  44828. * Gets the Up vector of the Spotlight for texture projection.
  44829. */
  44830. /**
  44831. * Sets the Up vector of the Spotlight for texture projection.
  44832. */
  44833. projectionTextureUpDirection: Vector3;
  44834. private _projectionTexture;
  44835. /**
  44836. * Gets the projection texture of the light.
  44837. */
  44838. /**
  44839. * Sets the projection texture of the light.
  44840. */
  44841. projectionTexture: Nullable<BaseTexture>;
  44842. private _projectionTextureViewLightDirty;
  44843. private _projectionTextureProjectionLightDirty;
  44844. private _projectionTextureDirty;
  44845. private _projectionTextureViewTargetVector;
  44846. private _projectionTextureViewLightMatrix;
  44847. private _projectionTextureProjectionLightMatrix;
  44848. private _projectionTextureScalingMatrix;
  44849. /**
  44850. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44851. * It can cast shadows.
  44852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44853. * @param name The light friendly name
  44854. * @param position The position of the spot light in the scene
  44855. * @param direction The direction of the light in the scene
  44856. * @param angle The cone angle of the light in Radians
  44857. * @param exponent The light decay speed with the distance from the emission spot
  44858. * @param scene The scene the lights belongs to
  44859. */
  44860. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44861. /**
  44862. * Returns the string "SpotLight".
  44863. * @returns the class name
  44864. */
  44865. getClassName(): string;
  44866. /**
  44867. * Returns the integer 2.
  44868. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44869. */
  44870. getTypeID(): number;
  44871. /**
  44872. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44873. */
  44874. protected _setDirection(value: Vector3): void;
  44875. /**
  44876. * Overrides the position setter to recompute the projection texture view light Matrix.
  44877. */
  44878. protected _setPosition(value: Vector3): void;
  44879. /**
  44880. * 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.
  44881. * Returns the SpotLight.
  44882. */
  44883. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44884. protected _computeProjectionTextureViewLightMatrix(): void;
  44885. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44886. /**
  44887. * Main function for light texture projection matrix computing.
  44888. */
  44889. protected _computeProjectionTextureMatrix(): void;
  44890. protected _buildUniformLayout(): void;
  44891. private _computeAngleValues;
  44892. /**
  44893. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44894. * @param effect The effect to update
  44895. * @param lightIndex The index of the light in the effect to update
  44896. * @returns The spot light
  44897. */
  44898. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44899. /**
  44900. * Disposes the light and the associated resources.
  44901. */
  44902. dispose(): void;
  44903. /**
  44904. * Prepares the list of defines specific to the light type.
  44905. * @param defines the list of defines
  44906. * @param lightIndex defines the index of the light for the effect
  44907. */
  44908. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44909. }
  44910. }
  44911. declare module "babylonjs/Gizmos/lightGizmo" {
  44912. import { Nullable } from "babylonjs/types";
  44913. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44914. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44915. import { Light } from "babylonjs/Lights/light";
  44916. /**
  44917. * Gizmo that enables viewing a light
  44918. */
  44919. export class LightGizmo extends Gizmo {
  44920. private _lightMesh;
  44921. private _material;
  44922. /**
  44923. * Creates a LightGizmo
  44924. * @param gizmoLayer The utility layer the gizmo will be added to
  44925. */
  44926. constructor(gizmoLayer?: UtilityLayerRenderer);
  44927. private _light;
  44928. /**
  44929. * The light that the gizmo is attached to
  44930. */
  44931. light: Nullable<Light>;
  44932. /**
  44933. * @hidden
  44934. * Updates the gizmo to match the attached mesh's position/rotation
  44935. */
  44936. protected _update(): void;
  44937. private static _Scale;
  44938. /**
  44939. * Creates the lines for a light mesh
  44940. */
  44941. private static _createLightLines;
  44942. private static _CreateHemisphericLightMesh;
  44943. private static _CreatePointLightMesh;
  44944. private static _CreateSpotLightMesh;
  44945. private static _CreateDirectionalLightMesh;
  44946. }
  44947. }
  44948. declare module "babylonjs/Gizmos/index" {
  44949. export * from "babylonjs/Gizmos/axisDragGizmo";
  44950. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44951. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44952. export * from "babylonjs/Gizmos/gizmo";
  44953. export * from "babylonjs/Gizmos/gizmoManager";
  44954. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44955. export * from "babylonjs/Gizmos/positionGizmo";
  44956. export * from "babylonjs/Gizmos/rotationGizmo";
  44957. export * from "babylonjs/Gizmos/scaleGizmo";
  44958. export * from "babylonjs/Gizmos/lightGizmo";
  44959. }
  44960. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44961. /** @hidden */
  44962. export var backgroundFragmentDeclaration: {
  44963. name: string;
  44964. shader: string;
  44965. };
  44966. }
  44967. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44968. /** @hidden */
  44969. export var backgroundUboDeclaration: {
  44970. name: string;
  44971. shader: string;
  44972. };
  44973. }
  44974. declare module "babylonjs/Shaders/background.fragment" {
  44975. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44976. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44977. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44978. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44979. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44980. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44982. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44983. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44984. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44985. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44986. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44987. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44988. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44989. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44990. /** @hidden */
  44991. export var backgroundPixelShader: {
  44992. name: string;
  44993. shader: string;
  44994. };
  44995. }
  44996. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44997. /** @hidden */
  44998. export var backgroundVertexDeclaration: {
  44999. name: string;
  45000. shader: string;
  45001. };
  45002. }
  45003. declare module "babylonjs/Shaders/background.vertex" {
  45004. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45005. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45006. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45007. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45008. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45010. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45011. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45012. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45013. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45014. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45015. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45016. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45017. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45018. /** @hidden */
  45019. export var backgroundVertexShader: {
  45020. name: string;
  45021. shader: string;
  45022. };
  45023. }
  45024. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45025. import { Nullable, int, float } from "babylonjs/types";
  45026. import { Scene } from "babylonjs/scene";
  45027. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45030. import { Mesh } from "babylonjs/Meshes/mesh";
  45031. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45032. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45033. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45035. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45036. import "babylonjs/Shaders/background.fragment";
  45037. import "babylonjs/Shaders/background.vertex";
  45038. /**
  45039. * Background material used to create an efficient environement around your scene.
  45040. */
  45041. export class BackgroundMaterial extends PushMaterial {
  45042. /**
  45043. * Standard reflectance value at parallel view angle.
  45044. */
  45045. static StandardReflectance0: number;
  45046. /**
  45047. * Standard reflectance value at grazing angle.
  45048. */
  45049. static StandardReflectance90: number;
  45050. protected _primaryColor: Color3;
  45051. /**
  45052. * Key light Color (multiply against the environement texture)
  45053. */
  45054. primaryColor: Color3;
  45055. protected __perceptualColor: Nullable<Color3>;
  45056. /**
  45057. * Experimental Internal Use Only.
  45058. *
  45059. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45060. * This acts as a helper to set the primary color to a more "human friendly" value.
  45061. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45062. * output color as close as possible from the chosen value.
  45063. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45064. * part of lighting setup.)
  45065. */
  45066. _perceptualColor: Nullable<Color3>;
  45067. protected _primaryColorShadowLevel: float;
  45068. /**
  45069. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45070. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45071. */
  45072. primaryColorShadowLevel: float;
  45073. protected _primaryColorHighlightLevel: float;
  45074. /**
  45075. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45076. * The primary color is used at the level chosen to define what the white area would look.
  45077. */
  45078. primaryColorHighlightLevel: float;
  45079. protected _reflectionTexture: Nullable<BaseTexture>;
  45080. /**
  45081. * Reflection Texture used in the material.
  45082. * Should be author in a specific way for the best result (refer to the documentation).
  45083. */
  45084. reflectionTexture: Nullable<BaseTexture>;
  45085. protected _reflectionBlur: float;
  45086. /**
  45087. * Reflection Texture level of blur.
  45088. *
  45089. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45090. * texture twice.
  45091. */
  45092. reflectionBlur: float;
  45093. protected _diffuseTexture: Nullable<BaseTexture>;
  45094. /**
  45095. * Diffuse Texture used in the material.
  45096. * Should be author in a specific way for the best result (refer to the documentation).
  45097. */
  45098. diffuseTexture: Nullable<BaseTexture>;
  45099. protected _shadowLights: Nullable<IShadowLight[]>;
  45100. /**
  45101. * Specify the list of lights casting shadow on the material.
  45102. * All scene shadow lights will be included if null.
  45103. */
  45104. shadowLights: Nullable<IShadowLight[]>;
  45105. protected _shadowLevel: float;
  45106. /**
  45107. * Helps adjusting the shadow to a softer level if required.
  45108. * 0 means black shadows and 1 means no shadows.
  45109. */
  45110. shadowLevel: float;
  45111. protected _sceneCenter: Vector3;
  45112. /**
  45113. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45114. * It is usually zero but might be interesting to modify according to your setup.
  45115. */
  45116. sceneCenter: Vector3;
  45117. protected _opacityFresnel: boolean;
  45118. /**
  45119. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45120. * This helps ensuring a nice transition when the camera goes under the ground.
  45121. */
  45122. opacityFresnel: boolean;
  45123. protected _reflectionFresnel: boolean;
  45124. /**
  45125. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45126. * This helps adding a mirror texture on the ground.
  45127. */
  45128. reflectionFresnel: boolean;
  45129. protected _reflectionFalloffDistance: number;
  45130. /**
  45131. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45132. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45133. */
  45134. reflectionFalloffDistance: number;
  45135. protected _reflectionAmount: number;
  45136. /**
  45137. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45138. */
  45139. reflectionAmount: number;
  45140. protected _reflectionReflectance0: number;
  45141. /**
  45142. * This specifies the weight of the reflection at grazing angle.
  45143. */
  45144. reflectionReflectance0: number;
  45145. protected _reflectionReflectance90: number;
  45146. /**
  45147. * This specifies the weight of the reflection at a perpendicular point of view.
  45148. */
  45149. reflectionReflectance90: number;
  45150. /**
  45151. * Sets the reflection reflectance fresnel values according to the default standard
  45152. * empirically know to work well :-)
  45153. */
  45154. reflectionStandardFresnelWeight: number;
  45155. protected _useRGBColor: boolean;
  45156. /**
  45157. * Helps to directly use the maps channels instead of their level.
  45158. */
  45159. useRGBColor: boolean;
  45160. protected _enableNoise: boolean;
  45161. /**
  45162. * This helps reducing the banding effect that could occur on the background.
  45163. */
  45164. enableNoise: boolean;
  45165. /**
  45166. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45167. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45168. * Recommended to be keep at 1.0 except for special cases.
  45169. */
  45170. fovMultiplier: number;
  45171. private _fovMultiplier;
  45172. /**
  45173. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45174. */
  45175. useEquirectangularFOV: boolean;
  45176. private _maxSimultaneousLights;
  45177. /**
  45178. * Number of Simultaneous lights allowed on the material.
  45179. */
  45180. maxSimultaneousLights: int;
  45181. /**
  45182. * Default configuration related to image processing available in the Background Material.
  45183. */
  45184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45185. /**
  45186. * Keep track of the image processing observer to allow dispose and replace.
  45187. */
  45188. private _imageProcessingObserver;
  45189. /**
  45190. * Attaches a new image processing configuration to the PBR Material.
  45191. * @param configuration (if null the scene configuration will be use)
  45192. */
  45193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45194. /**
  45195. * Gets the image processing configuration used either in this material.
  45196. */
  45197. /**
  45198. * Sets the Default image processing configuration used either in the this material.
  45199. *
  45200. * If sets to null, the scene one is in use.
  45201. */
  45202. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45203. /**
  45204. * Gets wether the color curves effect is enabled.
  45205. */
  45206. /**
  45207. * Sets wether the color curves effect is enabled.
  45208. */
  45209. cameraColorCurvesEnabled: boolean;
  45210. /**
  45211. * Gets wether the color grading effect is enabled.
  45212. */
  45213. /**
  45214. * Gets wether the color grading effect is enabled.
  45215. */
  45216. cameraColorGradingEnabled: boolean;
  45217. /**
  45218. * Gets wether tonemapping is enabled or not.
  45219. */
  45220. /**
  45221. * Sets wether tonemapping is enabled or not
  45222. */
  45223. cameraToneMappingEnabled: boolean;
  45224. /**
  45225. * The camera exposure used on this material.
  45226. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45227. * This corresponds to a photographic exposure.
  45228. */
  45229. /**
  45230. * The camera exposure used on this material.
  45231. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45232. * This corresponds to a photographic exposure.
  45233. */
  45234. cameraExposure: float;
  45235. /**
  45236. * Gets The camera contrast used on this material.
  45237. */
  45238. /**
  45239. * Sets The camera contrast used on this material.
  45240. */
  45241. cameraContrast: float;
  45242. /**
  45243. * Gets the Color Grading 2D Lookup Texture.
  45244. */
  45245. /**
  45246. * Sets the Color Grading 2D Lookup Texture.
  45247. */
  45248. cameraColorGradingTexture: Nullable<BaseTexture>;
  45249. /**
  45250. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45251. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45252. * 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;
  45253. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45254. */
  45255. /**
  45256. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45257. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45258. * 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;
  45259. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45260. */
  45261. cameraColorCurves: Nullable<ColorCurves>;
  45262. /**
  45263. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45264. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45265. */
  45266. switchToBGR: boolean;
  45267. private _renderTargets;
  45268. private _reflectionControls;
  45269. private _white;
  45270. private _primaryShadowColor;
  45271. private _primaryHighlightColor;
  45272. /**
  45273. * Instantiates a Background Material in the given scene
  45274. * @param name The friendly name of the material
  45275. * @param scene The scene to add the material to
  45276. */
  45277. constructor(name: string, scene: Scene);
  45278. /**
  45279. * Gets a boolean indicating that current material needs to register RTT
  45280. */
  45281. readonly hasRenderTargetTextures: boolean;
  45282. /**
  45283. * The entire material has been created in order to prevent overdraw.
  45284. * @returns false
  45285. */
  45286. needAlphaTesting(): boolean;
  45287. /**
  45288. * The entire material has been created in order to prevent overdraw.
  45289. * @returns true if blending is enable
  45290. */
  45291. needAlphaBlending(): boolean;
  45292. /**
  45293. * Checks wether the material is ready to be rendered for a given mesh.
  45294. * @param mesh The mesh to render
  45295. * @param subMesh The submesh to check against
  45296. * @param useInstances Specify wether or not the material is used with instances
  45297. * @returns true if all the dependencies are ready (Textures, Effects...)
  45298. */
  45299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45300. /**
  45301. * Compute the primary color according to the chosen perceptual color.
  45302. */
  45303. private _computePrimaryColorFromPerceptualColor;
  45304. /**
  45305. * Compute the highlights and shadow colors according to their chosen levels.
  45306. */
  45307. private _computePrimaryColors;
  45308. /**
  45309. * Build the uniform buffer used in the material.
  45310. */
  45311. buildUniformLayout(): void;
  45312. /**
  45313. * Unbind the material.
  45314. */
  45315. unbind(): void;
  45316. /**
  45317. * Bind only the world matrix to the material.
  45318. * @param world The world matrix to bind.
  45319. */
  45320. bindOnlyWorldMatrix(world: Matrix): void;
  45321. /**
  45322. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45323. * @param world The world matrix to bind.
  45324. * @param subMesh The submesh to bind for.
  45325. */
  45326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45327. /**
  45328. * Dispose the material.
  45329. * @param forceDisposeEffect Force disposal of the associated effect.
  45330. * @param forceDisposeTextures Force disposal of the associated textures.
  45331. */
  45332. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45333. /**
  45334. * Clones the material.
  45335. * @param name The cloned name.
  45336. * @returns The cloned material.
  45337. */
  45338. clone(name: string): BackgroundMaterial;
  45339. /**
  45340. * Serializes the current material to its JSON representation.
  45341. * @returns The JSON representation.
  45342. */
  45343. serialize(): any;
  45344. /**
  45345. * Gets the class name of the material
  45346. * @returns "BackgroundMaterial"
  45347. */
  45348. getClassName(): string;
  45349. /**
  45350. * Parse a JSON input to create back a background material.
  45351. * @param source The JSON data to parse
  45352. * @param scene The scene to create the parsed material in
  45353. * @param rootUrl The root url of the assets the material depends upon
  45354. * @returns the instantiated BackgroundMaterial.
  45355. */
  45356. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45357. }
  45358. }
  45359. declare module "babylonjs/Helpers/environmentHelper" {
  45360. import { Observable } from "babylonjs/Misc/observable";
  45361. import { Nullable } from "babylonjs/types";
  45362. import { Scene } from "babylonjs/scene";
  45363. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45365. import { Mesh } from "babylonjs/Meshes/mesh";
  45366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45367. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45368. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45369. import "babylonjs/Meshes/Builders/planeBuilder";
  45370. import "babylonjs/Meshes/Builders/boxBuilder";
  45371. /**
  45372. * Represents the different options available during the creation of
  45373. * a Environment helper.
  45374. *
  45375. * This can control the default ground, skybox and image processing setup of your scene.
  45376. */
  45377. export interface IEnvironmentHelperOptions {
  45378. /**
  45379. * Specifies wether or not to create a ground.
  45380. * True by default.
  45381. */
  45382. createGround: boolean;
  45383. /**
  45384. * Specifies the ground size.
  45385. * 15 by default.
  45386. */
  45387. groundSize: number;
  45388. /**
  45389. * The texture used on the ground for the main color.
  45390. * Comes from the BabylonJS CDN by default.
  45391. *
  45392. * Remarks: Can be either a texture or a url.
  45393. */
  45394. groundTexture: string | BaseTexture;
  45395. /**
  45396. * The color mixed in the ground texture by default.
  45397. * BabylonJS clearColor by default.
  45398. */
  45399. groundColor: Color3;
  45400. /**
  45401. * Specifies the ground opacity.
  45402. * 1 by default.
  45403. */
  45404. groundOpacity: number;
  45405. /**
  45406. * Enables the ground to receive shadows.
  45407. * True by default.
  45408. */
  45409. enableGroundShadow: boolean;
  45410. /**
  45411. * Helps preventing the shadow to be fully black on the ground.
  45412. * 0.5 by default.
  45413. */
  45414. groundShadowLevel: number;
  45415. /**
  45416. * Creates a mirror texture attach to the ground.
  45417. * false by default.
  45418. */
  45419. enableGroundMirror: boolean;
  45420. /**
  45421. * Specifies the ground mirror size ratio.
  45422. * 0.3 by default as the default kernel is 64.
  45423. */
  45424. groundMirrorSizeRatio: number;
  45425. /**
  45426. * Specifies the ground mirror blur kernel size.
  45427. * 64 by default.
  45428. */
  45429. groundMirrorBlurKernel: number;
  45430. /**
  45431. * Specifies the ground mirror visibility amount.
  45432. * 1 by default
  45433. */
  45434. groundMirrorAmount: number;
  45435. /**
  45436. * Specifies the ground mirror reflectance weight.
  45437. * This uses the standard weight of the background material to setup the fresnel effect
  45438. * of the mirror.
  45439. * 1 by default.
  45440. */
  45441. groundMirrorFresnelWeight: number;
  45442. /**
  45443. * Specifies the ground mirror Falloff distance.
  45444. * This can helps reducing the size of the reflection.
  45445. * 0 by Default.
  45446. */
  45447. groundMirrorFallOffDistance: number;
  45448. /**
  45449. * Specifies the ground mirror texture type.
  45450. * Unsigned Int by Default.
  45451. */
  45452. groundMirrorTextureType: number;
  45453. /**
  45454. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45455. * the shown objects.
  45456. */
  45457. groundYBias: number;
  45458. /**
  45459. * Specifies wether or not to create a skybox.
  45460. * True by default.
  45461. */
  45462. createSkybox: boolean;
  45463. /**
  45464. * Specifies the skybox size.
  45465. * 20 by default.
  45466. */
  45467. skyboxSize: number;
  45468. /**
  45469. * The texture used on the skybox for the main color.
  45470. * Comes from the BabylonJS CDN by default.
  45471. *
  45472. * Remarks: Can be either a texture or a url.
  45473. */
  45474. skyboxTexture: string | BaseTexture;
  45475. /**
  45476. * The color mixed in the skybox texture by default.
  45477. * BabylonJS clearColor by default.
  45478. */
  45479. skyboxColor: Color3;
  45480. /**
  45481. * The background rotation around the Y axis of the scene.
  45482. * This helps aligning the key lights of your scene with the background.
  45483. * 0 by default.
  45484. */
  45485. backgroundYRotation: number;
  45486. /**
  45487. * Compute automatically the size of the elements to best fit with the scene.
  45488. */
  45489. sizeAuto: boolean;
  45490. /**
  45491. * Default position of the rootMesh if autoSize is not true.
  45492. */
  45493. rootPosition: Vector3;
  45494. /**
  45495. * Sets up the image processing in the scene.
  45496. * true by default.
  45497. */
  45498. setupImageProcessing: boolean;
  45499. /**
  45500. * The texture used as your environment texture in the scene.
  45501. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45502. *
  45503. * Remarks: Can be either a texture or a url.
  45504. */
  45505. environmentTexture: string | BaseTexture;
  45506. /**
  45507. * The value of the exposure to apply to the scene.
  45508. * 0.6 by default if setupImageProcessing is true.
  45509. */
  45510. cameraExposure: number;
  45511. /**
  45512. * The value of the contrast to apply to the scene.
  45513. * 1.6 by default if setupImageProcessing is true.
  45514. */
  45515. cameraContrast: number;
  45516. /**
  45517. * Specifies wether or not tonemapping should be enabled in the scene.
  45518. * true by default if setupImageProcessing is true.
  45519. */
  45520. toneMappingEnabled: boolean;
  45521. }
  45522. /**
  45523. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45524. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45525. * It also helps with the default setup of your imageProcessing configuration.
  45526. */
  45527. export class EnvironmentHelper {
  45528. /**
  45529. * Default ground texture URL.
  45530. */
  45531. private static _groundTextureCDNUrl;
  45532. /**
  45533. * Default skybox texture URL.
  45534. */
  45535. private static _skyboxTextureCDNUrl;
  45536. /**
  45537. * Default environment texture URL.
  45538. */
  45539. private static _environmentTextureCDNUrl;
  45540. /**
  45541. * Creates the default options for the helper.
  45542. */
  45543. private static _getDefaultOptions;
  45544. private _rootMesh;
  45545. /**
  45546. * Gets the root mesh created by the helper.
  45547. */
  45548. readonly rootMesh: Mesh;
  45549. private _skybox;
  45550. /**
  45551. * Gets the skybox created by the helper.
  45552. */
  45553. readonly skybox: Nullable<Mesh>;
  45554. private _skyboxTexture;
  45555. /**
  45556. * Gets the skybox texture created by the helper.
  45557. */
  45558. readonly skyboxTexture: Nullable<BaseTexture>;
  45559. private _skyboxMaterial;
  45560. /**
  45561. * Gets the skybox material created by the helper.
  45562. */
  45563. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45564. private _ground;
  45565. /**
  45566. * Gets the ground mesh created by the helper.
  45567. */
  45568. readonly ground: Nullable<Mesh>;
  45569. private _groundTexture;
  45570. /**
  45571. * Gets the ground texture created by the helper.
  45572. */
  45573. readonly groundTexture: Nullable<BaseTexture>;
  45574. private _groundMirror;
  45575. /**
  45576. * Gets the ground mirror created by the helper.
  45577. */
  45578. readonly groundMirror: Nullable<MirrorTexture>;
  45579. /**
  45580. * Gets the ground mirror render list to helps pushing the meshes
  45581. * you wish in the ground reflection.
  45582. */
  45583. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45584. private _groundMaterial;
  45585. /**
  45586. * Gets the ground material created by the helper.
  45587. */
  45588. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45589. /**
  45590. * Stores the creation options.
  45591. */
  45592. private readonly _scene;
  45593. private _options;
  45594. /**
  45595. * This observable will be notified with any error during the creation of the environment,
  45596. * mainly texture creation errors.
  45597. */
  45598. onErrorObservable: Observable<{
  45599. message?: string;
  45600. exception?: any;
  45601. }>;
  45602. /**
  45603. * constructor
  45604. * @param options Defines the options we want to customize the helper
  45605. * @param scene The scene to add the material to
  45606. */
  45607. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45608. /**
  45609. * Updates the background according to the new options
  45610. * @param options
  45611. */
  45612. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45613. /**
  45614. * Sets the primary color of all the available elements.
  45615. * @param color the main color to affect to the ground and the background
  45616. */
  45617. setMainColor(color: Color3): void;
  45618. /**
  45619. * Setup the image processing according to the specified options.
  45620. */
  45621. private _setupImageProcessing;
  45622. /**
  45623. * Setup the environment texture according to the specified options.
  45624. */
  45625. private _setupEnvironmentTexture;
  45626. /**
  45627. * Setup the background according to the specified options.
  45628. */
  45629. private _setupBackground;
  45630. /**
  45631. * Get the scene sizes according to the setup.
  45632. */
  45633. private _getSceneSize;
  45634. /**
  45635. * Setup the ground according to the specified options.
  45636. */
  45637. private _setupGround;
  45638. /**
  45639. * Setup the ground material according to the specified options.
  45640. */
  45641. private _setupGroundMaterial;
  45642. /**
  45643. * Setup the ground diffuse texture according to the specified options.
  45644. */
  45645. private _setupGroundDiffuseTexture;
  45646. /**
  45647. * Setup the ground mirror texture according to the specified options.
  45648. */
  45649. private _setupGroundMirrorTexture;
  45650. /**
  45651. * Setup the ground to receive the mirror texture.
  45652. */
  45653. private _setupMirrorInGroundMaterial;
  45654. /**
  45655. * Setup the skybox according to the specified options.
  45656. */
  45657. private _setupSkybox;
  45658. /**
  45659. * Setup the skybox material according to the specified options.
  45660. */
  45661. private _setupSkyboxMaterial;
  45662. /**
  45663. * Setup the skybox reflection texture according to the specified options.
  45664. */
  45665. private _setupSkyboxReflectionTexture;
  45666. private _errorHandler;
  45667. /**
  45668. * Dispose all the elements created by the Helper.
  45669. */
  45670. dispose(): void;
  45671. }
  45672. }
  45673. declare module "babylonjs/Helpers/photoDome" {
  45674. import { Observable } from "babylonjs/Misc/observable";
  45675. import { Nullable } from "babylonjs/types";
  45676. import { Scene } from "babylonjs/scene";
  45677. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45678. import { Mesh } from "babylonjs/Meshes/mesh";
  45679. import { Texture } from "babylonjs/Materials/Textures/texture";
  45680. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45681. import "babylonjs/Meshes/Builders/sphereBuilder";
  45682. /**
  45683. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45684. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45685. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45686. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45687. */
  45688. export class PhotoDome extends TransformNode {
  45689. private _useDirectMapping;
  45690. /**
  45691. * The texture being displayed on the sphere
  45692. */
  45693. protected _photoTexture: Texture;
  45694. /**
  45695. * Gets or sets the texture being displayed on the sphere
  45696. */
  45697. photoTexture: Texture;
  45698. /**
  45699. * Observable raised when an error occured while loading the 360 image
  45700. */
  45701. onLoadErrorObservable: Observable<string>;
  45702. /**
  45703. * The skybox material
  45704. */
  45705. protected _material: BackgroundMaterial;
  45706. /**
  45707. * The surface used for the skybox
  45708. */
  45709. protected _mesh: Mesh;
  45710. /**
  45711. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45712. * Also see the options.resolution property.
  45713. */
  45714. fovMultiplier: number;
  45715. /**
  45716. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45717. * @param name Element's name, child elements will append suffixes for their own names.
  45718. * @param urlsOfPhoto defines the url of the photo to display
  45719. * @param options defines an object containing optional or exposed sub element properties
  45720. * @param onError defines a callback called when an error occured while loading the texture
  45721. */
  45722. constructor(name: string, urlOfPhoto: string, options: {
  45723. resolution?: number;
  45724. size?: number;
  45725. useDirectMapping?: boolean;
  45726. faceForward?: boolean;
  45727. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45728. /**
  45729. * Releases resources associated with this node.
  45730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45732. */
  45733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45734. }
  45735. }
  45736. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45738. /** @hidden */
  45739. export var rgbdDecodePixelShader: {
  45740. name: string;
  45741. shader: string;
  45742. };
  45743. }
  45744. declare module "babylonjs/Misc/brdfTextureTools" {
  45745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45746. import { Scene } from "babylonjs/scene";
  45747. import "babylonjs/Shaders/rgbdDecode.fragment";
  45748. /**
  45749. * Class used to host texture specific utilities
  45750. */
  45751. export class BRDFTextureTools {
  45752. /**
  45753. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45754. * @param texture the texture to expand.
  45755. */
  45756. private static _ExpandDefaultBRDFTexture;
  45757. /**
  45758. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45759. * @param scene defines the hosting scene
  45760. * @returns the environment BRDF texture
  45761. */
  45762. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45763. private static _environmentBRDFBase64Texture;
  45764. }
  45765. }
  45766. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45767. import { Nullable } from "babylonjs/types";
  45768. import { IAnimatable } from "babylonjs/Misc/tools";
  45769. import { Color3 } from "babylonjs/Maths/math";
  45770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45771. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45772. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45773. import { Engine } from "babylonjs/Engines/engine";
  45774. import { Scene } from "babylonjs/scene";
  45775. /**
  45776. * @hidden
  45777. */
  45778. export interface IMaterialClearCoatDefines {
  45779. CLEARCOAT: boolean;
  45780. CLEARCOAT_DEFAULTIOR: boolean;
  45781. CLEARCOAT_TEXTURE: boolean;
  45782. CLEARCOAT_TEXTUREDIRECTUV: number;
  45783. CLEARCOAT_BUMP: boolean;
  45784. CLEARCOAT_BUMPDIRECTUV: number;
  45785. CLEARCOAT_TINT: boolean;
  45786. CLEARCOAT_TINT_TEXTURE: boolean;
  45787. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45788. /** @hidden */
  45789. _areTexturesDirty: boolean;
  45790. }
  45791. /**
  45792. * Define the code related to the clear coat parameters of the pbr material.
  45793. */
  45794. export class PBRClearCoatConfiguration {
  45795. /**
  45796. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45797. * The default fits with a polyurethane material.
  45798. */
  45799. private static readonly _DefaultIndiceOfRefraction;
  45800. private _isEnabled;
  45801. /**
  45802. * Defines if the clear coat is enabled in the material.
  45803. */
  45804. isEnabled: boolean;
  45805. /**
  45806. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45807. */
  45808. intensity: number;
  45809. /**
  45810. * Defines the clear coat layer roughness.
  45811. */
  45812. roughness: number;
  45813. private _indiceOfRefraction;
  45814. /**
  45815. * Defines the indice of refraction of the clear coat.
  45816. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45817. * The default fits with a polyurethane material.
  45818. * Changing the default value is more performance intensive.
  45819. */
  45820. indiceOfRefraction: number;
  45821. private _texture;
  45822. /**
  45823. * Stores the clear coat values in a texture.
  45824. */
  45825. texture: Nullable<BaseTexture>;
  45826. private _bumpTexture;
  45827. /**
  45828. * Define the clear coat specific bump texture.
  45829. */
  45830. bumpTexture: Nullable<BaseTexture>;
  45831. private _isTintEnabled;
  45832. /**
  45833. * Defines if the clear coat tint is enabled in the material.
  45834. */
  45835. isTintEnabled: boolean;
  45836. /**
  45837. * Defines the clear coat tint of the material.
  45838. * This is only use if tint is enabled
  45839. */
  45840. tintColor: Color3;
  45841. /**
  45842. * Defines the distance at which the tint color should be found in the
  45843. * clear coat media.
  45844. * This is only use if tint is enabled
  45845. */
  45846. tintColorAtDistance: number;
  45847. /**
  45848. * Defines the clear coat layer thickness.
  45849. * This is only use if tint is enabled
  45850. */
  45851. tintThickness: number;
  45852. private _tintTexture;
  45853. /**
  45854. * Stores the clear tint values in a texture.
  45855. * rgb is tint
  45856. * a is a thickness factor
  45857. */
  45858. tintTexture: Nullable<BaseTexture>;
  45859. /** @hidden */
  45860. private _internalMarkAllSubMeshesAsTexturesDirty;
  45861. /** @hidden */
  45862. _markAllSubMeshesAsTexturesDirty(): void;
  45863. /**
  45864. * Instantiate a new istance of clear coat configuration.
  45865. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45866. */
  45867. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45868. /**
  45869. * Gets wehter the submesh is ready to be used or not.
  45870. * @param defines the list of "defines" to update.
  45871. * @param scene defines the scene the material belongs to.
  45872. * @param engine defines the engine the material belongs to.
  45873. * @param disableBumpMap defines wether the material disables bump or not.
  45874. * @returns - boolean indicating that the submesh is ready or not.
  45875. */
  45876. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45877. /**
  45878. * Checks to see if a texture is used in the material.
  45879. * @param defines the list of "defines" to update.
  45880. * @param scene defines the scene to the material belongs to.
  45881. */
  45882. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45883. /**
  45884. * Binds the material data.
  45885. * @param uniformBuffer defines the Uniform buffer to fill in.
  45886. * @param scene defines the scene the material belongs to.
  45887. * @param engine defines the engine the material belongs to.
  45888. * @param disableBumpMap defines wether the material disables bump or not.
  45889. * @param isFrozen defines wether the material is frozen or not.
  45890. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45891. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45892. */
  45893. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45894. /**
  45895. * Checks to see if a texture is used in the material.
  45896. * @param texture - Base texture to use.
  45897. * @returns - Boolean specifying if a texture is used in the material.
  45898. */
  45899. hasTexture(texture: BaseTexture): boolean;
  45900. /**
  45901. * Returns an array of the actively used textures.
  45902. * @param activeTextures Array of BaseTextures
  45903. */
  45904. getActiveTextures(activeTextures: BaseTexture[]): void;
  45905. /**
  45906. * Returns the animatable textures.
  45907. * @param animatables Array of animatable textures.
  45908. */
  45909. getAnimatables(animatables: IAnimatable[]): void;
  45910. /**
  45911. * Disposes the resources of the material.
  45912. * @param forceDisposeTextures - Forces the disposal of all textures.
  45913. */
  45914. dispose(forceDisposeTextures?: boolean): void;
  45915. /**
  45916. * Get the current class name of the texture useful for serialization or dynamic coding.
  45917. * @returns "PBRClearCoatConfiguration"
  45918. */
  45919. getClassName(): string;
  45920. /**
  45921. * Add fallbacks to the effect fallbacks list.
  45922. * @param defines defines the Base texture to use.
  45923. * @param fallbacks defines the current fallback list.
  45924. * @param currentRank defines the current fallback rank.
  45925. * @returns the new fallback rank.
  45926. */
  45927. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45928. /**
  45929. * Add the required uniforms to the current list.
  45930. * @param uniforms defines the current uniform list.
  45931. */
  45932. static AddUniforms(uniforms: string[]): void;
  45933. /**
  45934. * Add the required samplers to the current list.
  45935. * @param samplers defines the current sampler list.
  45936. */
  45937. static AddSamplers(samplers: string[]): void;
  45938. /**
  45939. * Add the required uniforms to the current buffer.
  45940. * @param uniformBuffer defines the current uniform buffer.
  45941. */
  45942. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45943. /**
  45944. * Makes a duplicate of the current configuration into another one.
  45945. * @param clearCoatConfiguration define the config where to copy the info
  45946. */
  45947. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45948. /**
  45949. * Serializes this clear coat configuration.
  45950. * @returns - An object with the serialized config.
  45951. */
  45952. serialize(): any;
  45953. /**
  45954. * Parses a Clear Coat Configuration from a serialized object.
  45955. * @param source - Serialized object.
  45956. */
  45957. parse(source: any): void;
  45958. }
  45959. }
  45960. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45961. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45962. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45964. import { Vector2 } from "babylonjs/Maths/math";
  45965. import { Scene } from "babylonjs/scene";
  45966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45967. import { IAnimatable } from "babylonjs/Misc/tools";
  45968. import { Nullable } from "babylonjs/types";
  45969. /**
  45970. * @hidden
  45971. */
  45972. export interface IMaterialAnisotropicDefines {
  45973. ANISOTROPIC: boolean;
  45974. ANISOTROPIC_TEXTURE: boolean;
  45975. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45976. MAINUV1: boolean;
  45977. _areTexturesDirty: boolean;
  45978. _needUVs: boolean;
  45979. }
  45980. /**
  45981. * Define the code related to the anisotropic parameters of the pbr material.
  45982. */
  45983. export class PBRAnisotropicConfiguration {
  45984. private _isEnabled;
  45985. /**
  45986. * Defines if the anisotropy is enabled in the material.
  45987. */
  45988. isEnabled: boolean;
  45989. /**
  45990. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45991. */
  45992. intensity: number;
  45993. /**
  45994. * Defines if the effect is along the tangents, bitangents or in between.
  45995. * By default, the effect is "strectching" the highlights along the tangents.
  45996. */
  45997. direction: Vector2;
  45998. private _texture;
  45999. /**
  46000. * Stores the anisotropy values in a texture.
  46001. * rg is direction (like normal from -1 to 1)
  46002. * b is a intensity
  46003. */
  46004. texture: Nullable<BaseTexture>;
  46005. /** @hidden */
  46006. private _internalMarkAllSubMeshesAsTexturesDirty;
  46007. /** @hidden */
  46008. _markAllSubMeshesAsTexturesDirty(): void;
  46009. /**
  46010. * Instantiate a new istance of anisotropy configuration.
  46011. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46012. */
  46013. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46014. /**
  46015. * Specifies that the submesh is ready to be used.
  46016. * @param defines the list of "defines" to update.
  46017. * @param scene defines the scene the material belongs to.
  46018. * @returns - boolean indicating that the submesh is ready or not.
  46019. */
  46020. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46021. /**
  46022. * Checks to see if a texture is used in the material.
  46023. * @param defines the list of "defines" to update.
  46024. * @param mesh the mesh we are preparing the defines for.
  46025. * @param scene defines the scene the material belongs to.
  46026. */
  46027. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46028. /**
  46029. * Binds the material data.
  46030. * @param uniformBuffer defines the Uniform buffer to fill in.
  46031. * @param scene defines the scene the material belongs to.
  46032. * @param isFrozen defines wether the material is frozen or not.
  46033. */
  46034. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46035. /**
  46036. * Checks to see if a texture is used in the material.
  46037. * @param texture - Base texture to use.
  46038. * @returns - Boolean specifying if a texture is used in the material.
  46039. */
  46040. hasTexture(texture: BaseTexture): boolean;
  46041. /**
  46042. * Returns an array of the actively used textures.
  46043. * @param activeTextures Array of BaseTextures
  46044. */
  46045. getActiveTextures(activeTextures: BaseTexture[]): void;
  46046. /**
  46047. * Returns the animatable textures.
  46048. * @param animatables Array of animatable textures.
  46049. */
  46050. getAnimatables(animatables: IAnimatable[]): void;
  46051. /**
  46052. * Disposes the resources of the material.
  46053. * @param forceDisposeTextures - Forces the disposal of all textures.
  46054. */
  46055. dispose(forceDisposeTextures?: boolean): void;
  46056. /**
  46057. * Get the current class name of the texture useful for serialization or dynamic coding.
  46058. * @returns "PBRAnisotropicConfiguration"
  46059. */
  46060. getClassName(): string;
  46061. /**
  46062. * Add fallbacks to the effect fallbacks list.
  46063. * @param defines defines the Base texture to use.
  46064. * @param fallbacks defines the current fallback list.
  46065. * @param currentRank defines the current fallback rank.
  46066. * @returns the new fallback rank.
  46067. */
  46068. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46069. /**
  46070. * Add the required uniforms to the current list.
  46071. * @param uniforms defines the current uniform list.
  46072. */
  46073. static AddUniforms(uniforms: string[]): void;
  46074. /**
  46075. * Add the required uniforms to the current buffer.
  46076. * @param uniformBuffer defines the current uniform buffer.
  46077. */
  46078. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46079. /**
  46080. * Add the required samplers to the current list.
  46081. * @param samplers defines the current sampler list.
  46082. */
  46083. static AddSamplers(samplers: string[]): void;
  46084. /**
  46085. * Makes a duplicate of the current configuration into another one.
  46086. * @param anisotropicConfiguration define the config where to copy the info
  46087. */
  46088. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46089. /**
  46090. * Serializes this anisotropy configuration.
  46091. * @returns - An object with the serialized config.
  46092. */
  46093. serialize(): any;
  46094. /**
  46095. * Parses a anisotropy Configuration from a serialized object.
  46096. * @param source - Serialized object.
  46097. */
  46098. parse(source: any): void;
  46099. }
  46100. }
  46101. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46102. /**
  46103. * @hidden
  46104. */
  46105. export interface IMaterialBRDFDefines {
  46106. BRDF_V_HEIGHT_CORRELATED: boolean;
  46107. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46108. SPHERICAL_HARMONICS: boolean;
  46109. /** @hidden */
  46110. _areMiscDirty: boolean;
  46111. }
  46112. /**
  46113. * Define the code related to the BRDF parameters of the pbr material.
  46114. */
  46115. export class PBRBRDFConfiguration {
  46116. /**
  46117. * Default value used for the energy conservation.
  46118. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46119. */
  46120. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46121. /**
  46122. * Default value used for the Smith Visibility Height Correlated mode.
  46123. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46124. */
  46125. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46126. /**
  46127. * Default value used for the IBL diffuse part.
  46128. * This can help switching back to the polynomials mode globally which is a tiny bit
  46129. * less GPU intensive at the drawback of a lower quality.
  46130. */
  46131. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46132. private _useEnergyConservation;
  46133. /**
  46134. * Defines if the material uses energy conservation.
  46135. */
  46136. useEnergyConservation: boolean;
  46137. private _useSmithVisibilityHeightCorrelated;
  46138. /**
  46139. * LEGACY Mode set to false
  46140. * Defines if the material uses height smith correlated visibility term.
  46141. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46142. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46143. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46144. * Not relying on height correlated will also disable energy conservation.
  46145. */
  46146. useSmithVisibilityHeightCorrelated: boolean;
  46147. private _useSphericalHarmonics;
  46148. /**
  46149. * LEGACY Mode set to false
  46150. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46151. * diffuse part of the IBL.
  46152. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46153. * to the ground truth.
  46154. */
  46155. useSphericalHarmonics: boolean;
  46156. /** @hidden */
  46157. private _internalMarkAllSubMeshesAsMiscDirty;
  46158. /** @hidden */
  46159. _markAllSubMeshesAsMiscDirty(): void;
  46160. /**
  46161. * Instantiate a new istance of clear coat configuration.
  46162. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46163. */
  46164. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46165. /**
  46166. * Checks to see if a texture is used in the material.
  46167. * @param defines the list of "defines" to update.
  46168. */
  46169. prepareDefines(defines: IMaterialBRDFDefines): void;
  46170. /**
  46171. * Get the current class name of the texture useful for serialization or dynamic coding.
  46172. * @returns "PBRClearCoatConfiguration"
  46173. */
  46174. getClassName(): string;
  46175. /**
  46176. * Makes a duplicate of the current configuration into another one.
  46177. * @param brdfConfiguration define the config where to copy the info
  46178. */
  46179. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46180. /**
  46181. * Serializes this BRDF configuration.
  46182. * @returns - An object with the serialized config.
  46183. */
  46184. serialize(): any;
  46185. /**
  46186. * Parses a BRDF Configuration from a serialized object.
  46187. * @param source - Serialized object.
  46188. */
  46189. parse(source: any): void;
  46190. }
  46191. }
  46192. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46193. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46195. import { Color3 } from "babylonjs/Maths/math";
  46196. import { Scene } from "babylonjs/scene";
  46197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46198. import { IAnimatable } from "babylonjs/Misc/tools";
  46199. import { Nullable } from "babylonjs/types";
  46200. /**
  46201. * @hidden
  46202. */
  46203. export interface IMaterialSheenDefines {
  46204. SHEEN: boolean;
  46205. SHEEN_TEXTURE: boolean;
  46206. SHEEN_TEXTUREDIRECTUV: number;
  46207. SHEEN_LINKWITHALBEDO: boolean;
  46208. /** @hidden */
  46209. _areTexturesDirty: boolean;
  46210. }
  46211. /**
  46212. * Define the code related to the Sheen parameters of the pbr material.
  46213. */
  46214. export class PBRSheenConfiguration {
  46215. private _isEnabled;
  46216. /**
  46217. * Defines if the material uses sheen.
  46218. */
  46219. isEnabled: boolean;
  46220. private _linkSheenWithAlbedo;
  46221. /**
  46222. * Defines if the sheen is linked to the sheen color.
  46223. */
  46224. linkSheenWithAlbedo: boolean;
  46225. /**
  46226. * Defines the sheen intensity.
  46227. */
  46228. intensity: number;
  46229. /**
  46230. * Defines the sheen color.
  46231. */
  46232. color: Color3;
  46233. private _texture;
  46234. /**
  46235. * Stores the sheen tint values in a texture.
  46236. * rgb is tint
  46237. * a is a intensity
  46238. */
  46239. texture: Nullable<BaseTexture>;
  46240. /** @hidden */
  46241. private _internalMarkAllSubMeshesAsTexturesDirty;
  46242. /** @hidden */
  46243. _markAllSubMeshesAsTexturesDirty(): void;
  46244. /**
  46245. * Instantiate a new istance of clear coat configuration.
  46246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46247. */
  46248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46249. /**
  46250. * Specifies that the submesh is ready to be used.
  46251. * @param defines the list of "defines" to update.
  46252. * @param scene defines the scene the material belongs to.
  46253. * @returns - boolean indicating that the submesh is ready or not.
  46254. */
  46255. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46256. /**
  46257. * Checks to see if a texture is used in the material.
  46258. * @param defines the list of "defines" to update.
  46259. * @param scene defines the scene the material belongs to.
  46260. */
  46261. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46262. /**
  46263. * Binds the material data.
  46264. * @param uniformBuffer defines the Uniform buffer to fill in.
  46265. * @param scene defines the scene the material belongs to.
  46266. * @param isFrozen defines wether the material is frozen or not.
  46267. */
  46268. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46269. /**
  46270. * Checks to see if a texture is used in the material.
  46271. * @param texture - Base texture to use.
  46272. * @returns - Boolean specifying if a texture is used in the material.
  46273. */
  46274. hasTexture(texture: BaseTexture): boolean;
  46275. /**
  46276. * Returns an array of the actively used textures.
  46277. * @param activeTextures Array of BaseTextures
  46278. */
  46279. getActiveTextures(activeTextures: BaseTexture[]): void;
  46280. /**
  46281. * Returns the animatable textures.
  46282. * @param animatables Array of animatable textures.
  46283. */
  46284. getAnimatables(animatables: IAnimatable[]): void;
  46285. /**
  46286. * Disposes the resources of the material.
  46287. * @param forceDisposeTextures - Forces the disposal of all textures.
  46288. */
  46289. dispose(forceDisposeTextures?: boolean): void;
  46290. /**
  46291. * Get the current class name of the texture useful for serialization or dynamic coding.
  46292. * @returns "PBRSheenConfiguration"
  46293. */
  46294. getClassName(): string;
  46295. /**
  46296. * Add fallbacks to the effect fallbacks list.
  46297. * @param defines defines the Base texture to use.
  46298. * @param fallbacks defines the current fallback list.
  46299. * @param currentRank defines the current fallback rank.
  46300. * @returns the new fallback rank.
  46301. */
  46302. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46303. /**
  46304. * Add the required uniforms to the current list.
  46305. * @param uniforms defines the current uniform list.
  46306. */
  46307. static AddUniforms(uniforms: string[]): void;
  46308. /**
  46309. * Add the required uniforms to the current buffer.
  46310. * @param uniformBuffer defines the current uniform buffer.
  46311. */
  46312. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46313. /**
  46314. * Add the required samplers to the current list.
  46315. * @param samplers defines the current sampler list.
  46316. */
  46317. static AddSamplers(samplers: string[]): void;
  46318. /**
  46319. * Makes a duplicate of the current configuration into another one.
  46320. * @param sheenConfiguration define the config where to copy the info
  46321. */
  46322. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46323. /**
  46324. * Serializes this BRDF configuration.
  46325. * @returns - An object with the serialized config.
  46326. */
  46327. serialize(): any;
  46328. /**
  46329. * Parses a Sheen Configuration from a serialized object.
  46330. * @param source - Serialized object.
  46331. */
  46332. parse(source: any): void;
  46333. }
  46334. }
  46335. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46336. import { Nullable } from "babylonjs/types";
  46337. import { IAnimatable } from "babylonjs/Misc/tools";
  46338. import { Color3 } from "babylonjs/Maths/math";
  46339. import { SmartArray } from "babylonjs/Misc/smartArray";
  46340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46341. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46342. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46343. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46344. import { Engine } from "babylonjs/Engines/engine";
  46345. import { Scene } from "babylonjs/scene";
  46346. /**
  46347. * @hidden
  46348. */
  46349. export interface IMaterialSubSurfaceDefines {
  46350. SUBSURFACE: boolean;
  46351. SS_REFRACTION: boolean;
  46352. SS_TRANSLUCENCY: boolean;
  46353. SS_SCATERRING: boolean;
  46354. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46355. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46356. SS_REFRACTIONMAP_3D: boolean;
  46357. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46358. SS_LODINREFRACTIONALPHA: boolean;
  46359. SS_GAMMAREFRACTION: boolean;
  46360. SS_RGBDREFRACTION: boolean;
  46361. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46362. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46363. /** @hidden */
  46364. _areTexturesDirty: boolean;
  46365. }
  46366. /**
  46367. * Define the code related to the sub surface parameters of the pbr material.
  46368. */
  46369. export class PBRSubSurfaceConfiguration {
  46370. private _isRefractionEnabled;
  46371. /**
  46372. * Defines if the refraction is enabled in the material.
  46373. */
  46374. isRefractionEnabled: boolean;
  46375. private _isTranslucencyEnabled;
  46376. /**
  46377. * Defines if the translucency is enabled in the material.
  46378. */
  46379. isTranslucencyEnabled: boolean;
  46380. private _isScatteringEnabled;
  46381. /**
  46382. * Defines the refraction intensity of the material.
  46383. * The refraction when enabled replaces the Diffuse part of the material.
  46384. * The intensity helps transitionning between diffuse and refraction.
  46385. */
  46386. refractionIntensity: number;
  46387. /**
  46388. * Defines the translucency intensity of the material.
  46389. * When translucency has been enabled, this defines how much of the "translucency"
  46390. * is addded to the diffuse part of the material.
  46391. */
  46392. translucencyIntensity: number;
  46393. /**
  46394. * Defines the scattering intensity of the material.
  46395. * When scattering has been enabled, this defines how much of the "scattered light"
  46396. * is addded to the diffuse part of the material.
  46397. */
  46398. scatteringIntensity: number;
  46399. private _thicknessTexture;
  46400. /**
  46401. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46402. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46403. * 0 would mean minimumThickness
  46404. * 1 would mean maximumThickness
  46405. * The other channels might be use as a mask to vary the different effects intensity.
  46406. */
  46407. thicknessTexture: Nullable<BaseTexture>;
  46408. private _refractionTexture;
  46409. /**
  46410. * Defines the texture to use for refraction.
  46411. */
  46412. refractionTexture: Nullable<BaseTexture>;
  46413. private _indexOfRefraction;
  46414. /**
  46415. * Defines the indice of refraction used in the material.
  46416. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46417. */
  46418. indexOfRefraction: number;
  46419. private _invertRefractionY;
  46420. /**
  46421. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46422. */
  46423. invertRefractionY: boolean;
  46424. private _linkRefractionWithTransparency;
  46425. /**
  46426. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46427. * Materials half opaque for instance using refraction could benefit from this control.
  46428. */
  46429. linkRefractionWithTransparency: boolean;
  46430. /**
  46431. * Defines the minimum thickness stored in the thickness map.
  46432. * If no thickness map is defined, this value will be used to simulate thickness.
  46433. */
  46434. minimumThickness: number;
  46435. /**
  46436. * Defines the maximum thickness stored in the thickness map.
  46437. */
  46438. maximumThickness: number;
  46439. /**
  46440. * Defines the volume tint of the material.
  46441. * This is used for both translucency and scattering.
  46442. */
  46443. tintColor: Color3;
  46444. /**
  46445. * Defines the distance at which the tint color should be found in the media.
  46446. * This is used for refraction only.
  46447. */
  46448. tintColorAtDistance: number;
  46449. /**
  46450. * Defines how far each channel transmit through the media.
  46451. * It is defined as a color to simplify it selection.
  46452. */
  46453. diffusionDistance: Color3;
  46454. private _useMaskFromThicknessTexture;
  46455. /**
  46456. * Stores the intensity of the different subsurface effects in the thickness texture.
  46457. * * the green channel is the translucency intensity.
  46458. * * the blue channel is the scattering intensity.
  46459. * * the alpha channel is the refraction intensity.
  46460. */
  46461. useMaskFromThicknessTexture: boolean;
  46462. /** @hidden */
  46463. private _internalMarkAllSubMeshesAsTexturesDirty;
  46464. /** @hidden */
  46465. _markAllSubMeshesAsTexturesDirty(): void;
  46466. /**
  46467. * Instantiate a new istance of sub surface configuration.
  46468. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46469. */
  46470. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46471. /**
  46472. * Gets wehter the submesh is ready to be used or not.
  46473. * @param defines the list of "defines" to update.
  46474. * @param scene defines the scene the material belongs to.
  46475. * @returns - boolean indicating that the submesh is ready or not.
  46476. */
  46477. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46478. /**
  46479. * Checks to see if a texture is used in the material.
  46480. * @param defines the list of "defines" to update.
  46481. * @param scene defines the scene to the material belongs to.
  46482. */
  46483. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46484. /**
  46485. * Binds the material data.
  46486. * @param uniformBuffer defines the Uniform buffer to fill in.
  46487. * @param scene defines the scene the material belongs to.
  46488. * @param engine defines the engine the material belongs to.
  46489. * @param isFrozen defines wether the material is frozen or not.
  46490. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46491. */
  46492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46493. /**
  46494. * Unbinds the material from the mesh.
  46495. * @param activeEffect defines the effect that should be unbound from.
  46496. * @returns true if unbound, otherwise false
  46497. */
  46498. unbind(activeEffect: Effect): boolean;
  46499. /**
  46500. * Returns the texture used for refraction or null if none is used.
  46501. * @param scene defines the scene the material belongs to.
  46502. * @returns - Refraction texture if present. If no refraction texture and refraction
  46503. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46504. */
  46505. private _getRefractionTexture;
  46506. /**
  46507. * Returns true if alpha blending should be disabled.
  46508. */
  46509. readonly disableAlphaBlending: boolean;
  46510. /**
  46511. * Fills the list of render target textures.
  46512. * @param renderTargets the list of render targets to update
  46513. */
  46514. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46515. /**
  46516. * Checks to see if a texture is used in the material.
  46517. * @param texture - Base texture to use.
  46518. * @returns - Boolean specifying if a texture is used in the material.
  46519. */
  46520. hasTexture(texture: BaseTexture): boolean;
  46521. /**
  46522. * Gets a boolean indicating that current material needs to register RTT
  46523. * @returns true if this uses a render target otherwise false.
  46524. */
  46525. hasRenderTargetTextures(): boolean;
  46526. /**
  46527. * Returns an array of the actively used textures.
  46528. * @param activeTextures Array of BaseTextures
  46529. */
  46530. getActiveTextures(activeTextures: BaseTexture[]): void;
  46531. /**
  46532. * Returns the animatable textures.
  46533. * @param animatables Array of animatable textures.
  46534. */
  46535. getAnimatables(animatables: IAnimatable[]): void;
  46536. /**
  46537. * Disposes the resources of the material.
  46538. * @param forceDisposeTextures - Forces the disposal of all textures.
  46539. */
  46540. dispose(forceDisposeTextures?: boolean): void;
  46541. /**
  46542. * Get the current class name of the texture useful for serialization or dynamic coding.
  46543. * @returns "PBRSubSurfaceConfiguration"
  46544. */
  46545. getClassName(): string;
  46546. /**
  46547. * Add fallbacks to the effect fallbacks list.
  46548. * @param defines defines the Base texture to use.
  46549. * @param fallbacks defines the current fallback list.
  46550. * @param currentRank defines the current fallback rank.
  46551. * @returns the new fallback rank.
  46552. */
  46553. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46554. /**
  46555. * Add the required uniforms to the current list.
  46556. * @param uniforms defines the current uniform list.
  46557. */
  46558. static AddUniforms(uniforms: string[]): void;
  46559. /**
  46560. * Add the required samplers to the current list.
  46561. * @param samplers defines the current sampler list.
  46562. */
  46563. static AddSamplers(samplers: string[]): void;
  46564. /**
  46565. * Add the required uniforms to the current buffer.
  46566. * @param uniformBuffer defines the current uniform buffer.
  46567. */
  46568. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46569. /**
  46570. * Makes a duplicate of the current configuration into another one.
  46571. * @param configuration define the config where to copy the info
  46572. */
  46573. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46574. /**
  46575. * Serializes this Sub Surface configuration.
  46576. * @returns - An object with the serialized config.
  46577. */
  46578. serialize(): any;
  46579. /**
  46580. * Parses a Sub Surface Configuration from a serialized object.
  46581. * @param source - Serialized object.
  46582. */
  46583. parse(source: any): void;
  46584. }
  46585. }
  46586. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46587. /** @hidden */
  46588. export var pbrFragmentDeclaration: {
  46589. name: string;
  46590. shader: string;
  46591. };
  46592. }
  46593. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46594. /** @hidden */
  46595. export var pbrUboDeclaration: {
  46596. name: string;
  46597. shader: string;
  46598. };
  46599. }
  46600. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46601. /** @hidden */
  46602. export var pbrFragmentExtraDeclaration: {
  46603. name: string;
  46604. shader: string;
  46605. };
  46606. }
  46607. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46608. /** @hidden */
  46609. export var pbrFragmentSamplersDeclaration: {
  46610. name: string;
  46611. shader: string;
  46612. };
  46613. }
  46614. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46615. /** @hidden */
  46616. export var pbrHelperFunctions: {
  46617. name: string;
  46618. shader: string;
  46619. };
  46620. }
  46621. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46622. /** @hidden */
  46623. export var harmonicsFunctions: {
  46624. name: string;
  46625. shader: string;
  46626. };
  46627. }
  46628. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46629. /** @hidden */
  46630. export var pbrDirectLightingSetupFunctions: {
  46631. name: string;
  46632. shader: string;
  46633. };
  46634. }
  46635. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46636. /** @hidden */
  46637. export var pbrDirectLightingFalloffFunctions: {
  46638. name: string;
  46639. shader: string;
  46640. };
  46641. }
  46642. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46643. /** @hidden */
  46644. export var pbrBRDFFunctions: {
  46645. name: string;
  46646. shader: string;
  46647. };
  46648. }
  46649. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46650. /** @hidden */
  46651. export var pbrDirectLightingFunctions: {
  46652. name: string;
  46653. shader: string;
  46654. };
  46655. }
  46656. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46657. /** @hidden */
  46658. export var pbrIBLFunctions: {
  46659. name: string;
  46660. shader: string;
  46661. };
  46662. }
  46663. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46664. /** @hidden */
  46665. export var pbrDebug: {
  46666. name: string;
  46667. shader: string;
  46668. };
  46669. }
  46670. declare module "babylonjs/Shaders/pbr.fragment" {
  46671. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46672. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46673. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46674. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46675. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46676. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46677. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46678. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46679. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46680. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46682. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46683. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46684. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46685. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46686. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46687. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46688. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46689. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46690. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46691. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46692. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46693. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46694. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46695. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46696. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46697. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46698. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46699. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46700. /** @hidden */
  46701. export var pbrPixelShader: {
  46702. name: string;
  46703. shader: string;
  46704. };
  46705. }
  46706. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46707. /** @hidden */
  46708. export var pbrVertexDeclaration: {
  46709. name: string;
  46710. shader: string;
  46711. };
  46712. }
  46713. declare module "babylonjs/Shaders/pbr.vertex" {
  46714. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46715. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46716. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46717. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46718. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46719. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46720. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46721. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46722. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46723. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46724. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46726. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46727. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46728. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46729. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46731. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46733. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46734. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46735. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46736. /** @hidden */
  46737. export var pbrVertexShader: {
  46738. name: string;
  46739. shader: string;
  46740. };
  46741. }
  46742. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46743. import { IAnimatable } from "babylonjs/Misc/tools";
  46744. import { Nullable } from "babylonjs/types";
  46745. import { Scene } from "babylonjs/scene";
  46746. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46747. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46749. import { Mesh } from "babylonjs/Meshes/mesh";
  46750. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46751. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46752. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46753. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46754. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46755. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46756. import { Material } from "babylonjs/Materials/material";
  46757. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46758. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46760. import "babylonjs/Shaders/pbr.fragment";
  46761. import "babylonjs/Shaders/pbr.vertex";
  46762. /**
  46763. * Manages the defines for the PBR Material.
  46764. * @hidden
  46765. */
  46766. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46767. PBR: boolean;
  46768. MAINUV1: boolean;
  46769. MAINUV2: boolean;
  46770. UV1: boolean;
  46771. UV2: boolean;
  46772. ALBEDO: boolean;
  46773. ALBEDODIRECTUV: number;
  46774. VERTEXCOLOR: boolean;
  46775. AMBIENT: boolean;
  46776. AMBIENTDIRECTUV: number;
  46777. AMBIENTINGRAYSCALE: boolean;
  46778. OPACITY: boolean;
  46779. VERTEXALPHA: boolean;
  46780. OPACITYDIRECTUV: number;
  46781. OPACITYRGB: boolean;
  46782. ALPHATEST: boolean;
  46783. DEPTHPREPASS: boolean;
  46784. ALPHABLEND: boolean;
  46785. ALPHAFROMALBEDO: boolean;
  46786. ALPHATESTVALUE: string;
  46787. SPECULAROVERALPHA: boolean;
  46788. RADIANCEOVERALPHA: boolean;
  46789. ALPHAFRESNEL: boolean;
  46790. LINEARALPHAFRESNEL: boolean;
  46791. PREMULTIPLYALPHA: boolean;
  46792. EMISSIVE: boolean;
  46793. EMISSIVEDIRECTUV: number;
  46794. REFLECTIVITY: boolean;
  46795. REFLECTIVITYDIRECTUV: number;
  46796. SPECULARTERM: boolean;
  46797. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46798. MICROSURFACEAUTOMATIC: boolean;
  46799. LODBASEDMICROSFURACE: boolean;
  46800. MICROSURFACEMAP: boolean;
  46801. MICROSURFACEMAPDIRECTUV: number;
  46802. METALLICWORKFLOW: boolean;
  46803. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46804. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46805. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46806. AOSTOREINMETALMAPRED: boolean;
  46807. ENVIRONMENTBRDF: boolean;
  46808. ENVIRONMENTBRDF_RGBD: boolean;
  46809. NORMAL: boolean;
  46810. TANGENT: boolean;
  46811. BUMP: boolean;
  46812. BUMPDIRECTUV: number;
  46813. OBJECTSPACE_NORMALMAP: boolean;
  46814. PARALLAX: boolean;
  46815. PARALLAXOCCLUSION: boolean;
  46816. NORMALXYSCALE: boolean;
  46817. LIGHTMAP: boolean;
  46818. LIGHTMAPDIRECTUV: number;
  46819. USELIGHTMAPASSHADOWMAP: boolean;
  46820. GAMMALIGHTMAP: boolean;
  46821. REFLECTION: boolean;
  46822. REFLECTIONMAP_3D: boolean;
  46823. REFLECTIONMAP_SPHERICAL: boolean;
  46824. REFLECTIONMAP_PLANAR: boolean;
  46825. REFLECTIONMAP_CUBIC: boolean;
  46826. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46827. REFLECTIONMAP_PROJECTION: boolean;
  46828. REFLECTIONMAP_SKYBOX: boolean;
  46829. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46830. REFLECTIONMAP_EXPLICIT: boolean;
  46831. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46832. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46833. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46834. INVERTCUBICMAP: boolean;
  46835. USESPHERICALFROMREFLECTIONMAP: boolean;
  46836. SPHERICAL_HARMONICS: boolean;
  46837. USESPHERICALINVERTEX: boolean;
  46838. REFLECTIONMAP_OPPOSITEZ: boolean;
  46839. LODINREFLECTIONALPHA: boolean;
  46840. GAMMAREFLECTION: boolean;
  46841. RGBDREFLECTION: boolean;
  46842. RADIANCEOCCLUSION: boolean;
  46843. HORIZONOCCLUSION: boolean;
  46844. INSTANCES: boolean;
  46845. NUM_BONE_INFLUENCERS: number;
  46846. BonesPerMesh: number;
  46847. BONETEXTURE: boolean;
  46848. NONUNIFORMSCALING: boolean;
  46849. MORPHTARGETS: boolean;
  46850. MORPHTARGETS_NORMAL: boolean;
  46851. MORPHTARGETS_TANGENT: boolean;
  46852. NUM_MORPH_INFLUENCERS: number;
  46853. IMAGEPROCESSING: boolean;
  46854. VIGNETTE: boolean;
  46855. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46856. VIGNETTEBLENDMODEOPAQUE: boolean;
  46857. TONEMAPPING: boolean;
  46858. TONEMAPPING_ACES: boolean;
  46859. CONTRAST: boolean;
  46860. COLORCURVES: boolean;
  46861. COLORGRADING: boolean;
  46862. COLORGRADING3D: boolean;
  46863. SAMPLER3DGREENDEPTH: boolean;
  46864. SAMPLER3DBGRMAP: boolean;
  46865. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46866. EXPOSURE: boolean;
  46867. MULTIVIEW: boolean;
  46868. USEPHYSICALLIGHTFALLOFF: boolean;
  46869. USEGLTFLIGHTFALLOFF: boolean;
  46870. TWOSIDEDLIGHTING: boolean;
  46871. SHADOWFLOAT: boolean;
  46872. CLIPPLANE: boolean;
  46873. CLIPPLANE2: boolean;
  46874. CLIPPLANE3: boolean;
  46875. CLIPPLANE4: boolean;
  46876. POINTSIZE: boolean;
  46877. FOG: boolean;
  46878. LOGARITHMICDEPTH: boolean;
  46879. FORCENORMALFORWARD: boolean;
  46880. SPECULARAA: boolean;
  46881. CLEARCOAT: boolean;
  46882. CLEARCOAT_DEFAULTIOR: boolean;
  46883. CLEARCOAT_TEXTURE: boolean;
  46884. CLEARCOAT_TEXTUREDIRECTUV: number;
  46885. CLEARCOAT_BUMP: boolean;
  46886. CLEARCOAT_BUMPDIRECTUV: number;
  46887. CLEARCOAT_TINT: boolean;
  46888. CLEARCOAT_TINT_TEXTURE: boolean;
  46889. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46890. ANISOTROPIC: boolean;
  46891. ANISOTROPIC_TEXTURE: boolean;
  46892. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46893. BRDF_V_HEIGHT_CORRELATED: boolean;
  46894. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46895. SHEEN: boolean;
  46896. SHEEN_TEXTURE: boolean;
  46897. SHEEN_TEXTUREDIRECTUV: number;
  46898. SHEEN_LINKWITHALBEDO: boolean;
  46899. SUBSURFACE: boolean;
  46900. SS_REFRACTION: boolean;
  46901. SS_TRANSLUCENCY: boolean;
  46902. SS_SCATERRING: boolean;
  46903. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46904. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46905. SS_REFRACTIONMAP_3D: boolean;
  46906. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46907. SS_LODINREFRACTIONALPHA: boolean;
  46908. SS_GAMMAREFRACTION: boolean;
  46909. SS_RGBDREFRACTION: boolean;
  46910. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46911. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46912. UNLIT: boolean;
  46913. DEBUGMODE: number;
  46914. /**
  46915. * Initializes the PBR Material defines.
  46916. */
  46917. constructor();
  46918. /**
  46919. * Resets the PBR Material defines.
  46920. */
  46921. reset(): void;
  46922. }
  46923. /**
  46924. * The Physically based material base class of BJS.
  46925. *
  46926. * This offers the main features of a standard PBR material.
  46927. * For more information, please refer to the documentation :
  46928. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46929. */
  46930. export abstract class PBRBaseMaterial extends PushMaterial {
  46931. /**
  46932. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46933. */
  46934. static readonly PBRMATERIAL_OPAQUE: number;
  46935. /**
  46936. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46937. */
  46938. static readonly PBRMATERIAL_ALPHATEST: number;
  46939. /**
  46940. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46941. */
  46942. static readonly PBRMATERIAL_ALPHABLEND: number;
  46943. /**
  46944. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46945. * They are also discarded below the alpha cutoff threshold to improve performances.
  46946. */
  46947. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46948. /**
  46949. * Defines the default value of how much AO map is occluding the analytical lights
  46950. * (point spot...).
  46951. */
  46952. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46953. /**
  46954. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46955. */
  46956. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46957. /**
  46958. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46959. * to enhance interoperability with other engines.
  46960. */
  46961. static readonly LIGHTFALLOFF_GLTF: number;
  46962. /**
  46963. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46964. * to enhance interoperability with other materials.
  46965. */
  46966. static readonly LIGHTFALLOFF_STANDARD: number;
  46967. /**
  46968. * Intensity of the direct lights e.g. the four lights available in your scene.
  46969. * This impacts both the direct diffuse and specular highlights.
  46970. */
  46971. protected _directIntensity: number;
  46972. /**
  46973. * Intensity of the emissive part of the material.
  46974. * This helps controlling the emissive effect without modifying the emissive color.
  46975. */
  46976. protected _emissiveIntensity: number;
  46977. /**
  46978. * Intensity of the environment e.g. how much the environment will light the object
  46979. * either through harmonics for rough material or through the refelction for shiny ones.
  46980. */
  46981. protected _environmentIntensity: number;
  46982. /**
  46983. * This is a special control allowing the reduction of the specular highlights coming from the
  46984. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46985. */
  46986. protected _specularIntensity: number;
  46987. /**
  46988. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46989. */
  46990. private _lightingInfos;
  46991. /**
  46992. * Debug Control allowing disabling the bump map on this material.
  46993. */
  46994. protected _disableBumpMap: boolean;
  46995. /**
  46996. * AKA Diffuse Texture in standard nomenclature.
  46997. */
  46998. protected _albedoTexture: Nullable<BaseTexture>;
  46999. /**
  47000. * AKA Occlusion Texture in other nomenclature.
  47001. */
  47002. protected _ambientTexture: Nullable<BaseTexture>;
  47003. /**
  47004. * AKA Occlusion Texture Intensity in other nomenclature.
  47005. */
  47006. protected _ambientTextureStrength: number;
  47007. /**
  47008. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47009. * 1 means it completely occludes it
  47010. * 0 mean it has no impact
  47011. */
  47012. protected _ambientTextureImpactOnAnalyticalLights: number;
  47013. /**
  47014. * Stores the alpha values in a texture.
  47015. */
  47016. protected _opacityTexture: Nullable<BaseTexture>;
  47017. /**
  47018. * Stores the reflection values in a texture.
  47019. */
  47020. protected _reflectionTexture: Nullable<BaseTexture>;
  47021. /**
  47022. * Stores the emissive values in a texture.
  47023. */
  47024. protected _emissiveTexture: Nullable<BaseTexture>;
  47025. /**
  47026. * AKA Specular texture in other nomenclature.
  47027. */
  47028. protected _reflectivityTexture: Nullable<BaseTexture>;
  47029. /**
  47030. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47031. */
  47032. protected _metallicTexture: Nullable<BaseTexture>;
  47033. /**
  47034. * Specifies the metallic scalar of the metallic/roughness workflow.
  47035. * Can also be used to scale the metalness values of the metallic texture.
  47036. */
  47037. protected _metallic: Nullable<number>;
  47038. /**
  47039. * Specifies the roughness scalar of the metallic/roughness workflow.
  47040. * Can also be used to scale the roughness values of the metallic texture.
  47041. */
  47042. protected _roughness: Nullable<number>;
  47043. /**
  47044. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47045. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47046. */
  47047. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47048. /**
  47049. * Stores surface normal data used to displace a mesh in a texture.
  47050. */
  47051. protected _bumpTexture: Nullable<BaseTexture>;
  47052. /**
  47053. * Stores the pre-calculated light information of a mesh in a texture.
  47054. */
  47055. protected _lightmapTexture: Nullable<BaseTexture>;
  47056. /**
  47057. * The color of a material in ambient lighting.
  47058. */
  47059. protected _ambientColor: Color3;
  47060. /**
  47061. * AKA Diffuse Color in other nomenclature.
  47062. */
  47063. protected _albedoColor: Color3;
  47064. /**
  47065. * AKA Specular Color in other nomenclature.
  47066. */
  47067. protected _reflectivityColor: Color3;
  47068. /**
  47069. * The color applied when light is reflected from a material.
  47070. */
  47071. protected _reflectionColor: Color3;
  47072. /**
  47073. * The color applied when light is emitted from a material.
  47074. */
  47075. protected _emissiveColor: Color3;
  47076. /**
  47077. * AKA Glossiness in other nomenclature.
  47078. */
  47079. protected _microSurface: number;
  47080. /**
  47081. * Specifies that the material will use the light map as a show map.
  47082. */
  47083. protected _useLightmapAsShadowmap: boolean;
  47084. /**
  47085. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47086. * makes the reflect vector face the model (under horizon).
  47087. */
  47088. protected _useHorizonOcclusion: boolean;
  47089. /**
  47090. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47091. * too much the area relying on ambient texture to define their ambient occlusion.
  47092. */
  47093. protected _useRadianceOcclusion: boolean;
  47094. /**
  47095. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47096. */
  47097. protected _useAlphaFromAlbedoTexture: boolean;
  47098. /**
  47099. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47100. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47101. */
  47102. protected _useSpecularOverAlpha: boolean;
  47103. /**
  47104. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47105. */
  47106. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47107. /**
  47108. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47109. */
  47110. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47111. /**
  47112. * Specifies if the metallic texture contains the roughness information in its green channel.
  47113. */
  47114. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47115. /**
  47116. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47117. */
  47118. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47119. /**
  47120. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47121. */
  47122. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47123. /**
  47124. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47125. */
  47126. protected _useAmbientInGrayScale: boolean;
  47127. /**
  47128. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47129. * The material will try to infer what glossiness each pixel should be.
  47130. */
  47131. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47132. /**
  47133. * Defines the falloff type used in this material.
  47134. * It by default is Physical.
  47135. */
  47136. protected _lightFalloff: number;
  47137. /**
  47138. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47139. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47140. */
  47141. protected _useRadianceOverAlpha: boolean;
  47142. /**
  47143. * Allows using an object space normal map (instead of tangent space).
  47144. */
  47145. protected _useObjectSpaceNormalMap: boolean;
  47146. /**
  47147. * Allows using the bump map in parallax mode.
  47148. */
  47149. protected _useParallax: boolean;
  47150. /**
  47151. * Allows using the bump map in parallax occlusion mode.
  47152. */
  47153. protected _useParallaxOcclusion: boolean;
  47154. /**
  47155. * Controls the scale bias of the parallax mode.
  47156. */
  47157. protected _parallaxScaleBias: number;
  47158. /**
  47159. * If sets to true, disables all the lights affecting the material.
  47160. */
  47161. protected _disableLighting: boolean;
  47162. /**
  47163. * Number of Simultaneous lights allowed on the material.
  47164. */
  47165. protected _maxSimultaneousLights: number;
  47166. /**
  47167. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47168. */
  47169. protected _invertNormalMapX: boolean;
  47170. /**
  47171. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47172. */
  47173. protected _invertNormalMapY: boolean;
  47174. /**
  47175. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47176. */
  47177. protected _twoSidedLighting: boolean;
  47178. /**
  47179. * Defines the alpha limits in alpha test mode.
  47180. */
  47181. protected _alphaCutOff: number;
  47182. /**
  47183. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47184. */
  47185. protected _forceAlphaTest: boolean;
  47186. /**
  47187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47188. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47189. */
  47190. protected _useAlphaFresnel: boolean;
  47191. /**
  47192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47193. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47194. */
  47195. protected _useLinearAlphaFresnel: boolean;
  47196. /**
  47197. * The transparency mode of the material.
  47198. */
  47199. protected _transparencyMode: Nullable<number>;
  47200. /**
  47201. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47202. * from cos thetav and roughness:
  47203. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47204. */
  47205. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47206. /**
  47207. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47208. */
  47209. protected _forceIrradianceInFragment: boolean;
  47210. /**
  47211. * Force normal to face away from face.
  47212. */
  47213. protected _forceNormalForward: boolean;
  47214. /**
  47215. * Enables specular anti aliasing in the PBR shader.
  47216. * It will both interacts on the Geometry for analytical and IBL lighting.
  47217. * It also prefilter the roughness map based on the bump values.
  47218. */
  47219. protected _enableSpecularAntiAliasing: boolean;
  47220. /**
  47221. * Default configuration related to image processing available in the PBR Material.
  47222. */
  47223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47224. /**
  47225. * Keep track of the image processing observer to allow dispose and replace.
  47226. */
  47227. private _imageProcessingObserver;
  47228. /**
  47229. * Attaches a new image processing configuration to the PBR Material.
  47230. * @param configuration
  47231. */
  47232. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47233. /**
  47234. * Stores the available render targets.
  47235. */
  47236. private _renderTargets;
  47237. /**
  47238. * Sets the global ambient color for the material used in lighting calculations.
  47239. */
  47240. private _globalAmbientColor;
  47241. /**
  47242. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47243. */
  47244. private _useLogarithmicDepth;
  47245. /**
  47246. * If set to true, no lighting calculations will be applied.
  47247. */
  47248. private _unlit;
  47249. private _debugMode;
  47250. /**
  47251. * @hidden
  47252. * This is reserved for the inspector.
  47253. * Defines the material debug mode.
  47254. * It helps seeing only some components of the material while troubleshooting.
  47255. */
  47256. debugMode: number;
  47257. /**
  47258. * @hidden
  47259. * This is reserved for the inspector.
  47260. * Specify from where on screen the debug mode should start.
  47261. * The value goes from -1 (full screen) to 1 (not visible)
  47262. * It helps with side by side comparison against the final render
  47263. * This defaults to -1
  47264. */
  47265. private debugLimit;
  47266. /**
  47267. * @hidden
  47268. * This is reserved for the inspector.
  47269. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47270. * You can use the factor to better multiply the final value.
  47271. */
  47272. private debugFactor;
  47273. /**
  47274. * Defines the clear coat layer parameters for the material.
  47275. */
  47276. readonly clearCoat: PBRClearCoatConfiguration;
  47277. /**
  47278. * Defines the anisotropic parameters for the material.
  47279. */
  47280. readonly anisotropy: PBRAnisotropicConfiguration;
  47281. /**
  47282. * Defines the BRDF parameters for the material.
  47283. */
  47284. readonly brdf: PBRBRDFConfiguration;
  47285. /**
  47286. * Defines the Sheen parameters for the material.
  47287. */
  47288. readonly sheen: PBRSheenConfiguration;
  47289. /**
  47290. * Defines the SubSurface parameters for the material.
  47291. */
  47292. readonly subSurface: PBRSubSurfaceConfiguration;
  47293. /**
  47294. * Custom callback helping to override the default shader used in the material.
  47295. */
  47296. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47297. /**
  47298. * Instantiates a new PBRMaterial instance.
  47299. *
  47300. * @param name The material name
  47301. * @param scene The scene the material will be use in.
  47302. */
  47303. constructor(name: string, scene: Scene);
  47304. /**
  47305. * Gets a boolean indicating that current material needs to register RTT
  47306. */
  47307. readonly hasRenderTargetTextures: boolean;
  47308. /**
  47309. * Gets the name of the material class.
  47310. */
  47311. getClassName(): string;
  47312. /**
  47313. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47314. */
  47315. /**
  47316. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47317. */
  47318. useLogarithmicDepth: boolean;
  47319. /**
  47320. * Gets the current transparency mode.
  47321. */
  47322. /**
  47323. * Sets the transparency mode of the material.
  47324. *
  47325. * | Value | Type | Description |
  47326. * | ----- | ----------------------------------- | ----------- |
  47327. * | 0 | OPAQUE | |
  47328. * | 1 | ALPHATEST | |
  47329. * | 2 | ALPHABLEND | |
  47330. * | 3 | ALPHATESTANDBLEND | |
  47331. *
  47332. */
  47333. transparencyMode: Nullable<number>;
  47334. /**
  47335. * Returns true if alpha blending should be disabled.
  47336. */
  47337. private readonly _disableAlphaBlending;
  47338. /**
  47339. * Specifies whether or not this material should be rendered in alpha blend mode.
  47340. */
  47341. needAlphaBlending(): boolean;
  47342. /**
  47343. * Specifies if the mesh will require alpha blending.
  47344. * @param mesh - BJS mesh.
  47345. */
  47346. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47347. /**
  47348. * Specifies whether or not this material should be rendered in alpha test mode.
  47349. */
  47350. needAlphaTesting(): boolean;
  47351. /**
  47352. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47353. */
  47354. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47355. /**
  47356. * Gets the texture used for the alpha test.
  47357. */
  47358. getAlphaTestTexture(): Nullable<BaseTexture>;
  47359. /**
  47360. * Specifies that the submesh is ready to be used.
  47361. * @param mesh - BJS mesh.
  47362. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47363. * @param useInstances - Specifies that instances should be used.
  47364. * @returns - boolean indicating that the submesh is ready or not.
  47365. */
  47366. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47367. /**
  47368. * Specifies if the material uses metallic roughness workflow.
  47369. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47370. */
  47371. isMetallicWorkflow(): boolean;
  47372. private _prepareEffect;
  47373. private _prepareDefines;
  47374. /**
  47375. * Force shader compilation
  47376. */
  47377. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47378. clipPlane: boolean;
  47379. }>): void;
  47380. /**
  47381. * Initializes the uniform buffer layout for the shader.
  47382. */
  47383. buildUniformLayout(): void;
  47384. /**
  47385. * Unbinds the material from the mesh
  47386. */
  47387. unbind(): void;
  47388. /**
  47389. * Binds the submesh data.
  47390. * @param world - The world matrix.
  47391. * @param mesh - The BJS mesh.
  47392. * @param subMesh - A submesh of the BJS mesh.
  47393. */
  47394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47395. /**
  47396. * Returns the animatable textures.
  47397. * @returns - Array of animatable textures.
  47398. */
  47399. getAnimatables(): IAnimatable[];
  47400. /**
  47401. * Returns the texture used for reflections.
  47402. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47403. */
  47404. private _getReflectionTexture;
  47405. /**
  47406. * Returns an array of the actively used textures.
  47407. * @returns - Array of BaseTextures
  47408. */
  47409. getActiveTextures(): BaseTexture[];
  47410. /**
  47411. * Checks to see if a texture is used in the material.
  47412. * @param texture - Base texture to use.
  47413. * @returns - Boolean specifying if a texture is used in the material.
  47414. */
  47415. hasTexture(texture: BaseTexture): boolean;
  47416. /**
  47417. * Disposes the resources of the material.
  47418. * @param forceDisposeEffect - Forces the disposal of effects.
  47419. * @param forceDisposeTextures - Forces the disposal of all textures.
  47420. */
  47421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47422. }
  47423. }
  47424. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47425. import { Nullable } from "babylonjs/types";
  47426. import { Scene } from "babylonjs/scene";
  47427. import { Color3 } from "babylonjs/Maths/math";
  47428. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47429. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47431. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47432. /**
  47433. * The Physically based material of BJS.
  47434. *
  47435. * This offers the main features of a standard PBR material.
  47436. * For more information, please refer to the documentation :
  47437. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47438. */
  47439. export class PBRMaterial extends PBRBaseMaterial {
  47440. /**
  47441. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47442. */
  47443. static readonly PBRMATERIAL_OPAQUE: number;
  47444. /**
  47445. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47446. */
  47447. static readonly PBRMATERIAL_ALPHATEST: number;
  47448. /**
  47449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47450. */
  47451. static readonly PBRMATERIAL_ALPHABLEND: number;
  47452. /**
  47453. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47454. * They are also discarded below the alpha cutoff threshold to improve performances.
  47455. */
  47456. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47457. /**
  47458. * Defines the default value of how much AO map is occluding the analytical lights
  47459. * (point spot...).
  47460. */
  47461. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47462. /**
  47463. * Intensity of the direct lights e.g. the four lights available in your scene.
  47464. * This impacts both the direct diffuse and specular highlights.
  47465. */
  47466. directIntensity: number;
  47467. /**
  47468. * Intensity of the emissive part of the material.
  47469. * This helps controlling the emissive effect without modifying the emissive color.
  47470. */
  47471. emissiveIntensity: number;
  47472. /**
  47473. * Intensity of the environment e.g. how much the environment will light the object
  47474. * either through harmonics for rough material or through the refelction for shiny ones.
  47475. */
  47476. environmentIntensity: number;
  47477. /**
  47478. * This is a special control allowing the reduction of the specular highlights coming from the
  47479. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47480. */
  47481. specularIntensity: number;
  47482. /**
  47483. * Debug Control allowing disabling the bump map on this material.
  47484. */
  47485. disableBumpMap: boolean;
  47486. /**
  47487. * AKA Diffuse Texture in standard nomenclature.
  47488. */
  47489. albedoTexture: BaseTexture;
  47490. /**
  47491. * AKA Occlusion Texture in other nomenclature.
  47492. */
  47493. ambientTexture: BaseTexture;
  47494. /**
  47495. * AKA Occlusion Texture Intensity in other nomenclature.
  47496. */
  47497. ambientTextureStrength: number;
  47498. /**
  47499. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47500. * 1 means it completely occludes it
  47501. * 0 mean it has no impact
  47502. */
  47503. ambientTextureImpactOnAnalyticalLights: number;
  47504. /**
  47505. * Stores the alpha values in a texture.
  47506. */
  47507. opacityTexture: BaseTexture;
  47508. /**
  47509. * Stores the reflection values in a texture.
  47510. */
  47511. reflectionTexture: Nullable<BaseTexture>;
  47512. /**
  47513. * Stores the emissive values in a texture.
  47514. */
  47515. emissiveTexture: BaseTexture;
  47516. /**
  47517. * AKA Specular texture in other nomenclature.
  47518. */
  47519. reflectivityTexture: BaseTexture;
  47520. /**
  47521. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47522. */
  47523. metallicTexture: BaseTexture;
  47524. /**
  47525. * Specifies the metallic scalar of the metallic/roughness workflow.
  47526. * Can also be used to scale the metalness values of the metallic texture.
  47527. */
  47528. metallic: Nullable<number>;
  47529. /**
  47530. * Specifies the roughness scalar of the metallic/roughness workflow.
  47531. * Can also be used to scale the roughness values of the metallic texture.
  47532. */
  47533. roughness: Nullable<number>;
  47534. /**
  47535. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47537. */
  47538. microSurfaceTexture: BaseTexture;
  47539. /**
  47540. * Stores surface normal data used to displace a mesh in a texture.
  47541. */
  47542. bumpTexture: BaseTexture;
  47543. /**
  47544. * Stores the pre-calculated light information of a mesh in a texture.
  47545. */
  47546. lightmapTexture: BaseTexture;
  47547. /**
  47548. * Stores the refracted light information in a texture.
  47549. */
  47550. refractionTexture: Nullable<BaseTexture>;
  47551. /**
  47552. * The color of a material in ambient lighting.
  47553. */
  47554. ambientColor: Color3;
  47555. /**
  47556. * AKA Diffuse Color in other nomenclature.
  47557. */
  47558. albedoColor: Color3;
  47559. /**
  47560. * AKA Specular Color in other nomenclature.
  47561. */
  47562. reflectivityColor: Color3;
  47563. /**
  47564. * The color reflected from the material.
  47565. */
  47566. reflectionColor: Color3;
  47567. /**
  47568. * The color emitted from the material.
  47569. */
  47570. emissiveColor: Color3;
  47571. /**
  47572. * AKA Glossiness in other nomenclature.
  47573. */
  47574. microSurface: number;
  47575. /**
  47576. * source material index of refraction (IOR)' / 'destination material IOR.
  47577. */
  47578. indexOfRefraction: number;
  47579. /**
  47580. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47581. */
  47582. invertRefractionY: boolean;
  47583. /**
  47584. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47585. * Materials half opaque for instance using refraction could benefit from this control.
  47586. */
  47587. linkRefractionWithTransparency: boolean;
  47588. /**
  47589. * If true, the light map contains occlusion information instead of lighting info.
  47590. */
  47591. useLightmapAsShadowmap: boolean;
  47592. /**
  47593. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47594. */
  47595. useAlphaFromAlbedoTexture: boolean;
  47596. /**
  47597. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47598. */
  47599. forceAlphaTest: boolean;
  47600. /**
  47601. * Defines the alpha limits in alpha test mode.
  47602. */
  47603. alphaCutOff: number;
  47604. /**
  47605. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47607. */
  47608. useSpecularOverAlpha: boolean;
  47609. /**
  47610. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47611. */
  47612. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47613. /**
  47614. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47615. */
  47616. useRoughnessFromMetallicTextureAlpha: boolean;
  47617. /**
  47618. * Specifies if the metallic texture contains the roughness information in its green channel.
  47619. */
  47620. useRoughnessFromMetallicTextureGreen: boolean;
  47621. /**
  47622. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47623. */
  47624. useMetallnessFromMetallicTextureBlue: boolean;
  47625. /**
  47626. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47627. */
  47628. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47629. /**
  47630. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47631. */
  47632. useAmbientInGrayScale: boolean;
  47633. /**
  47634. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47635. * The material will try to infer what glossiness each pixel should be.
  47636. */
  47637. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47638. /**
  47639. * BJS is using an harcoded light falloff based on a manually sets up range.
  47640. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47641. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47642. */
  47643. /**
  47644. * BJS is using an harcoded light falloff based on a manually sets up range.
  47645. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47646. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47647. */
  47648. usePhysicalLightFalloff: boolean;
  47649. /**
  47650. * In order to support the falloff compatibility with gltf, a special mode has been added
  47651. * to reproduce the gltf light falloff.
  47652. */
  47653. /**
  47654. * In order to support the falloff compatibility with gltf, a special mode has been added
  47655. * to reproduce the gltf light falloff.
  47656. */
  47657. useGLTFLightFalloff: boolean;
  47658. /**
  47659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47661. */
  47662. useRadianceOverAlpha: boolean;
  47663. /**
  47664. * Allows using an object space normal map (instead of tangent space).
  47665. */
  47666. useObjectSpaceNormalMap: boolean;
  47667. /**
  47668. * Allows using the bump map in parallax mode.
  47669. */
  47670. useParallax: boolean;
  47671. /**
  47672. * Allows using the bump map in parallax occlusion mode.
  47673. */
  47674. useParallaxOcclusion: boolean;
  47675. /**
  47676. * Controls the scale bias of the parallax mode.
  47677. */
  47678. parallaxScaleBias: number;
  47679. /**
  47680. * If sets to true, disables all the lights affecting the material.
  47681. */
  47682. disableLighting: boolean;
  47683. /**
  47684. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47685. */
  47686. forceIrradianceInFragment: boolean;
  47687. /**
  47688. * Number of Simultaneous lights allowed on the material.
  47689. */
  47690. maxSimultaneousLights: number;
  47691. /**
  47692. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47693. */
  47694. invertNormalMapX: boolean;
  47695. /**
  47696. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47697. */
  47698. invertNormalMapY: boolean;
  47699. /**
  47700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47701. */
  47702. twoSidedLighting: boolean;
  47703. /**
  47704. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47705. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47706. */
  47707. useAlphaFresnel: boolean;
  47708. /**
  47709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47710. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47711. */
  47712. useLinearAlphaFresnel: boolean;
  47713. /**
  47714. * Let user defines the brdf lookup texture used for IBL.
  47715. * A default 8bit version is embedded but you could point at :
  47716. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47717. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47718. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47719. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47720. */
  47721. environmentBRDFTexture: Nullable<BaseTexture>;
  47722. /**
  47723. * Force normal to face away from face.
  47724. */
  47725. forceNormalForward: boolean;
  47726. /**
  47727. * Enables specular anti aliasing in the PBR shader.
  47728. * It will both interacts on the Geometry for analytical and IBL lighting.
  47729. * It also prefilter the roughness map based on the bump values.
  47730. */
  47731. enableSpecularAntiAliasing: boolean;
  47732. /**
  47733. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47734. * makes the reflect vector face the model (under horizon).
  47735. */
  47736. useHorizonOcclusion: boolean;
  47737. /**
  47738. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47739. * too much the area relying on ambient texture to define their ambient occlusion.
  47740. */
  47741. useRadianceOcclusion: boolean;
  47742. /**
  47743. * If set to true, no lighting calculations will be applied.
  47744. */
  47745. unlit: boolean;
  47746. /**
  47747. * Gets the image processing configuration used either in this material.
  47748. */
  47749. /**
  47750. * Sets the Default image processing configuration used either in the this material.
  47751. *
  47752. * If sets to null, the scene one is in use.
  47753. */
  47754. imageProcessingConfiguration: ImageProcessingConfiguration;
  47755. /**
  47756. * Gets wether the color curves effect is enabled.
  47757. */
  47758. /**
  47759. * Sets wether the color curves effect is enabled.
  47760. */
  47761. cameraColorCurvesEnabled: boolean;
  47762. /**
  47763. * Gets wether the color grading effect is enabled.
  47764. */
  47765. /**
  47766. * Gets wether the color grading effect is enabled.
  47767. */
  47768. cameraColorGradingEnabled: boolean;
  47769. /**
  47770. * Gets wether tonemapping is enabled or not.
  47771. */
  47772. /**
  47773. * Sets wether tonemapping is enabled or not
  47774. */
  47775. cameraToneMappingEnabled: boolean;
  47776. /**
  47777. * The camera exposure used on this material.
  47778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47779. * This corresponds to a photographic exposure.
  47780. */
  47781. /**
  47782. * The camera exposure used on this material.
  47783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47784. * This corresponds to a photographic exposure.
  47785. */
  47786. cameraExposure: number;
  47787. /**
  47788. * Gets The camera contrast used on this material.
  47789. */
  47790. /**
  47791. * Sets The camera contrast used on this material.
  47792. */
  47793. cameraContrast: number;
  47794. /**
  47795. * Gets the Color Grading 2D Lookup Texture.
  47796. */
  47797. /**
  47798. * Sets the Color Grading 2D Lookup Texture.
  47799. */
  47800. cameraColorGradingTexture: Nullable<BaseTexture>;
  47801. /**
  47802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47804. * 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;
  47805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47806. */
  47807. /**
  47808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47810. * 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;
  47811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47812. */
  47813. cameraColorCurves: Nullable<ColorCurves>;
  47814. /**
  47815. * Instantiates a new PBRMaterial instance.
  47816. *
  47817. * @param name The material name
  47818. * @param scene The scene the material will be use in.
  47819. */
  47820. constructor(name: string, scene: Scene);
  47821. /**
  47822. * Returns the name of this material class.
  47823. */
  47824. getClassName(): string;
  47825. /**
  47826. * Makes a duplicate of the current material.
  47827. * @param name - name to use for the new material.
  47828. */
  47829. clone(name: string): PBRMaterial;
  47830. /**
  47831. * Serializes this PBR Material.
  47832. * @returns - An object with the serialized material.
  47833. */
  47834. serialize(): any;
  47835. /**
  47836. * Parses a PBR Material from a serialized object.
  47837. * @param source - Serialized object.
  47838. * @param scene - BJS scene instance.
  47839. * @param rootUrl - url for the scene object
  47840. * @returns - PBRMaterial
  47841. */
  47842. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47843. }
  47844. }
  47845. declare module "babylonjs/Misc/dds" {
  47846. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47847. import { Engine } from "babylonjs/Engines/engine";
  47848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47849. import { Nullable } from "babylonjs/types";
  47850. import { Scene } from "babylonjs/scene";
  47851. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47852. /**
  47853. * Direct draw surface info
  47854. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47855. */
  47856. export interface DDSInfo {
  47857. /**
  47858. * Width of the texture
  47859. */
  47860. width: number;
  47861. /**
  47862. * Width of the texture
  47863. */
  47864. height: number;
  47865. /**
  47866. * Number of Mipmaps for the texture
  47867. * @see https://en.wikipedia.org/wiki/Mipmap
  47868. */
  47869. mipmapCount: number;
  47870. /**
  47871. * If the textures format is a known fourCC format
  47872. * @see https://www.fourcc.org/
  47873. */
  47874. isFourCC: boolean;
  47875. /**
  47876. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47877. */
  47878. isRGB: boolean;
  47879. /**
  47880. * If the texture is a lumincance format
  47881. */
  47882. isLuminance: boolean;
  47883. /**
  47884. * If this is a cube texture
  47885. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47886. */
  47887. isCube: boolean;
  47888. /**
  47889. * If the texture is a compressed format eg. FOURCC_DXT1
  47890. */
  47891. isCompressed: boolean;
  47892. /**
  47893. * The dxgiFormat of the texture
  47894. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47895. */
  47896. dxgiFormat: number;
  47897. /**
  47898. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47899. */
  47900. textureType: number;
  47901. /**
  47902. * Sphericle polynomial created for the dds texture
  47903. */
  47904. sphericalPolynomial?: SphericalPolynomial;
  47905. }
  47906. /**
  47907. * Class used to provide DDS decompression tools
  47908. */
  47909. export class DDSTools {
  47910. /**
  47911. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47912. */
  47913. static StoreLODInAlphaChannel: boolean;
  47914. /**
  47915. * Gets DDS information from an array buffer
  47916. * @param arrayBuffer defines the array buffer to read data from
  47917. * @returns the DDS information
  47918. */
  47919. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47920. private static _FloatView;
  47921. private static _Int32View;
  47922. private static _ToHalfFloat;
  47923. private static _FromHalfFloat;
  47924. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47925. private static _GetHalfFloatRGBAArrayBuffer;
  47926. private static _GetFloatRGBAArrayBuffer;
  47927. private static _GetFloatAsUIntRGBAArrayBuffer;
  47928. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47929. private static _GetRGBAArrayBuffer;
  47930. private static _ExtractLongWordOrder;
  47931. private static _GetRGBArrayBuffer;
  47932. private static _GetLuminanceArrayBuffer;
  47933. /**
  47934. * Uploads DDS Levels to a Babylon Texture
  47935. * @hidden
  47936. */
  47937. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47938. }
  47939. module "babylonjs/Engines/engine" {
  47940. interface Engine {
  47941. /**
  47942. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47943. * @param rootUrl defines the url where the file to load is located
  47944. * @param scene defines the current scene
  47945. * @param lodScale defines scale to apply to the mip map selection
  47946. * @param lodOffset defines offset to apply to the mip map selection
  47947. * @param onLoad defines an optional callback raised when the texture is loaded
  47948. * @param onError defines an optional callback raised if there is an issue to load the texture
  47949. * @param format defines the format of the data
  47950. * @param forcedExtension defines the extension to use to pick the right loader
  47951. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47952. * @returns the cube texture as an InternalTexture
  47953. */
  47954. 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;
  47955. }
  47956. }
  47957. }
  47958. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47959. import { Nullable } from "babylonjs/types";
  47960. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47961. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47962. /**
  47963. * Implementation of the DDS Texture Loader.
  47964. * @hidden
  47965. */
  47966. export class _DDSTextureLoader implements IInternalTextureLoader {
  47967. /**
  47968. * Defines wether the loader supports cascade loading the different faces.
  47969. */
  47970. readonly supportCascades: boolean;
  47971. /**
  47972. * This returns if the loader support the current file information.
  47973. * @param extension defines the file extension of the file being loaded
  47974. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47975. * @param fallback defines the fallback internal texture if any
  47976. * @param isBase64 defines whether the texture is encoded as a base64
  47977. * @param isBuffer defines whether the texture data are stored as a buffer
  47978. * @returns true if the loader can load the specified file
  47979. */
  47980. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47981. /**
  47982. * Transform the url before loading if required.
  47983. * @param rootUrl the url of the texture
  47984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47985. * @returns the transformed texture
  47986. */
  47987. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47988. /**
  47989. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47990. * @param rootUrl the url of the texture
  47991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47992. * @returns the fallback texture
  47993. */
  47994. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47995. /**
  47996. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47997. * @param data contains the texture data
  47998. * @param texture defines the BabylonJS internal texture
  47999. * @param createPolynomials will be true if polynomials have been requested
  48000. * @param onLoad defines the callback to trigger once the texture is ready
  48001. * @param onError defines the callback to trigger in case of error
  48002. */
  48003. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48004. /**
  48005. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48006. * @param data contains the texture data
  48007. * @param texture defines the BabylonJS internal texture
  48008. * @param callback defines the method to call once ready to upload
  48009. */
  48010. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48011. }
  48012. }
  48013. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48014. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48015. /** @hidden */
  48016. export var rgbdEncodePixelShader: {
  48017. name: string;
  48018. shader: string;
  48019. };
  48020. }
  48021. declare module "babylonjs/Misc/environmentTextureTools" {
  48022. import { Nullable } from "babylonjs/types";
  48023. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48025. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48026. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48027. import "babylonjs/Shaders/rgbdEncode.fragment";
  48028. import "babylonjs/Shaders/rgbdDecode.fragment";
  48029. /**
  48030. * Raw texture data and descriptor sufficient for WebGL texture upload
  48031. */
  48032. export interface EnvironmentTextureInfo {
  48033. /**
  48034. * Version of the environment map
  48035. */
  48036. version: number;
  48037. /**
  48038. * Width of image
  48039. */
  48040. width: number;
  48041. /**
  48042. * Irradiance information stored in the file.
  48043. */
  48044. irradiance: any;
  48045. /**
  48046. * Specular information stored in the file.
  48047. */
  48048. specular: any;
  48049. }
  48050. /**
  48051. * Sets of helpers addressing the serialization and deserialization of environment texture
  48052. * stored in a BabylonJS env file.
  48053. * Those files are usually stored as .env files.
  48054. */
  48055. export class EnvironmentTextureTools {
  48056. /**
  48057. * Magic number identifying the env file.
  48058. */
  48059. private static _MagicBytes;
  48060. /**
  48061. * Gets the environment info from an env file.
  48062. * @param data The array buffer containing the .env bytes.
  48063. * @returns the environment file info (the json header) if successfully parsed.
  48064. */
  48065. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48066. /**
  48067. * Creates an environment texture from a loaded cube texture.
  48068. * @param texture defines the cube texture to convert in env file
  48069. * @return a promise containing the environment data if succesfull.
  48070. */
  48071. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48072. /**
  48073. * Creates a JSON representation of the spherical data.
  48074. * @param texture defines the texture containing the polynomials
  48075. * @return the JSON representation of the spherical info
  48076. */
  48077. private static _CreateEnvTextureIrradiance;
  48078. /**
  48079. * Uploads the texture info contained in the env file to the GPU.
  48080. * @param texture defines the internal texture to upload to
  48081. * @param arrayBuffer defines the buffer cotaining the data to load
  48082. * @param info defines the texture info retrieved through the GetEnvInfo method
  48083. * @returns a promise
  48084. */
  48085. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48086. /**
  48087. * Uploads the levels of image data to the GPU.
  48088. * @param texture defines the internal texture to upload to
  48089. * @param imageData defines the array buffer views of image data [mipmap][face]
  48090. * @returns a promise
  48091. */
  48092. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48093. /**
  48094. * Uploads spherical polynomials information to the texture.
  48095. * @param texture defines the texture we are trying to upload the information to
  48096. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48097. */
  48098. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48099. /** @hidden */
  48100. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48101. }
  48102. }
  48103. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48104. import { Nullable } from "babylonjs/types";
  48105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48106. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48107. /**
  48108. * Implementation of the ENV Texture Loader.
  48109. * @hidden
  48110. */
  48111. export class _ENVTextureLoader implements IInternalTextureLoader {
  48112. /**
  48113. * Defines wether the loader supports cascade loading the different faces.
  48114. */
  48115. readonly supportCascades: boolean;
  48116. /**
  48117. * This returns if the loader support the current file information.
  48118. * @param extension defines the file extension of the file being loaded
  48119. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48120. * @param fallback defines the fallback internal texture if any
  48121. * @param isBase64 defines whether the texture is encoded as a base64
  48122. * @param isBuffer defines whether the texture data are stored as a buffer
  48123. * @returns true if the loader can load the specified file
  48124. */
  48125. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48126. /**
  48127. * Transform the url before loading if required.
  48128. * @param rootUrl the url of the texture
  48129. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48130. * @returns the transformed texture
  48131. */
  48132. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48133. /**
  48134. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48135. * @param rootUrl the url of the texture
  48136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48137. * @returns the fallback texture
  48138. */
  48139. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48140. /**
  48141. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48142. * @param data contains the texture data
  48143. * @param texture defines the BabylonJS internal texture
  48144. * @param createPolynomials will be true if polynomials have been requested
  48145. * @param onLoad defines the callback to trigger once the texture is ready
  48146. * @param onError defines the callback to trigger in case of error
  48147. */
  48148. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48149. /**
  48150. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48151. * @param data contains the texture data
  48152. * @param texture defines the BabylonJS internal texture
  48153. * @param callback defines the method to call once ready to upload
  48154. */
  48155. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48156. }
  48157. }
  48158. declare module "babylonjs/Misc/khronosTextureContainer" {
  48159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48160. /**
  48161. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48162. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48163. */
  48164. export class KhronosTextureContainer {
  48165. /** contents of the KTX container file */
  48166. arrayBuffer: any;
  48167. private static HEADER_LEN;
  48168. private static COMPRESSED_2D;
  48169. private static COMPRESSED_3D;
  48170. private static TEX_2D;
  48171. private static TEX_3D;
  48172. /**
  48173. * Gets the openGL type
  48174. */
  48175. glType: number;
  48176. /**
  48177. * Gets the openGL type size
  48178. */
  48179. glTypeSize: number;
  48180. /**
  48181. * Gets the openGL format
  48182. */
  48183. glFormat: number;
  48184. /**
  48185. * Gets the openGL internal format
  48186. */
  48187. glInternalFormat: number;
  48188. /**
  48189. * Gets the base internal format
  48190. */
  48191. glBaseInternalFormat: number;
  48192. /**
  48193. * Gets image width in pixel
  48194. */
  48195. pixelWidth: number;
  48196. /**
  48197. * Gets image height in pixel
  48198. */
  48199. pixelHeight: number;
  48200. /**
  48201. * Gets image depth in pixels
  48202. */
  48203. pixelDepth: number;
  48204. /**
  48205. * Gets the number of array elements
  48206. */
  48207. numberOfArrayElements: number;
  48208. /**
  48209. * Gets the number of faces
  48210. */
  48211. numberOfFaces: number;
  48212. /**
  48213. * Gets the number of mipmap levels
  48214. */
  48215. numberOfMipmapLevels: number;
  48216. /**
  48217. * Gets the bytes of key value data
  48218. */
  48219. bytesOfKeyValueData: number;
  48220. /**
  48221. * Gets the load type
  48222. */
  48223. loadType: number;
  48224. /**
  48225. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48226. */
  48227. isInvalid: boolean;
  48228. /**
  48229. * Creates a new KhronosTextureContainer
  48230. * @param arrayBuffer contents of the KTX container file
  48231. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48232. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48233. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48234. */
  48235. constructor(
  48236. /** contents of the KTX container file */
  48237. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48238. /**
  48239. * Uploads KTX content to a Babylon Texture.
  48240. * It is assumed that the texture has already been created & is currently bound
  48241. * @hidden
  48242. */
  48243. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48244. private _upload2DCompressedLevels;
  48245. }
  48246. }
  48247. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48248. import { Nullable } from "babylonjs/types";
  48249. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48250. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48251. /**
  48252. * Implementation of the KTX Texture Loader.
  48253. * @hidden
  48254. */
  48255. export class _KTXTextureLoader implements IInternalTextureLoader {
  48256. /**
  48257. * Defines wether the loader supports cascade loading the different faces.
  48258. */
  48259. readonly supportCascades: boolean;
  48260. /**
  48261. * This returns if the loader support the current file information.
  48262. * @param extension defines the file extension of the file being loaded
  48263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48264. * @param fallback defines the fallback internal texture if any
  48265. * @param isBase64 defines whether the texture is encoded as a base64
  48266. * @param isBuffer defines whether the texture data are stored as a buffer
  48267. * @returns true if the loader can load the specified file
  48268. */
  48269. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48270. /**
  48271. * Transform the url before loading if required.
  48272. * @param rootUrl the url of the texture
  48273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48274. * @returns the transformed texture
  48275. */
  48276. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48277. /**
  48278. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48279. * @param rootUrl the url of the texture
  48280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48281. * @returns the fallback texture
  48282. */
  48283. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48284. /**
  48285. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48286. * @param data contains the texture data
  48287. * @param texture defines the BabylonJS internal texture
  48288. * @param createPolynomials will be true if polynomials have been requested
  48289. * @param onLoad defines the callback to trigger once the texture is ready
  48290. * @param onError defines the callback to trigger in case of error
  48291. */
  48292. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48293. /**
  48294. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48295. * @param data contains the texture data
  48296. * @param texture defines the BabylonJS internal texture
  48297. * @param callback defines the method to call once ready to upload
  48298. */
  48299. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48300. }
  48301. }
  48302. declare module "babylonjs/Helpers/sceneHelpers" {
  48303. import { Nullable } from "babylonjs/types";
  48304. import { Mesh } from "babylonjs/Meshes/mesh";
  48305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48306. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48307. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48308. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48309. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48310. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48311. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48312. import "babylonjs/Meshes/Builders/boxBuilder";
  48313. /** @hidden */
  48314. export var _forceSceneHelpersToBundle: boolean;
  48315. module "babylonjs/scene" {
  48316. interface Scene {
  48317. /**
  48318. * Creates a default light for the scene.
  48319. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48320. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48321. */
  48322. createDefaultLight(replace?: boolean): void;
  48323. /**
  48324. * Creates a default camera for the scene.
  48325. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48326. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48327. * @param replace has default false, when true replaces the active camera in the scene
  48328. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48329. */
  48330. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48331. /**
  48332. * Creates a default camera and a default light.
  48333. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48334. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48335. * @param replace has the default false, when true replaces the active camera/light in the scene
  48336. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48337. */
  48338. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48339. /**
  48340. * Creates a new sky box
  48341. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48342. * @param environmentTexture defines the texture to use as environment texture
  48343. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48344. * @param scale defines the overall scale of the skybox
  48345. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48346. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48347. * @returns a new mesh holding the sky box
  48348. */
  48349. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48350. /**
  48351. * Creates a new environment
  48352. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48353. * @param options defines the options you can use to configure the environment
  48354. * @returns the new EnvironmentHelper
  48355. */
  48356. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48357. /**
  48358. * Creates a new VREXperienceHelper
  48359. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48360. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48361. * @returns a new VREXperienceHelper
  48362. */
  48363. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48364. /**
  48365. * Creates a new XREXperienceHelper
  48366. * @see http://doc.babylonjs.com/how_to/webxr
  48367. * @returns a promise for a new XREXperienceHelper
  48368. */
  48369. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48370. }
  48371. }
  48372. }
  48373. declare module "babylonjs/Helpers/videoDome" {
  48374. import { Scene } from "babylonjs/scene";
  48375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48378. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48379. import "babylonjs/Meshes/Builders/sphereBuilder";
  48380. /**
  48381. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48382. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48383. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48384. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48385. */
  48386. export class VideoDome extends TransformNode {
  48387. /**
  48388. * Define the video source as a Monoscopic panoramic 360 video.
  48389. */
  48390. static readonly MODE_MONOSCOPIC: number;
  48391. /**
  48392. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48393. */
  48394. static readonly MODE_TOPBOTTOM: number;
  48395. /**
  48396. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48397. */
  48398. static readonly MODE_SIDEBYSIDE: number;
  48399. private _useDirectMapping;
  48400. /**
  48401. * The video texture being displayed on the sphere
  48402. */
  48403. protected _videoTexture: VideoTexture;
  48404. /**
  48405. * Gets the video texture being displayed on the sphere
  48406. */
  48407. readonly videoTexture: VideoTexture;
  48408. /**
  48409. * The skybox material
  48410. */
  48411. protected _material: BackgroundMaterial;
  48412. /**
  48413. * The surface used for the skybox
  48414. */
  48415. protected _mesh: Mesh;
  48416. /**
  48417. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48418. * Also see the options.resolution property.
  48419. */
  48420. fovMultiplier: number;
  48421. private _videoMode;
  48422. /**
  48423. * Gets or set the current video mode for the video. It can be:
  48424. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48425. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48426. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48427. */
  48428. videoMode: number;
  48429. /**
  48430. * Oberserver used in Stereoscopic VR Mode.
  48431. */
  48432. private _onBeforeCameraRenderObserver;
  48433. /**
  48434. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48435. * @param name Element's name, child elements will append suffixes for their own names.
  48436. * @param urlsOrVideo defines the url(s) or the video element to use
  48437. * @param options An object containing optional or exposed sub element properties
  48438. */
  48439. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48440. resolution?: number;
  48441. clickToPlay?: boolean;
  48442. autoPlay?: boolean;
  48443. loop?: boolean;
  48444. size?: number;
  48445. poster?: string;
  48446. faceForward?: boolean;
  48447. useDirectMapping?: boolean;
  48448. }, scene: Scene);
  48449. private _changeVideoMode;
  48450. /**
  48451. * Releases resources associated with this node.
  48452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48454. */
  48455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48456. }
  48457. }
  48458. declare module "babylonjs/Helpers/index" {
  48459. export * from "babylonjs/Helpers/environmentHelper";
  48460. export * from "babylonjs/Helpers/photoDome";
  48461. export * from "babylonjs/Helpers/sceneHelpers";
  48462. export * from "babylonjs/Helpers/videoDome";
  48463. }
  48464. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48465. import { PerfCounter } from "babylonjs/Misc/tools";
  48466. import { IDisposable } from "babylonjs/scene";
  48467. import { Engine } from "babylonjs/Engines/engine";
  48468. /**
  48469. * This class can be used to get instrumentation data from a Babylon engine
  48470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48471. */
  48472. export class EngineInstrumentation implements IDisposable {
  48473. /**
  48474. * Define the instrumented engine.
  48475. */
  48476. engine: Engine;
  48477. private _captureGPUFrameTime;
  48478. private _gpuFrameTimeToken;
  48479. private _gpuFrameTime;
  48480. private _captureShaderCompilationTime;
  48481. private _shaderCompilationTime;
  48482. private _onBeginFrameObserver;
  48483. private _onEndFrameObserver;
  48484. private _onBeforeShaderCompilationObserver;
  48485. private _onAfterShaderCompilationObserver;
  48486. /**
  48487. * Gets the perf counter used for GPU frame time
  48488. */
  48489. readonly gpuFrameTimeCounter: PerfCounter;
  48490. /**
  48491. * Gets the GPU frame time capture status
  48492. */
  48493. /**
  48494. * Enable or disable the GPU frame time capture
  48495. */
  48496. captureGPUFrameTime: boolean;
  48497. /**
  48498. * Gets the perf counter used for shader compilation time
  48499. */
  48500. readonly shaderCompilationTimeCounter: PerfCounter;
  48501. /**
  48502. * Gets the shader compilation time capture status
  48503. */
  48504. /**
  48505. * Enable or disable the shader compilation time capture
  48506. */
  48507. captureShaderCompilationTime: boolean;
  48508. /**
  48509. * Instantiates a new engine instrumentation.
  48510. * This class can be used to get instrumentation data from a Babylon engine
  48511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48512. * @param engine Defines the engine to instrument
  48513. */
  48514. constructor(
  48515. /**
  48516. * Define the instrumented engine.
  48517. */
  48518. engine: Engine);
  48519. /**
  48520. * Dispose and release associated resources.
  48521. */
  48522. dispose(): void;
  48523. }
  48524. }
  48525. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48526. import { PerfCounter } from "babylonjs/Misc/tools";
  48527. import { Scene, IDisposable } from "babylonjs/scene";
  48528. /**
  48529. * This class can be used to get instrumentation data from a Babylon engine
  48530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48531. */
  48532. export class SceneInstrumentation implements IDisposable {
  48533. /**
  48534. * Defines the scene to instrument
  48535. */
  48536. scene: Scene;
  48537. private _captureActiveMeshesEvaluationTime;
  48538. private _activeMeshesEvaluationTime;
  48539. private _captureRenderTargetsRenderTime;
  48540. private _renderTargetsRenderTime;
  48541. private _captureFrameTime;
  48542. private _frameTime;
  48543. private _captureRenderTime;
  48544. private _renderTime;
  48545. private _captureInterFrameTime;
  48546. private _interFrameTime;
  48547. private _captureParticlesRenderTime;
  48548. private _particlesRenderTime;
  48549. private _captureSpritesRenderTime;
  48550. private _spritesRenderTime;
  48551. private _capturePhysicsTime;
  48552. private _physicsTime;
  48553. private _captureAnimationsTime;
  48554. private _animationsTime;
  48555. private _captureCameraRenderTime;
  48556. private _cameraRenderTime;
  48557. private _onBeforeActiveMeshesEvaluationObserver;
  48558. private _onAfterActiveMeshesEvaluationObserver;
  48559. private _onBeforeRenderTargetsRenderObserver;
  48560. private _onAfterRenderTargetsRenderObserver;
  48561. private _onAfterRenderObserver;
  48562. private _onBeforeDrawPhaseObserver;
  48563. private _onAfterDrawPhaseObserver;
  48564. private _onBeforeAnimationsObserver;
  48565. private _onBeforeParticlesRenderingObserver;
  48566. private _onAfterParticlesRenderingObserver;
  48567. private _onBeforeSpritesRenderingObserver;
  48568. private _onAfterSpritesRenderingObserver;
  48569. private _onBeforePhysicsObserver;
  48570. private _onAfterPhysicsObserver;
  48571. private _onAfterAnimationsObserver;
  48572. private _onBeforeCameraRenderObserver;
  48573. private _onAfterCameraRenderObserver;
  48574. /**
  48575. * Gets the perf counter used for active meshes evaluation time
  48576. */
  48577. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48578. /**
  48579. * Gets the active meshes evaluation time capture status
  48580. */
  48581. /**
  48582. * Enable or disable the active meshes evaluation time capture
  48583. */
  48584. captureActiveMeshesEvaluationTime: boolean;
  48585. /**
  48586. * Gets the perf counter used for render targets render time
  48587. */
  48588. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48589. /**
  48590. * Gets the render targets render time capture status
  48591. */
  48592. /**
  48593. * Enable or disable the render targets render time capture
  48594. */
  48595. captureRenderTargetsRenderTime: boolean;
  48596. /**
  48597. * Gets the perf counter used for particles render time
  48598. */
  48599. readonly particlesRenderTimeCounter: PerfCounter;
  48600. /**
  48601. * Gets the particles render time capture status
  48602. */
  48603. /**
  48604. * Enable or disable the particles render time capture
  48605. */
  48606. captureParticlesRenderTime: boolean;
  48607. /**
  48608. * Gets the perf counter used for sprites render time
  48609. */
  48610. readonly spritesRenderTimeCounter: PerfCounter;
  48611. /**
  48612. * Gets the sprites render time capture status
  48613. */
  48614. /**
  48615. * Enable or disable the sprites render time capture
  48616. */
  48617. captureSpritesRenderTime: boolean;
  48618. /**
  48619. * Gets the perf counter used for physics time
  48620. */
  48621. readonly physicsTimeCounter: PerfCounter;
  48622. /**
  48623. * Gets the physics time capture status
  48624. */
  48625. /**
  48626. * Enable or disable the physics time capture
  48627. */
  48628. capturePhysicsTime: boolean;
  48629. /**
  48630. * Gets the perf counter used for animations time
  48631. */
  48632. readonly animationsTimeCounter: PerfCounter;
  48633. /**
  48634. * Gets the animations time capture status
  48635. */
  48636. /**
  48637. * Enable or disable the animations time capture
  48638. */
  48639. captureAnimationsTime: boolean;
  48640. /**
  48641. * Gets the perf counter used for frame time capture
  48642. */
  48643. readonly frameTimeCounter: PerfCounter;
  48644. /**
  48645. * Gets the frame time capture status
  48646. */
  48647. /**
  48648. * Enable or disable the frame time capture
  48649. */
  48650. captureFrameTime: boolean;
  48651. /**
  48652. * Gets the perf counter used for inter-frames time capture
  48653. */
  48654. readonly interFrameTimeCounter: PerfCounter;
  48655. /**
  48656. * Gets the inter-frames time capture status
  48657. */
  48658. /**
  48659. * Enable or disable the inter-frames time capture
  48660. */
  48661. captureInterFrameTime: boolean;
  48662. /**
  48663. * Gets the perf counter used for render time capture
  48664. */
  48665. readonly renderTimeCounter: PerfCounter;
  48666. /**
  48667. * Gets the render time capture status
  48668. */
  48669. /**
  48670. * Enable or disable the render time capture
  48671. */
  48672. captureRenderTime: boolean;
  48673. /**
  48674. * Gets the perf counter used for camera render time capture
  48675. */
  48676. readonly cameraRenderTimeCounter: PerfCounter;
  48677. /**
  48678. * Gets the camera render time capture status
  48679. */
  48680. /**
  48681. * Enable or disable the camera render time capture
  48682. */
  48683. captureCameraRenderTime: boolean;
  48684. /**
  48685. * Gets the perf counter used for draw calls
  48686. */
  48687. readonly drawCallsCounter: PerfCounter;
  48688. /**
  48689. * Instantiates a new scene instrumentation.
  48690. * This class can be used to get instrumentation data from a Babylon engine
  48691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48692. * @param scene Defines the scene to instrument
  48693. */
  48694. constructor(
  48695. /**
  48696. * Defines the scene to instrument
  48697. */
  48698. scene: Scene);
  48699. /**
  48700. * Dispose and release associated resources.
  48701. */
  48702. dispose(): void;
  48703. }
  48704. }
  48705. declare module "babylonjs/Instrumentation/index" {
  48706. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48707. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48708. export * from "babylonjs/Instrumentation/timeToken";
  48709. }
  48710. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48711. /** @hidden */
  48712. export var glowMapGenerationPixelShader: {
  48713. name: string;
  48714. shader: string;
  48715. };
  48716. }
  48717. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48718. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48719. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48720. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48721. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48722. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48723. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48724. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48725. /** @hidden */
  48726. export var glowMapGenerationVertexShader: {
  48727. name: string;
  48728. shader: string;
  48729. };
  48730. }
  48731. declare module "babylonjs/Layers/effectLayer" {
  48732. import { Observable } from "babylonjs/Misc/observable";
  48733. import { Nullable } from "babylonjs/types";
  48734. import { Camera } from "babylonjs/Cameras/camera";
  48735. import { Scene } from "babylonjs/scene";
  48736. import { Color4, ISize } from "babylonjs/Maths/math";
  48737. import { Engine } from "babylonjs/Engines/engine";
  48738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48740. import { Mesh } from "babylonjs/Meshes/mesh";
  48741. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48744. import { Effect } from "babylonjs/Materials/effect";
  48745. import { Material } from "babylonjs/Materials/material";
  48746. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48747. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48748. /**
  48749. * Effect layer options. This helps customizing the behaviour
  48750. * of the effect layer.
  48751. */
  48752. export interface IEffectLayerOptions {
  48753. /**
  48754. * Multiplication factor apply to the canvas size to compute the render target size
  48755. * used to generated the objects (the smaller the faster).
  48756. */
  48757. mainTextureRatio: number;
  48758. /**
  48759. * Enforces a fixed size texture to ensure effect stability across devices.
  48760. */
  48761. mainTextureFixedSize?: number;
  48762. /**
  48763. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48764. */
  48765. alphaBlendingMode: number;
  48766. /**
  48767. * The camera attached to the layer.
  48768. */
  48769. camera: Nullable<Camera>;
  48770. /**
  48771. * The rendering group to draw the layer in.
  48772. */
  48773. renderingGroupId: number;
  48774. }
  48775. /**
  48776. * The effect layer Helps adding post process effect blended with the main pass.
  48777. *
  48778. * This can be for instance use to generate glow or higlight effects on the scene.
  48779. *
  48780. * The effect layer class can not be used directly and is intented to inherited from to be
  48781. * customized per effects.
  48782. */
  48783. export abstract class EffectLayer {
  48784. private _vertexBuffers;
  48785. private _indexBuffer;
  48786. private _cachedDefines;
  48787. private _effectLayerMapGenerationEffect;
  48788. private _effectLayerOptions;
  48789. private _mergeEffect;
  48790. protected _scene: Scene;
  48791. protected _engine: Engine;
  48792. protected _maxSize: number;
  48793. protected _mainTextureDesiredSize: ISize;
  48794. protected _mainTexture: RenderTargetTexture;
  48795. protected _shouldRender: boolean;
  48796. protected _postProcesses: PostProcess[];
  48797. protected _textures: BaseTexture[];
  48798. protected _emissiveTextureAndColor: {
  48799. texture: Nullable<BaseTexture>;
  48800. color: Color4;
  48801. };
  48802. /**
  48803. * The name of the layer
  48804. */
  48805. name: string;
  48806. /**
  48807. * The clear color of the texture used to generate the glow map.
  48808. */
  48809. neutralColor: Color4;
  48810. /**
  48811. * Specifies wether the highlight layer is enabled or not.
  48812. */
  48813. isEnabled: boolean;
  48814. /**
  48815. * Gets the camera attached to the layer.
  48816. */
  48817. readonly camera: Nullable<Camera>;
  48818. /**
  48819. * Gets the rendering group id the layer should render in.
  48820. */
  48821. readonly renderingGroupId: number;
  48822. /**
  48823. * An event triggered when the effect layer has been disposed.
  48824. */
  48825. onDisposeObservable: Observable<EffectLayer>;
  48826. /**
  48827. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48828. */
  48829. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48830. /**
  48831. * An event triggered when the generated texture is being merged in the scene.
  48832. */
  48833. onBeforeComposeObservable: Observable<EffectLayer>;
  48834. /**
  48835. * An event triggered when the generated texture has been merged in the scene.
  48836. */
  48837. onAfterComposeObservable: Observable<EffectLayer>;
  48838. /**
  48839. * An event triggered when the efffect layer changes its size.
  48840. */
  48841. onSizeChangedObservable: Observable<EffectLayer>;
  48842. /** @hidden */
  48843. static _SceneComponentInitialization: (scene: Scene) => void;
  48844. /**
  48845. * Instantiates a new effect Layer and references it in the scene.
  48846. * @param name The name of the layer
  48847. * @param scene The scene to use the layer in
  48848. */
  48849. constructor(
  48850. /** The Friendly of the effect in the scene */
  48851. name: string, scene: Scene);
  48852. /**
  48853. * Get the effect name of the layer.
  48854. * @return The effect name
  48855. */
  48856. abstract getEffectName(): string;
  48857. /**
  48858. * Checks for the readiness of the element composing the layer.
  48859. * @param subMesh the mesh to check for
  48860. * @param useInstances specify wether or not to use instances to render the mesh
  48861. * @return true if ready otherwise, false
  48862. */
  48863. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48864. /**
  48865. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48866. * @returns true if the effect requires stencil during the main canvas render pass.
  48867. */
  48868. abstract needStencil(): boolean;
  48869. /**
  48870. * Create the merge effect. This is the shader use to blit the information back
  48871. * to the main canvas at the end of the scene rendering.
  48872. * @returns The effect containing the shader used to merge the effect on the main canvas
  48873. */
  48874. protected abstract _createMergeEffect(): Effect;
  48875. /**
  48876. * Creates the render target textures and post processes used in the effect layer.
  48877. */
  48878. protected abstract _createTextureAndPostProcesses(): void;
  48879. /**
  48880. * Implementation specific of rendering the generating effect on the main canvas.
  48881. * @param effect The effect used to render through
  48882. */
  48883. protected abstract _internalRender(effect: Effect): void;
  48884. /**
  48885. * Sets the required values for both the emissive texture and and the main color.
  48886. */
  48887. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48888. /**
  48889. * Free any resources and references associated to a mesh.
  48890. * Internal use
  48891. * @param mesh The mesh to free.
  48892. */
  48893. abstract _disposeMesh(mesh: Mesh): void;
  48894. /**
  48895. * Serializes this layer (Glow or Highlight for example)
  48896. * @returns a serialized layer object
  48897. */
  48898. abstract serialize?(): any;
  48899. /**
  48900. * Initializes the effect layer with the required options.
  48901. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48902. */
  48903. protected _init(options: Partial<IEffectLayerOptions>): void;
  48904. /**
  48905. * Generates the index buffer of the full screen quad blending to the main canvas.
  48906. */
  48907. private _generateIndexBuffer;
  48908. /**
  48909. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48910. */
  48911. private _generateVertexBuffer;
  48912. /**
  48913. * Sets the main texture desired size which is the closest power of two
  48914. * of the engine canvas size.
  48915. */
  48916. private _setMainTextureSize;
  48917. /**
  48918. * Creates the main texture for the effect layer.
  48919. */
  48920. protected _createMainTexture(): void;
  48921. /**
  48922. * Adds specific effects defines.
  48923. * @param defines The defines to add specifics to.
  48924. */
  48925. protected _addCustomEffectDefines(defines: string[]): void;
  48926. /**
  48927. * Checks for the readiness of the element composing the layer.
  48928. * @param subMesh the mesh to check for
  48929. * @param useInstances specify wether or not to use instances to render the mesh
  48930. * @param emissiveTexture the associated emissive texture used to generate the glow
  48931. * @return true if ready otherwise, false
  48932. */
  48933. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48934. /**
  48935. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48936. */
  48937. render(): void;
  48938. /**
  48939. * Determine if a given mesh will be used in the current effect.
  48940. * @param mesh mesh to test
  48941. * @returns true if the mesh will be used
  48942. */
  48943. hasMesh(mesh: AbstractMesh): boolean;
  48944. /**
  48945. * Returns true if the layer contains information to display, otherwise false.
  48946. * @returns true if the glow layer should be rendered
  48947. */
  48948. shouldRender(): boolean;
  48949. /**
  48950. * Returns true if the mesh should render, otherwise false.
  48951. * @param mesh The mesh to render
  48952. * @returns true if it should render otherwise false
  48953. */
  48954. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48955. /**
  48956. * Returns true if the mesh can be rendered, otherwise false.
  48957. * @param mesh The mesh to render
  48958. * @param material The material used on the mesh
  48959. * @returns true if it can be rendered otherwise false
  48960. */
  48961. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48962. /**
  48963. * Returns true if the mesh should render, otherwise false.
  48964. * @param mesh The mesh to render
  48965. * @returns true if it should render otherwise false
  48966. */
  48967. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48968. /**
  48969. * Renders the submesh passed in parameter to the generation map.
  48970. */
  48971. protected _renderSubMesh(subMesh: SubMesh): void;
  48972. /**
  48973. * Rebuild the required buffers.
  48974. * @hidden Internal use only.
  48975. */
  48976. _rebuild(): void;
  48977. /**
  48978. * Dispose only the render target textures and post process.
  48979. */
  48980. private _disposeTextureAndPostProcesses;
  48981. /**
  48982. * Dispose the highlight layer and free resources.
  48983. */
  48984. dispose(): void;
  48985. /**
  48986. * Gets the class name of the effect layer
  48987. * @returns the string with the class name of the effect layer
  48988. */
  48989. getClassName(): string;
  48990. /**
  48991. * Creates an effect layer from parsed effect layer data
  48992. * @param parsedEffectLayer defines effect layer data
  48993. * @param scene defines the current scene
  48994. * @param rootUrl defines the root URL containing the effect layer information
  48995. * @returns a parsed effect Layer
  48996. */
  48997. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48998. }
  48999. }
  49000. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49001. import { Scene } from "babylonjs/scene";
  49002. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49003. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49004. import { AbstractScene } from "babylonjs/abstractScene";
  49005. module "babylonjs/abstractScene" {
  49006. interface AbstractScene {
  49007. /**
  49008. * The list of effect layers (highlights/glow) added to the scene
  49009. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49010. * @see http://doc.babylonjs.com/how_to/glow_layer
  49011. */
  49012. effectLayers: Array<EffectLayer>;
  49013. /**
  49014. * Removes the given effect layer from this scene.
  49015. * @param toRemove defines the effect layer to remove
  49016. * @returns the index of the removed effect layer
  49017. */
  49018. removeEffectLayer(toRemove: EffectLayer): number;
  49019. /**
  49020. * Adds the given effect layer to this scene
  49021. * @param newEffectLayer defines the effect layer to add
  49022. */
  49023. addEffectLayer(newEffectLayer: EffectLayer): void;
  49024. }
  49025. }
  49026. /**
  49027. * Defines the layer scene component responsible to manage any effect layers
  49028. * in a given scene.
  49029. */
  49030. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49031. /**
  49032. * The component name helpfull to identify the component in the list of scene components.
  49033. */
  49034. readonly name: string;
  49035. /**
  49036. * The scene the component belongs to.
  49037. */
  49038. scene: Scene;
  49039. private _engine;
  49040. private _renderEffects;
  49041. private _needStencil;
  49042. private _previousStencilState;
  49043. /**
  49044. * Creates a new instance of the component for the given scene
  49045. * @param scene Defines the scene to register the component in
  49046. */
  49047. constructor(scene: Scene);
  49048. /**
  49049. * Registers the component in a given scene
  49050. */
  49051. register(): void;
  49052. /**
  49053. * Rebuilds the elements related to this component in case of
  49054. * context lost for instance.
  49055. */
  49056. rebuild(): void;
  49057. /**
  49058. * Serializes the component data to the specified json object
  49059. * @param serializationObject The object to serialize to
  49060. */
  49061. serialize(serializationObject: any): void;
  49062. /**
  49063. * Adds all the element from the container to the scene
  49064. * @param container the container holding the elements
  49065. */
  49066. addFromContainer(container: AbstractScene): void;
  49067. /**
  49068. * Removes all the elements in the container from the scene
  49069. * @param container contains the elements to remove
  49070. * @param dispose if the removed element should be disposed (default: false)
  49071. */
  49072. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49073. /**
  49074. * Disposes the component and the associated ressources.
  49075. */
  49076. dispose(): void;
  49077. private _isReadyForMesh;
  49078. private _renderMainTexture;
  49079. private _setStencil;
  49080. private _setStencilBack;
  49081. private _draw;
  49082. private _drawCamera;
  49083. private _drawRenderingGroup;
  49084. }
  49085. }
  49086. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49087. /** @hidden */
  49088. export var glowMapMergePixelShader: {
  49089. name: string;
  49090. shader: string;
  49091. };
  49092. }
  49093. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49094. /** @hidden */
  49095. export var glowMapMergeVertexShader: {
  49096. name: string;
  49097. shader: string;
  49098. };
  49099. }
  49100. declare module "babylonjs/Layers/glowLayer" {
  49101. import { Nullable } from "babylonjs/types";
  49102. import { Camera } from "babylonjs/Cameras/camera";
  49103. import { Scene } from "babylonjs/scene";
  49104. import { Color4 } from "babylonjs/Maths/math";
  49105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49107. import { Mesh } from "babylonjs/Meshes/mesh";
  49108. import { Texture } from "babylonjs/Materials/Textures/texture";
  49109. import { Effect } from "babylonjs/Materials/effect";
  49110. import { Material } from "babylonjs/Materials/material";
  49111. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49112. import "babylonjs/Shaders/glowMapMerge.fragment";
  49113. import "babylonjs/Shaders/glowMapMerge.vertex";
  49114. import "babylonjs/Layers/effectLayerSceneComponent";
  49115. module "babylonjs/abstractScene" {
  49116. interface AbstractScene {
  49117. /**
  49118. * Return a the first highlight layer of the scene with a given name.
  49119. * @param name The name of the highlight layer to look for.
  49120. * @return The highlight layer if found otherwise null.
  49121. */
  49122. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49123. }
  49124. }
  49125. /**
  49126. * Glow layer options. This helps customizing the behaviour
  49127. * of the glow layer.
  49128. */
  49129. export interface IGlowLayerOptions {
  49130. /**
  49131. * Multiplication factor apply to the canvas size to compute the render target size
  49132. * used to generated the glowing objects (the smaller the faster).
  49133. */
  49134. mainTextureRatio: number;
  49135. /**
  49136. * Enforces a fixed size texture to ensure resize independant blur.
  49137. */
  49138. mainTextureFixedSize?: number;
  49139. /**
  49140. * How big is the kernel of the blur texture.
  49141. */
  49142. blurKernelSize: number;
  49143. /**
  49144. * The camera attached to the layer.
  49145. */
  49146. camera: Nullable<Camera>;
  49147. /**
  49148. * Enable MSAA by chosing the number of samples.
  49149. */
  49150. mainTextureSamples?: number;
  49151. /**
  49152. * The rendering group to draw the layer in.
  49153. */
  49154. renderingGroupId: number;
  49155. }
  49156. /**
  49157. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49158. *
  49159. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49160. * glowy meshes to your scene.
  49161. *
  49162. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49163. */
  49164. export class GlowLayer extends EffectLayer {
  49165. /**
  49166. * Effect Name of the layer.
  49167. */
  49168. static readonly EffectName: string;
  49169. /**
  49170. * The default blur kernel size used for the glow.
  49171. */
  49172. static DefaultBlurKernelSize: number;
  49173. /**
  49174. * The default texture size ratio used for the glow.
  49175. */
  49176. static DefaultTextureRatio: number;
  49177. /**
  49178. * Sets the kernel size of the blur.
  49179. */
  49180. /**
  49181. * Gets the kernel size of the blur.
  49182. */
  49183. blurKernelSize: number;
  49184. /**
  49185. * Sets the glow intensity.
  49186. */
  49187. /**
  49188. * Gets the glow intensity.
  49189. */
  49190. intensity: number;
  49191. private _options;
  49192. private _intensity;
  49193. private _horizontalBlurPostprocess1;
  49194. private _verticalBlurPostprocess1;
  49195. private _horizontalBlurPostprocess2;
  49196. private _verticalBlurPostprocess2;
  49197. private _blurTexture1;
  49198. private _blurTexture2;
  49199. private _postProcesses1;
  49200. private _postProcesses2;
  49201. private _includedOnlyMeshes;
  49202. private _excludedMeshes;
  49203. /**
  49204. * Callback used to let the user override the color selection on a per mesh basis
  49205. */
  49206. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49207. /**
  49208. * Callback used to let the user override the texture selection on a per mesh basis
  49209. */
  49210. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49211. /**
  49212. * Instantiates a new glow Layer and references it to the scene.
  49213. * @param name The name of the layer
  49214. * @param scene The scene to use the layer in
  49215. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49216. */
  49217. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49218. /**
  49219. * Get the effect name of the layer.
  49220. * @return The effect name
  49221. */
  49222. getEffectName(): string;
  49223. /**
  49224. * Create the merge effect. This is the shader use to blit the information back
  49225. * to the main canvas at the end of the scene rendering.
  49226. */
  49227. protected _createMergeEffect(): Effect;
  49228. /**
  49229. * Creates the render target textures and post processes used in the glow layer.
  49230. */
  49231. protected _createTextureAndPostProcesses(): void;
  49232. /**
  49233. * Checks for the readiness of the element composing the layer.
  49234. * @param subMesh the mesh to check for
  49235. * @param useInstances specify wether or not to use instances to render the mesh
  49236. * @param emissiveTexture the associated emissive texture used to generate the glow
  49237. * @return true if ready otherwise, false
  49238. */
  49239. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49240. /**
  49241. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49242. */
  49243. needStencil(): boolean;
  49244. /**
  49245. * Returns true if the mesh can be rendered, otherwise false.
  49246. * @param mesh The mesh to render
  49247. * @param material The material used on the mesh
  49248. * @returns true if it can be rendered otherwise false
  49249. */
  49250. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49251. /**
  49252. * Implementation specific of rendering the generating effect on the main canvas.
  49253. * @param effect The effect used to render through
  49254. */
  49255. protected _internalRender(effect: Effect): void;
  49256. /**
  49257. * Sets the required values for both the emissive texture and and the main color.
  49258. */
  49259. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49260. /**
  49261. * Returns true if the mesh should render, otherwise false.
  49262. * @param mesh The mesh to render
  49263. * @returns true if it should render otherwise false
  49264. */
  49265. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49266. /**
  49267. * Adds specific effects defines.
  49268. * @param defines The defines to add specifics to.
  49269. */
  49270. protected _addCustomEffectDefines(defines: string[]): void;
  49271. /**
  49272. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49273. * @param mesh The mesh to exclude from the glow layer
  49274. */
  49275. addExcludedMesh(mesh: Mesh): void;
  49276. /**
  49277. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49278. * @param mesh The mesh to remove
  49279. */
  49280. removeExcludedMesh(mesh: Mesh): void;
  49281. /**
  49282. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49283. * @param mesh The mesh to include in the glow layer
  49284. */
  49285. addIncludedOnlyMesh(mesh: Mesh): void;
  49286. /**
  49287. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49288. * @param mesh The mesh to remove
  49289. */
  49290. removeIncludedOnlyMesh(mesh: Mesh): void;
  49291. /**
  49292. * Determine if a given mesh will be used in the glow layer
  49293. * @param mesh The mesh to test
  49294. * @returns true if the mesh will be highlighted by the current glow layer
  49295. */
  49296. hasMesh(mesh: AbstractMesh): boolean;
  49297. /**
  49298. * Free any resources and references associated to a mesh.
  49299. * Internal use
  49300. * @param mesh The mesh to free.
  49301. * @hidden
  49302. */
  49303. _disposeMesh(mesh: Mesh): void;
  49304. /**
  49305. * Gets the class name of the effect layer
  49306. * @returns the string with the class name of the effect layer
  49307. */
  49308. getClassName(): string;
  49309. /**
  49310. * Serializes this glow layer
  49311. * @returns a serialized glow layer object
  49312. */
  49313. serialize(): any;
  49314. /**
  49315. * Creates a Glow Layer from parsed glow layer data
  49316. * @param parsedGlowLayer defines glow layer data
  49317. * @param scene defines the current scene
  49318. * @param rootUrl defines the root URL containing the glow layer information
  49319. * @returns a parsed Glow Layer
  49320. */
  49321. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49322. }
  49323. }
  49324. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49325. /** @hidden */
  49326. export var glowBlurPostProcessPixelShader: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module "babylonjs/Layers/highlightLayer" {
  49332. import { Observable } from "babylonjs/Misc/observable";
  49333. import { Nullable } from "babylonjs/types";
  49334. import { Camera } from "babylonjs/Cameras/camera";
  49335. import { Scene } from "babylonjs/scene";
  49336. import { Color3, Color4 } from "babylonjs/Maths/math";
  49337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49339. import { Mesh } from "babylonjs/Meshes/mesh";
  49340. import { Effect } from "babylonjs/Materials/effect";
  49341. import { Material } from "babylonjs/Materials/material";
  49342. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49343. import "babylonjs/Shaders/glowMapMerge.fragment";
  49344. import "babylonjs/Shaders/glowMapMerge.vertex";
  49345. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49346. module "babylonjs/abstractScene" {
  49347. interface AbstractScene {
  49348. /**
  49349. * Return a the first highlight layer of the scene with a given name.
  49350. * @param name The name of the highlight layer to look for.
  49351. * @return The highlight layer if found otherwise null.
  49352. */
  49353. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49354. }
  49355. }
  49356. /**
  49357. * Highlight layer options. This helps customizing the behaviour
  49358. * of the highlight layer.
  49359. */
  49360. export interface IHighlightLayerOptions {
  49361. /**
  49362. * Multiplication factor apply to the canvas size to compute the render target size
  49363. * used to generated the glowing objects (the smaller the faster).
  49364. */
  49365. mainTextureRatio: number;
  49366. /**
  49367. * Enforces a fixed size texture to ensure resize independant blur.
  49368. */
  49369. mainTextureFixedSize?: number;
  49370. /**
  49371. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49372. * of the picture to blur (the smaller the faster).
  49373. */
  49374. blurTextureSizeRatio: number;
  49375. /**
  49376. * How big in texel of the blur texture is the vertical blur.
  49377. */
  49378. blurVerticalSize: number;
  49379. /**
  49380. * How big in texel of the blur texture is the horizontal blur.
  49381. */
  49382. blurHorizontalSize: number;
  49383. /**
  49384. * Alpha blending mode used to apply the blur. Default is combine.
  49385. */
  49386. alphaBlendingMode: number;
  49387. /**
  49388. * The camera attached to the layer.
  49389. */
  49390. camera: Nullable<Camera>;
  49391. /**
  49392. * Should we display highlight as a solid stroke?
  49393. */
  49394. isStroke?: boolean;
  49395. /**
  49396. * The rendering group to draw the layer in.
  49397. */
  49398. renderingGroupId: number;
  49399. }
  49400. /**
  49401. * The highlight layer Helps adding a glow effect around a mesh.
  49402. *
  49403. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49404. * glowy meshes to your scene.
  49405. *
  49406. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49407. */
  49408. export class HighlightLayer extends EffectLayer {
  49409. name: string;
  49410. /**
  49411. * Effect Name of the highlight layer.
  49412. */
  49413. static readonly EffectName: string;
  49414. /**
  49415. * The neutral color used during the preparation of the glow effect.
  49416. * This is black by default as the blend operation is a blend operation.
  49417. */
  49418. static NeutralColor: Color4;
  49419. /**
  49420. * Stencil value used for glowing meshes.
  49421. */
  49422. static GlowingMeshStencilReference: number;
  49423. /**
  49424. * Stencil value used for the other meshes in the scene.
  49425. */
  49426. static NormalMeshStencilReference: number;
  49427. /**
  49428. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49429. */
  49430. innerGlow: boolean;
  49431. /**
  49432. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49433. */
  49434. outerGlow: boolean;
  49435. /**
  49436. * Specifies the horizontal size of the blur.
  49437. */
  49438. /**
  49439. * Gets the horizontal size of the blur.
  49440. */
  49441. blurHorizontalSize: number;
  49442. /**
  49443. * Specifies the vertical size of the blur.
  49444. */
  49445. /**
  49446. * Gets the vertical size of the blur.
  49447. */
  49448. blurVerticalSize: number;
  49449. /**
  49450. * An event triggered when the highlight layer is being blurred.
  49451. */
  49452. onBeforeBlurObservable: Observable<HighlightLayer>;
  49453. /**
  49454. * An event triggered when the highlight layer has been blurred.
  49455. */
  49456. onAfterBlurObservable: Observable<HighlightLayer>;
  49457. private _instanceGlowingMeshStencilReference;
  49458. private _options;
  49459. private _downSamplePostprocess;
  49460. private _horizontalBlurPostprocess;
  49461. private _verticalBlurPostprocess;
  49462. private _blurTexture;
  49463. private _meshes;
  49464. private _excludedMeshes;
  49465. /**
  49466. * Instantiates a new highlight Layer and references it to the scene..
  49467. * @param name The name of the layer
  49468. * @param scene The scene to use the layer in
  49469. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49470. */
  49471. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49472. /**
  49473. * Get the effect name of the layer.
  49474. * @return The effect name
  49475. */
  49476. getEffectName(): string;
  49477. /**
  49478. * Create the merge effect. This is the shader use to blit the information back
  49479. * to the main canvas at the end of the scene rendering.
  49480. */
  49481. protected _createMergeEffect(): Effect;
  49482. /**
  49483. * Creates the render target textures and post processes used in the highlight layer.
  49484. */
  49485. protected _createTextureAndPostProcesses(): void;
  49486. /**
  49487. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49488. */
  49489. needStencil(): boolean;
  49490. /**
  49491. * Checks for the readiness of the element composing the layer.
  49492. * @param subMesh the mesh to check for
  49493. * @param useInstances specify wether or not to use instances to render the mesh
  49494. * @param emissiveTexture the associated emissive texture used to generate the glow
  49495. * @return true if ready otherwise, false
  49496. */
  49497. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49498. /**
  49499. * Implementation specific of rendering the generating effect on the main canvas.
  49500. * @param effect The effect used to render through
  49501. */
  49502. protected _internalRender(effect: Effect): void;
  49503. /**
  49504. * Returns true if the layer contains information to display, otherwise false.
  49505. */
  49506. shouldRender(): boolean;
  49507. /**
  49508. * Returns true if the mesh should render, otherwise false.
  49509. * @param mesh The mesh to render
  49510. * @returns true if it should render otherwise false
  49511. */
  49512. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49513. /**
  49514. * Sets the required values for both the emissive texture and and the main color.
  49515. */
  49516. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49517. /**
  49518. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49519. * @param mesh The mesh to exclude from the highlight layer
  49520. */
  49521. addExcludedMesh(mesh: Mesh): void;
  49522. /**
  49523. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49524. * @param mesh The mesh to highlight
  49525. */
  49526. removeExcludedMesh(mesh: Mesh): void;
  49527. /**
  49528. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49529. * @param mesh mesh to test
  49530. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49531. */
  49532. hasMesh(mesh: AbstractMesh): boolean;
  49533. /**
  49534. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49535. * @param mesh The mesh to highlight
  49536. * @param color The color of the highlight
  49537. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49538. */
  49539. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49540. /**
  49541. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49542. * @param mesh The mesh to highlight
  49543. */
  49544. removeMesh(mesh: Mesh): void;
  49545. /**
  49546. * Force the stencil to the normal expected value for none glowing parts
  49547. */
  49548. private _defaultStencilReference;
  49549. /**
  49550. * Free any resources and references associated to a mesh.
  49551. * Internal use
  49552. * @param mesh The mesh to free.
  49553. * @hidden
  49554. */
  49555. _disposeMesh(mesh: Mesh): void;
  49556. /**
  49557. * Dispose the highlight layer and free resources.
  49558. */
  49559. dispose(): void;
  49560. /**
  49561. * Gets the class name of the effect layer
  49562. * @returns the string with the class name of the effect layer
  49563. */
  49564. getClassName(): string;
  49565. /**
  49566. * Serializes this Highlight layer
  49567. * @returns a serialized Highlight layer object
  49568. */
  49569. serialize(): any;
  49570. /**
  49571. * Creates a Highlight layer from parsed Highlight layer data
  49572. * @param parsedHightlightLayer defines the Highlight layer data
  49573. * @param scene defines the current scene
  49574. * @param rootUrl defines the root URL containing the Highlight layer information
  49575. * @returns a parsed Highlight layer
  49576. */
  49577. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49578. }
  49579. }
  49580. declare module "babylonjs/Layers/index" {
  49581. export * from "babylonjs/Layers/effectLayer";
  49582. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49583. export * from "babylonjs/Layers/glowLayer";
  49584. export * from "babylonjs/Layers/highlightLayer";
  49585. export * from "babylonjs/Layers/layer";
  49586. export * from "babylonjs/Layers/layerSceneComponent";
  49587. }
  49588. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49589. /** @hidden */
  49590. export var lensFlarePixelShader: {
  49591. name: string;
  49592. shader: string;
  49593. };
  49594. }
  49595. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49596. /** @hidden */
  49597. export var lensFlareVertexShader: {
  49598. name: string;
  49599. shader: string;
  49600. };
  49601. }
  49602. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49603. import { Scene } from "babylonjs/scene";
  49604. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49606. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49607. import "babylonjs/Shaders/lensFlare.fragment";
  49608. import "babylonjs/Shaders/lensFlare.vertex";
  49609. /**
  49610. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49611. * It is usually composed of several `lensFlare`.
  49612. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49613. */
  49614. export class LensFlareSystem {
  49615. /**
  49616. * Define the name of the lens flare system
  49617. */
  49618. name: string;
  49619. /**
  49620. * List of lens flares used in this system.
  49621. */
  49622. lensFlares: LensFlare[];
  49623. /**
  49624. * Define a limit from the border the lens flare can be visible.
  49625. */
  49626. borderLimit: number;
  49627. /**
  49628. * Define a viewport border we do not want to see the lens flare in.
  49629. */
  49630. viewportBorder: number;
  49631. /**
  49632. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49633. */
  49634. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49635. /**
  49636. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49637. */
  49638. layerMask: number;
  49639. /**
  49640. * Define the id of the lens flare system in the scene.
  49641. * (equal to name by default)
  49642. */
  49643. id: string;
  49644. private _scene;
  49645. private _emitter;
  49646. private _vertexBuffers;
  49647. private _indexBuffer;
  49648. private _effect;
  49649. private _positionX;
  49650. private _positionY;
  49651. private _isEnabled;
  49652. /** @hidden */
  49653. static _SceneComponentInitialization: (scene: Scene) => void;
  49654. /**
  49655. * Instantiates a lens flare system.
  49656. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49657. * It is usually composed of several `lensFlare`.
  49658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49659. * @param name Define the name of the lens flare system in the scene
  49660. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49661. * @param scene Define the scene the lens flare system belongs to
  49662. */
  49663. constructor(
  49664. /**
  49665. * Define the name of the lens flare system
  49666. */
  49667. name: string, emitter: any, scene: Scene);
  49668. /**
  49669. * Define if the lens flare system is enabled.
  49670. */
  49671. isEnabled: boolean;
  49672. /**
  49673. * Get the scene the effects belongs to.
  49674. * @returns the scene holding the lens flare system
  49675. */
  49676. getScene(): Scene;
  49677. /**
  49678. * Get the emitter of the lens flare system.
  49679. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49680. * @returns the emitter of the lens flare system
  49681. */
  49682. getEmitter(): any;
  49683. /**
  49684. * Set the emitter of the lens flare system.
  49685. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49686. * @param newEmitter Define the new emitter of the system
  49687. */
  49688. setEmitter(newEmitter: any): void;
  49689. /**
  49690. * Get the lens flare system emitter position.
  49691. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49692. * @returns the position
  49693. */
  49694. getEmitterPosition(): Vector3;
  49695. /**
  49696. * @hidden
  49697. */
  49698. computeEffectivePosition(globalViewport: Viewport): boolean;
  49699. /** @hidden */
  49700. _isVisible(): boolean;
  49701. /**
  49702. * @hidden
  49703. */
  49704. render(): boolean;
  49705. /**
  49706. * Dispose and release the lens flare with its associated resources.
  49707. */
  49708. dispose(): void;
  49709. /**
  49710. * Parse a lens flare system from a JSON repressentation
  49711. * @param parsedLensFlareSystem Define the JSON to parse
  49712. * @param scene Define the scene the parsed system should be instantiated in
  49713. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49714. * @returns the parsed system
  49715. */
  49716. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49717. /**
  49718. * Serialize the current Lens Flare System into a JSON representation.
  49719. * @returns the serialized JSON
  49720. */
  49721. serialize(): any;
  49722. }
  49723. }
  49724. declare module "babylonjs/LensFlares/lensFlare" {
  49725. import { Nullable } from "babylonjs/types";
  49726. import { Color3 } from "babylonjs/Maths/math";
  49727. import { Texture } from "babylonjs/Materials/Textures/texture";
  49728. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49729. /**
  49730. * This represents one of the lens effect in a `lensFlareSystem`.
  49731. * It controls one of the indiviual texture used in the effect.
  49732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49733. */
  49734. export class LensFlare {
  49735. /**
  49736. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49737. */
  49738. size: number;
  49739. /**
  49740. * 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.
  49741. */
  49742. position: number;
  49743. /**
  49744. * Define the lens color.
  49745. */
  49746. color: Color3;
  49747. /**
  49748. * Define the lens texture.
  49749. */
  49750. texture: Nullable<Texture>;
  49751. /**
  49752. * Define the alpha mode to render this particular lens.
  49753. */
  49754. alphaMode: number;
  49755. private _system;
  49756. /**
  49757. * Creates a new Lens Flare.
  49758. * This represents one of the lens effect in a `lensFlareSystem`.
  49759. * It controls one of the indiviual texture used in the effect.
  49760. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49761. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49762. * @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.
  49763. * @param color Define the lens color
  49764. * @param imgUrl Define the lens texture url
  49765. * @param system Define the `lensFlareSystem` this flare is part of
  49766. * @returns The newly created Lens Flare
  49767. */
  49768. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49769. /**
  49770. * Instantiates a new Lens Flare.
  49771. * This represents one of the lens effect in a `lensFlareSystem`.
  49772. * It controls one of the indiviual texture used in the effect.
  49773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49774. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49775. * @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.
  49776. * @param color Define the lens color
  49777. * @param imgUrl Define the lens texture url
  49778. * @param system Define the `lensFlareSystem` this flare is part of
  49779. */
  49780. constructor(
  49781. /**
  49782. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49783. */
  49784. size: number,
  49785. /**
  49786. * 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.
  49787. */
  49788. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49789. /**
  49790. * Dispose and release the lens flare with its associated resources.
  49791. */
  49792. dispose(): void;
  49793. }
  49794. }
  49795. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49796. import { Nullable } from "babylonjs/types";
  49797. import { Scene } from "babylonjs/scene";
  49798. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49799. import { AbstractScene } from "babylonjs/abstractScene";
  49800. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49801. module "babylonjs/abstractScene" {
  49802. interface AbstractScene {
  49803. /**
  49804. * The list of lens flare system added to the scene
  49805. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49806. */
  49807. lensFlareSystems: Array<LensFlareSystem>;
  49808. /**
  49809. * Removes the given lens flare system from this scene.
  49810. * @param toRemove The lens flare system to remove
  49811. * @returns The index of the removed lens flare system
  49812. */
  49813. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49814. /**
  49815. * Adds the given lens flare system to this scene
  49816. * @param newLensFlareSystem The lens flare system to add
  49817. */
  49818. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49819. /**
  49820. * Gets a lens flare system using its name
  49821. * @param name defines the name to look for
  49822. * @returns the lens flare system or null if not found
  49823. */
  49824. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49825. /**
  49826. * Gets a lens flare system using its id
  49827. * @param id defines the id to look for
  49828. * @returns the lens flare system or null if not found
  49829. */
  49830. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49831. }
  49832. }
  49833. /**
  49834. * Defines the lens flare scene component responsible to manage any lens flares
  49835. * in a given scene.
  49836. */
  49837. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49838. /**
  49839. * The component name helpfull to identify the component in the list of scene components.
  49840. */
  49841. readonly name: string;
  49842. /**
  49843. * The scene the component belongs to.
  49844. */
  49845. scene: Scene;
  49846. /**
  49847. * Creates a new instance of the component for the given scene
  49848. * @param scene Defines the scene to register the component in
  49849. */
  49850. constructor(scene: Scene);
  49851. /**
  49852. * Registers the component in a given scene
  49853. */
  49854. register(): void;
  49855. /**
  49856. * Rebuilds the elements related to this component in case of
  49857. * context lost for instance.
  49858. */
  49859. rebuild(): void;
  49860. /**
  49861. * Adds all the element from the container to the scene
  49862. * @param container the container holding the elements
  49863. */
  49864. addFromContainer(container: AbstractScene): void;
  49865. /**
  49866. * Removes all the elements in the container from the scene
  49867. * @param container contains the elements to remove
  49868. * @param dispose if the removed element should be disposed (default: false)
  49869. */
  49870. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49871. /**
  49872. * Serializes the component data to the specified json object
  49873. * @param serializationObject The object to serialize to
  49874. */
  49875. serialize(serializationObject: any): void;
  49876. /**
  49877. * Disposes the component and the associated ressources.
  49878. */
  49879. dispose(): void;
  49880. private _draw;
  49881. }
  49882. }
  49883. declare module "babylonjs/LensFlares/index" {
  49884. export * from "babylonjs/LensFlares/lensFlare";
  49885. export * from "babylonjs/LensFlares/lensFlareSystem";
  49886. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49887. }
  49888. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49889. import { Scene } from "babylonjs/scene";
  49890. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49891. import { AbstractScene } from "babylonjs/abstractScene";
  49892. /**
  49893. * Defines the shadow generator component responsible to manage any shadow generators
  49894. * in a given scene.
  49895. */
  49896. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49897. /**
  49898. * The component name helpfull to identify the component in the list of scene components.
  49899. */
  49900. readonly name: string;
  49901. /**
  49902. * The scene the component belongs to.
  49903. */
  49904. scene: Scene;
  49905. /**
  49906. * Creates a new instance of the component for the given scene
  49907. * @param scene Defines the scene to register the component in
  49908. */
  49909. constructor(scene: Scene);
  49910. /**
  49911. * Registers the component in a given scene
  49912. */
  49913. register(): void;
  49914. /**
  49915. * Rebuilds the elements related to this component in case of
  49916. * context lost for instance.
  49917. */
  49918. rebuild(): void;
  49919. /**
  49920. * Serializes the component data to the specified json object
  49921. * @param serializationObject The object to serialize to
  49922. */
  49923. serialize(serializationObject: any): void;
  49924. /**
  49925. * Adds all the element from the container to the scene
  49926. * @param container the container holding the elements
  49927. */
  49928. addFromContainer(container: AbstractScene): void;
  49929. /**
  49930. * Removes all the elements in the container from the scene
  49931. * @param container contains the elements to remove
  49932. * @param dispose if the removed element should be disposed (default: false)
  49933. */
  49934. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49935. /**
  49936. * Rebuilds the elements related to this component in case of
  49937. * context lost for instance.
  49938. */
  49939. dispose(): void;
  49940. private _gatherRenderTargets;
  49941. }
  49942. }
  49943. declare module "babylonjs/Lights/Shadows/index" {
  49944. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49945. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49946. }
  49947. declare module "babylonjs/Lights/pointLight" {
  49948. import { Scene } from "babylonjs/scene";
  49949. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49951. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49952. import { Effect } from "babylonjs/Materials/effect";
  49953. /**
  49954. * A point light is a light defined by an unique point in world space.
  49955. * The light is emitted in every direction from this point.
  49956. * A good example of a point light is a standard light bulb.
  49957. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49958. */
  49959. export class PointLight extends ShadowLight {
  49960. private _shadowAngle;
  49961. /**
  49962. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49963. * This specifies what angle the shadow will use to be created.
  49964. *
  49965. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49966. */
  49967. /**
  49968. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49969. * This specifies what angle the shadow will use to be created.
  49970. *
  49971. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49972. */
  49973. shadowAngle: number;
  49974. /**
  49975. * Gets the direction if it has been set.
  49976. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49977. */
  49978. /**
  49979. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49980. */
  49981. direction: Vector3;
  49982. /**
  49983. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49984. * A PointLight emits the light in every direction.
  49985. * It can cast shadows.
  49986. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49987. * ```javascript
  49988. * var pointLight = new PointLight("pl", camera.position, scene);
  49989. * ```
  49990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49991. * @param name The light friendly name
  49992. * @param position The position of the point light in the scene
  49993. * @param scene The scene the lights belongs to
  49994. */
  49995. constructor(name: string, position: Vector3, scene: Scene);
  49996. /**
  49997. * Returns the string "PointLight"
  49998. * @returns the class name
  49999. */
  50000. getClassName(): string;
  50001. /**
  50002. * Returns the integer 0.
  50003. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50004. */
  50005. getTypeID(): number;
  50006. /**
  50007. * Specifies wether or not the shadowmap should be a cube texture.
  50008. * @returns true if the shadowmap needs to be a cube texture.
  50009. */
  50010. needCube(): boolean;
  50011. /**
  50012. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50015. */
  50016. getShadowDirection(faceIndex?: number): Vector3;
  50017. /**
  50018. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50019. * - fov = PI / 2
  50020. * - aspect ratio : 1.0
  50021. * - z-near and far equal to the active camera minZ and maxZ.
  50022. * Returns the PointLight.
  50023. */
  50024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50025. protected _buildUniformLayout(): void;
  50026. /**
  50027. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50028. * @param effect The effect to update
  50029. * @param lightIndex The index of the light in the effect to update
  50030. * @returns The point light
  50031. */
  50032. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50033. /**
  50034. * Prepares the list of defines specific to the light type.
  50035. * @param defines the list of defines
  50036. * @param lightIndex defines the index of the light for the effect
  50037. */
  50038. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50039. }
  50040. }
  50041. declare module "babylonjs/Lights/index" {
  50042. export * from "babylonjs/Lights/light";
  50043. export * from "babylonjs/Lights/shadowLight";
  50044. export * from "babylonjs/Lights/Shadows/index";
  50045. export * from "babylonjs/Lights/directionalLight";
  50046. export * from "babylonjs/Lights/hemisphericLight";
  50047. export * from "babylonjs/Lights/pointLight";
  50048. export * from "babylonjs/Lights/spotLight";
  50049. }
  50050. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50051. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50052. /**
  50053. * Header information of HDR texture files.
  50054. */
  50055. export interface HDRInfo {
  50056. /**
  50057. * The height of the texture in pixels.
  50058. */
  50059. height: number;
  50060. /**
  50061. * The width of the texture in pixels.
  50062. */
  50063. width: number;
  50064. /**
  50065. * The index of the beginning of the data in the binary file.
  50066. */
  50067. dataPosition: number;
  50068. }
  50069. /**
  50070. * This groups tools to convert HDR texture to native colors array.
  50071. */
  50072. export class HDRTools {
  50073. private static Ldexp;
  50074. private static Rgbe2float;
  50075. private static readStringLine;
  50076. /**
  50077. * Reads header information from an RGBE texture stored in a native array.
  50078. * More information on this format are available here:
  50079. * https://en.wikipedia.org/wiki/RGBE_image_format
  50080. *
  50081. * @param uint8array The binary file stored in native array.
  50082. * @return The header information.
  50083. */
  50084. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50085. /**
  50086. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50087. * This RGBE texture needs to store the information as a panorama.
  50088. *
  50089. * More information on this format are available here:
  50090. * https://en.wikipedia.org/wiki/RGBE_image_format
  50091. *
  50092. * @param buffer The binary file stored in an array buffer.
  50093. * @param size The expected size of the extracted cubemap.
  50094. * @return The Cube Map information.
  50095. */
  50096. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50097. /**
  50098. * Returns the pixels data extracted from an RGBE texture.
  50099. * This pixels will be stored left to right up to down in the R G B order in one array.
  50100. *
  50101. * More information on this format are available here:
  50102. * https://en.wikipedia.org/wiki/RGBE_image_format
  50103. *
  50104. * @param uint8array The binary file stored in an array buffer.
  50105. * @param hdrInfo The header information of the file.
  50106. * @return The pixels data in RGB right to left up to down order.
  50107. */
  50108. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50109. private static RGBE_ReadPixels_RLE;
  50110. }
  50111. }
  50112. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50113. import { Nullable } from "babylonjs/types";
  50114. import { Scene } from "babylonjs/scene";
  50115. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50117. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50118. /**
  50119. * This represents a texture coming from an HDR input.
  50120. *
  50121. * The only supported format is currently panorama picture stored in RGBE format.
  50122. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50123. */
  50124. export class HDRCubeTexture extends BaseTexture {
  50125. private static _facesMapping;
  50126. private _generateHarmonics;
  50127. private _noMipmap;
  50128. private _textureMatrix;
  50129. private _size;
  50130. private _onLoad;
  50131. private _onError;
  50132. /**
  50133. * The texture URL.
  50134. */
  50135. url: string;
  50136. /**
  50137. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50138. */
  50139. coordinatesMode: number;
  50140. protected _isBlocking: boolean;
  50141. /**
  50142. * Sets wether or not the texture is blocking during loading.
  50143. */
  50144. /**
  50145. * Gets wether or not the texture is blocking during loading.
  50146. */
  50147. isBlocking: boolean;
  50148. protected _rotationY: number;
  50149. /**
  50150. * Sets texture matrix rotation angle around Y axis in radians.
  50151. */
  50152. /**
  50153. * Gets texture matrix rotation angle around Y axis radians.
  50154. */
  50155. rotationY: number;
  50156. /**
  50157. * Gets or sets the center of the bounding box associated with the cube texture
  50158. * It must define where the camera used to render the texture was set
  50159. */
  50160. boundingBoxPosition: Vector3;
  50161. private _boundingBoxSize;
  50162. /**
  50163. * Gets or sets the size of the bounding box associated with the cube texture
  50164. * When defined, the cubemap will switch to local mode
  50165. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50166. * @example https://www.babylonjs-playground.com/#RNASML
  50167. */
  50168. boundingBoxSize: Vector3;
  50169. /**
  50170. * Instantiates an HDRTexture from the following parameters.
  50171. *
  50172. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50173. * @param scene The scene the texture will be used in
  50174. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50175. * @param noMipmap Forces to not generate the mipmap if true
  50176. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50177. * @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)
  50178. * @param reserved Reserved flag for internal use.
  50179. */
  50180. 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>);
  50181. /**
  50182. * Get the current class name of the texture useful for serialization or dynamic coding.
  50183. * @returns "HDRCubeTexture"
  50184. */
  50185. getClassName(): string;
  50186. /**
  50187. * Occurs when the file is raw .hdr file.
  50188. */
  50189. private loadTexture;
  50190. clone(): HDRCubeTexture;
  50191. delayLoad(): void;
  50192. /**
  50193. * Get the texture reflection matrix used to rotate/transform the reflection.
  50194. * @returns the reflection matrix
  50195. */
  50196. getReflectionTextureMatrix(): Matrix;
  50197. /**
  50198. * Set the texture reflection matrix used to rotate/transform the reflection.
  50199. * @param value Define the reflection matrix to set
  50200. */
  50201. setReflectionTextureMatrix(value: Matrix): void;
  50202. /**
  50203. * Parses a JSON representation of an HDR Texture in order to create the texture
  50204. * @param parsedTexture Define the JSON representation
  50205. * @param scene Define the scene the texture should be created in
  50206. * @param rootUrl Define the root url in case we need to load relative dependencies
  50207. * @returns the newly created texture after parsing
  50208. */
  50209. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50210. serialize(): any;
  50211. }
  50212. }
  50213. declare module "babylonjs/Physics/physicsEngine" {
  50214. import { Nullable } from "babylonjs/types";
  50215. import { Vector3 } from "babylonjs/Maths/math";
  50216. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50217. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50218. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50219. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50220. /**
  50221. * Class used to control physics engine
  50222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50223. */
  50224. export class PhysicsEngine implements IPhysicsEngine {
  50225. private _physicsPlugin;
  50226. /**
  50227. * Global value used to control the smallest number supported by the simulation
  50228. */
  50229. static Epsilon: number;
  50230. private _impostors;
  50231. private _joints;
  50232. /**
  50233. * Gets the gravity vector used by the simulation
  50234. */
  50235. gravity: Vector3;
  50236. /**
  50237. * Factory used to create the default physics plugin.
  50238. * @returns The default physics plugin
  50239. */
  50240. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50241. /**
  50242. * Creates a new Physics Engine
  50243. * @param gravity defines the gravity vector used by the simulation
  50244. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50245. */
  50246. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50247. /**
  50248. * Sets the gravity vector used by the simulation
  50249. * @param gravity defines the gravity vector to use
  50250. */
  50251. setGravity(gravity: Vector3): void;
  50252. /**
  50253. * Set the time step of the physics engine.
  50254. * Default is 1/60.
  50255. * To slow it down, enter 1/600 for example.
  50256. * To speed it up, 1/30
  50257. * @param newTimeStep defines the new timestep to apply to this world.
  50258. */
  50259. setTimeStep(newTimeStep?: number): void;
  50260. /**
  50261. * Get the time step of the physics engine.
  50262. * @returns the current time step
  50263. */
  50264. getTimeStep(): number;
  50265. /**
  50266. * Release all resources
  50267. */
  50268. dispose(): void;
  50269. /**
  50270. * Gets the name of the current physics plugin
  50271. * @returns the name of the plugin
  50272. */
  50273. getPhysicsPluginName(): string;
  50274. /**
  50275. * Adding a new impostor for the impostor tracking.
  50276. * This will be done by the impostor itself.
  50277. * @param impostor the impostor to add
  50278. */
  50279. addImpostor(impostor: PhysicsImpostor): void;
  50280. /**
  50281. * Remove an impostor from the engine.
  50282. * This impostor and its mesh will not longer be updated by the physics engine.
  50283. * @param impostor the impostor to remove
  50284. */
  50285. removeImpostor(impostor: PhysicsImpostor): void;
  50286. /**
  50287. * Add a joint to the physics engine
  50288. * @param mainImpostor defines the main impostor to which the joint is added.
  50289. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50290. * @param joint defines the joint that will connect both impostors.
  50291. */
  50292. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50293. /**
  50294. * Removes a joint from the simulation
  50295. * @param mainImpostor defines the impostor used with the joint
  50296. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50297. * @param joint defines the joint to remove
  50298. */
  50299. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50300. /**
  50301. * Called by the scene. No need to call it.
  50302. * @param delta defines the timespam between frames
  50303. */
  50304. _step(delta: number): void;
  50305. /**
  50306. * Gets the current plugin used to run the simulation
  50307. * @returns current plugin
  50308. */
  50309. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50310. /**
  50311. * Gets the list of physic impostors
  50312. * @returns an array of PhysicsImpostor
  50313. */
  50314. getImpostors(): Array<PhysicsImpostor>;
  50315. /**
  50316. * Gets the impostor for a physics enabled object
  50317. * @param object defines the object impersonated by the impostor
  50318. * @returns the PhysicsImpostor or null if not found
  50319. */
  50320. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50321. /**
  50322. * Gets the impostor for a physics body object
  50323. * @param body defines physics body used by the impostor
  50324. * @returns the PhysicsImpostor or null if not found
  50325. */
  50326. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50327. /**
  50328. * Does a raycast in the physics world
  50329. * @param from when should the ray start?
  50330. * @param to when should the ray end?
  50331. * @returns PhysicsRaycastResult
  50332. */
  50333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50334. }
  50335. }
  50336. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50337. import { Nullable } from "babylonjs/types";
  50338. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50340. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50341. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50342. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50343. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50344. /** @hidden */
  50345. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50346. private _useDeltaForWorldStep;
  50347. world: any;
  50348. name: string;
  50349. private _physicsMaterials;
  50350. private _fixedTimeStep;
  50351. private _cannonRaycastResult;
  50352. private _raycastResult;
  50353. private _removeAfterStep;
  50354. BJSCANNON: any;
  50355. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50356. setGravity(gravity: Vector3): void;
  50357. setTimeStep(timeStep: number): void;
  50358. getTimeStep(): number;
  50359. executeStep(delta: number): void;
  50360. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50361. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50362. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50363. private _processChildMeshes;
  50364. removePhysicsBody(impostor: PhysicsImpostor): void;
  50365. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50366. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50367. private _addMaterial;
  50368. private _checkWithEpsilon;
  50369. private _createShape;
  50370. private _createHeightmap;
  50371. private _minus90X;
  50372. private _plus90X;
  50373. private _tmpPosition;
  50374. private _tmpDeltaPosition;
  50375. private _tmpUnityRotation;
  50376. private _updatePhysicsBodyTransformation;
  50377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50379. isSupported(): boolean;
  50380. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50381. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50382. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50383. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50384. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50385. getBodyMass(impostor: PhysicsImpostor): number;
  50386. getBodyFriction(impostor: PhysicsImpostor): number;
  50387. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50388. getBodyRestitution(impostor: PhysicsImpostor): number;
  50389. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50390. sleepBody(impostor: PhysicsImpostor): void;
  50391. wakeUpBody(impostor: PhysicsImpostor): void;
  50392. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50393. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50394. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50395. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50396. getRadius(impostor: PhysicsImpostor): number;
  50397. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50398. dispose(): void;
  50399. private _extendNamespace;
  50400. /**
  50401. * Does a raycast in the physics world
  50402. * @param from when should the ray start?
  50403. * @param to when should the ray end?
  50404. * @returns PhysicsRaycastResult
  50405. */
  50406. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50407. }
  50408. }
  50409. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50410. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50411. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50412. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50414. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50415. import { Nullable } from "babylonjs/types";
  50416. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50417. /** @hidden */
  50418. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50419. world: any;
  50420. name: string;
  50421. BJSOIMO: any;
  50422. private _raycastResult;
  50423. constructor(iterations?: number, oimoInjection?: any);
  50424. setGravity(gravity: Vector3): void;
  50425. setTimeStep(timeStep: number): void;
  50426. getTimeStep(): number;
  50427. private _tmpImpostorsArray;
  50428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50429. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50432. private _tmpPositionVector;
  50433. removePhysicsBody(impostor: PhysicsImpostor): void;
  50434. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50435. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50436. isSupported(): boolean;
  50437. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50438. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50439. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50440. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50441. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50442. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50443. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50444. getBodyMass(impostor: PhysicsImpostor): number;
  50445. getBodyFriction(impostor: PhysicsImpostor): number;
  50446. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50447. getBodyRestitution(impostor: PhysicsImpostor): number;
  50448. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50449. sleepBody(impostor: PhysicsImpostor): void;
  50450. wakeUpBody(impostor: PhysicsImpostor): void;
  50451. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50452. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50454. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50455. getRadius(impostor: PhysicsImpostor): number;
  50456. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50457. dispose(): void;
  50458. /**
  50459. * Does a raycast in the physics world
  50460. * @param from when should the ray start?
  50461. * @param to when should the ray end?
  50462. * @returns PhysicsRaycastResult
  50463. */
  50464. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50465. }
  50466. }
  50467. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50468. import { Nullable } from "babylonjs/types";
  50469. import { Scene } from "babylonjs/scene";
  50470. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50471. import { Mesh } from "babylonjs/Meshes/mesh";
  50472. /**
  50473. * Class containing static functions to help procedurally build meshes
  50474. */
  50475. export class RibbonBuilder {
  50476. /**
  50477. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50478. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50479. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50480. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50481. * * 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
  50482. * * 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
  50483. * * 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
  50484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50487. * * 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
  50488. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50489. * * 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
  50490. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50492. * @param name defines the name of the mesh
  50493. * @param options defines the options used to create the mesh
  50494. * @param scene defines the hosting scene
  50495. * @returns the ribbon mesh
  50496. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50498. */
  50499. static CreateRibbon(name: string, options: {
  50500. pathArray: Vector3[][];
  50501. closeArray?: boolean;
  50502. closePath?: boolean;
  50503. offset?: number;
  50504. updatable?: boolean;
  50505. sideOrientation?: number;
  50506. frontUVs?: Vector4;
  50507. backUVs?: Vector4;
  50508. instance?: Mesh;
  50509. invertUV?: boolean;
  50510. uvs?: Vector2[];
  50511. colors?: Color4[];
  50512. }, scene?: Nullable<Scene>): Mesh;
  50513. }
  50514. }
  50515. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50516. import { Nullable } from "babylonjs/types";
  50517. import { Scene } from "babylonjs/scene";
  50518. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50519. import { Mesh } from "babylonjs/Meshes/mesh";
  50520. /**
  50521. * Class containing static functions to help procedurally build meshes
  50522. */
  50523. export class ShapeBuilder {
  50524. /**
  50525. * 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.
  50526. * * 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.
  50527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50528. * * 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.
  50529. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50530. * * 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
  50531. * * 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
  50532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50537. * @param name defines the name of the mesh
  50538. * @param options defines the options used to create the mesh
  50539. * @param scene defines the hosting scene
  50540. * @returns the extruded shape mesh
  50541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50543. */
  50544. static ExtrudeShape(name: string, options: {
  50545. shape: Vector3[];
  50546. path: Vector3[];
  50547. scale?: number;
  50548. rotation?: number;
  50549. cap?: number;
  50550. updatable?: boolean;
  50551. sideOrientation?: number;
  50552. frontUVs?: Vector4;
  50553. backUVs?: Vector4;
  50554. instance?: Mesh;
  50555. invertUV?: boolean;
  50556. }, scene?: Nullable<Scene>): Mesh;
  50557. /**
  50558. * Creates an custom extruded shape mesh.
  50559. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50560. * * 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.
  50561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50562. * * 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
  50563. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50564. * * 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
  50565. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50566. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50567. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50568. * * 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
  50569. * * 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
  50570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50575. * @param name defines the name of the mesh
  50576. * @param options defines the options used to create the mesh
  50577. * @param scene defines the hosting scene
  50578. * @returns the custom extruded shape mesh
  50579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50582. */
  50583. static ExtrudeShapeCustom(name: string, options: {
  50584. shape: Vector3[];
  50585. path: Vector3[];
  50586. scaleFunction?: any;
  50587. rotationFunction?: any;
  50588. ribbonCloseArray?: boolean;
  50589. ribbonClosePath?: boolean;
  50590. cap?: number;
  50591. updatable?: boolean;
  50592. sideOrientation?: number;
  50593. frontUVs?: Vector4;
  50594. backUVs?: Vector4;
  50595. instance?: Mesh;
  50596. invertUV?: boolean;
  50597. }, scene?: Nullable<Scene>): Mesh;
  50598. private static _ExtrudeShapeGeneric;
  50599. }
  50600. }
  50601. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50602. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50603. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50604. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50605. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50606. import { Nullable } from "babylonjs/types";
  50607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50608. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50609. /**
  50610. * AmmoJS Physics plugin
  50611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50612. * @see https://github.com/kripken/ammo.js/
  50613. */
  50614. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50615. private _useDeltaForWorldStep;
  50616. /**
  50617. * Reference to the Ammo library
  50618. */
  50619. bjsAMMO: any;
  50620. /**
  50621. * Created ammoJS world which physics bodies are added to
  50622. */
  50623. world: any;
  50624. /**
  50625. * Name of the plugin
  50626. */
  50627. name: string;
  50628. private _timeStep;
  50629. private _fixedTimeStep;
  50630. private _maxSteps;
  50631. private _tmpQuaternion;
  50632. private _tmpAmmoTransform;
  50633. private _tmpAmmoQuaternion;
  50634. private _tmpAmmoConcreteContactResultCallback;
  50635. private _collisionConfiguration;
  50636. private _dispatcher;
  50637. private _overlappingPairCache;
  50638. private _solver;
  50639. private _softBodySolver;
  50640. private _tmpAmmoVectorA;
  50641. private _tmpAmmoVectorB;
  50642. private _tmpAmmoVectorC;
  50643. private _tmpAmmoVectorD;
  50644. private _tmpContactCallbackResult;
  50645. private _tmpAmmoVectorRCA;
  50646. private _tmpAmmoVectorRCB;
  50647. private _raycastResult;
  50648. private static readonly DISABLE_COLLISION_FLAG;
  50649. private static readonly KINEMATIC_FLAG;
  50650. private static readonly DISABLE_DEACTIVATION_FLAG;
  50651. /**
  50652. * Initializes the ammoJS plugin
  50653. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50654. * @param ammoInjection can be used to inject your own ammo reference
  50655. */
  50656. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50657. /**
  50658. * Sets the gravity of the physics world (m/(s^2))
  50659. * @param gravity Gravity to set
  50660. */
  50661. setGravity(gravity: Vector3): void;
  50662. /**
  50663. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50664. * @param timeStep timestep to use in seconds
  50665. */
  50666. setTimeStep(timeStep: number): void;
  50667. /**
  50668. * 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)
  50669. * @param fixedTimeStep fixedTimeStep to use in seconds
  50670. */
  50671. setFixedTimeStep(fixedTimeStep: number): void;
  50672. /**
  50673. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50674. * @param maxSteps the maximum number of steps by the physics engine per frame
  50675. */
  50676. setMaxSteps(maxSteps: number): void;
  50677. /**
  50678. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50679. * @returns the current timestep in seconds
  50680. */
  50681. getTimeStep(): number;
  50682. private _isImpostorInContact;
  50683. private _isImpostorPairInContact;
  50684. private _stepSimulation;
  50685. /**
  50686. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50687. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50688. * After the step the babylon meshes are set to the position of the physics imposters
  50689. * @param delta amount of time to step forward
  50690. * @param impostors array of imposters to update before/after the step
  50691. */
  50692. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50693. /**
  50694. * Update babylon mesh to match physics world object
  50695. * @param impostor imposter to match
  50696. */
  50697. private _afterSoftStep;
  50698. /**
  50699. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50700. * @param impostor imposter to match
  50701. */
  50702. private _ropeStep;
  50703. /**
  50704. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50705. * @param impostor imposter to match
  50706. */
  50707. private _softbodyOrClothStep;
  50708. private _tmpVector;
  50709. private _tmpMatrix;
  50710. /**
  50711. * Applies an impulse on the imposter
  50712. * @param impostor imposter to apply impulse to
  50713. * @param force amount of force to be applied to the imposter
  50714. * @param contactPoint the location to apply the impulse on the imposter
  50715. */
  50716. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50717. /**
  50718. * Applies a force on the imposter
  50719. * @param impostor imposter to apply force
  50720. * @param force amount of force to be applied to the imposter
  50721. * @param contactPoint the location to apply the force on the imposter
  50722. */
  50723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50724. /**
  50725. * Creates a physics body using the plugin
  50726. * @param impostor the imposter to create the physics body on
  50727. */
  50728. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50729. /**
  50730. * Removes the physics body from the imposter and disposes of the body's memory
  50731. * @param impostor imposter to remove the physics body from
  50732. */
  50733. removePhysicsBody(impostor: PhysicsImpostor): void;
  50734. /**
  50735. * Generates a joint
  50736. * @param impostorJoint the imposter joint to create the joint with
  50737. */
  50738. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50739. /**
  50740. * Removes a joint
  50741. * @param impostorJoint the imposter joint to remove the joint from
  50742. */
  50743. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50744. private _addMeshVerts;
  50745. /**
  50746. * Initialise the soft body vertices to match its object's (mesh) vertices
  50747. * Softbody vertices (nodes) are in world space and to match this
  50748. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50749. * @param impostor to create the softbody for
  50750. */
  50751. private _softVertexData;
  50752. /**
  50753. * Create an impostor's soft body
  50754. * @param impostor to create the softbody for
  50755. */
  50756. private _createSoftbody;
  50757. /**
  50758. * Create cloth for an impostor
  50759. * @param impostor to create the softbody for
  50760. */
  50761. private _createCloth;
  50762. /**
  50763. * Create rope for an impostor
  50764. * @param impostor to create the softbody for
  50765. */
  50766. private _createRope;
  50767. private _addHullVerts;
  50768. private _createShape;
  50769. /**
  50770. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50771. * @param impostor imposter containing the physics body and babylon object
  50772. */
  50773. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50774. /**
  50775. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50776. * @param impostor imposter containing the physics body and babylon object
  50777. * @param newPosition new position
  50778. * @param newRotation new rotation
  50779. */
  50780. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50781. /**
  50782. * If this plugin is supported
  50783. * @returns true if its supported
  50784. */
  50785. isSupported(): boolean;
  50786. /**
  50787. * Sets the linear velocity of the physics body
  50788. * @param impostor imposter to set the velocity on
  50789. * @param velocity velocity to set
  50790. */
  50791. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50792. /**
  50793. * Sets the angular velocity of the physics body
  50794. * @param impostor imposter to set the velocity on
  50795. * @param velocity velocity to set
  50796. */
  50797. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50798. /**
  50799. * gets the linear velocity
  50800. * @param impostor imposter to get linear velocity from
  50801. * @returns linear velocity
  50802. */
  50803. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50804. /**
  50805. * gets the angular velocity
  50806. * @param impostor imposter to get angular velocity from
  50807. * @returns angular velocity
  50808. */
  50809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50810. /**
  50811. * Sets the mass of physics body
  50812. * @param impostor imposter to set the mass on
  50813. * @param mass mass to set
  50814. */
  50815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50816. /**
  50817. * Gets the mass of the physics body
  50818. * @param impostor imposter to get the mass from
  50819. * @returns mass
  50820. */
  50821. getBodyMass(impostor: PhysicsImpostor): number;
  50822. /**
  50823. * Gets friction of the impostor
  50824. * @param impostor impostor to get friction from
  50825. * @returns friction value
  50826. */
  50827. getBodyFriction(impostor: PhysicsImpostor): number;
  50828. /**
  50829. * Sets friction of the impostor
  50830. * @param impostor impostor to set friction on
  50831. * @param friction friction value
  50832. */
  50833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50834. /**
  50835. * Gets restitution of the impostor
  50836. * @param impostor impostor to get restitution from
  50837. * @returns restitution value
  50838. */
  50839. getBodyRestitution(impostor: PhysicsImpostor): number;
  50840. /**
  50841. * Sets resitution of the impostor
  50842. * @param impostor impostor to set resitution on
  50843. * @param restitution resitution value
  50844. */
  50845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50846. /**
  50847. * Gets pressure inside the impostor
  50848. * @param impostor impostor to get pressure from
  50849. * @returns pressure value
  50850. */
  50851. getBodyPressure(impostor: PhysicsImpostor): number;
  50852. /**
  50853. * Sets pressure inside a soft body impostor
  50854. * Cloth and rope must remain 0 pressure
  50855. * @param impostor impostor to set pressure on
  50856. * @param pressure pressure value
  50857. */
  50858. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50859. /**
  50860. * Gets stiffness of the impostor
  50861. * @param impostor impostor to get stiffness from
  50862. * @returns pressure value
  50863. */
  50864. getBodyStiffness(impostor: PhysicsImpostor): number;
  50865. /**
  50866. * Sets stiffness of the impostor
  50867. * @param impostor impostor to set stiffness on
  50868. * @param stiffness stiffness value from 0 to 1
  50869. */
  50870. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50871. /**
  50872. * Gets velocityIterations of the impostor
  50873. * @param impostor impostor to get velocity iterations from
  50874. * @returns velocityIterations value
  50875. */
  50876. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50877. /**
  50878. * Sets velocityIterations of the impostor
  50879. * @param impostor impostor to set velocity iterations on
  50880. * @param velocityIterations velocityIterations value
  50881. */
  50882. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50883. /**
  50884. * Gets positionIterations of the impostor
  50885. * @param impostor impostor to get position iterations from
  50886. * @returns positionIterations value
  50887. */
  50888. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50889. /**
  50890. * Sets positionIterations of the impostor
  50891. * @param impostor impostor to set position on
  50892. * @param positionIterations positionIterations value
  50893. */
  50894. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50895. /**
  50896. * Append an anchor to a cloth object
  50897. * @param impostor is the cloth impostor to add anchor to
  50898. * @param otherImpostor is the rigid impostor to anchor to
  50899. * @param width ratio across width from 0 to 1
  50900. * @param height ratio up height from 0 to 1
  50901. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50903. */
  50904. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50905. /**
  50906. * Append an hook to a rope object
  50907. * @param impostor is the rope impostor to add hook to
  50908. * @param otherImpostor is the rigid impostor to hook to
  50909. * @param length ratio along the rope from 0 to 1
  50910. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50911. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50912. */
  50913. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50914. /**
  50915. * Sleeps the physics body and stops it from being active
  50916. * @param impostor impostor to sleep
  50917. */
  50918. sleepBody(impostor: PhysicsImpostor): void;
  50919. /**
  50920. * Activates the physics body
  50921. * @param impostor impostor to activate
  50922. */
  50923. wakeUpBody(impostor: PhysicsImpostor): void;
  50924. /**
  50925. * Updates the distance parameters of the joint
  50926. * @param joint joint to update
  50927. * @param maxDistance maximum distance of the joint
  50928. * @param minDistance minimum distance of the joint
  50929. */
  50930. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50931. /**
  50932. * Sets a motor on the joint
  50933. * @param joint joint to set motor on
  50934. * @param speed speed of the motor
  50935. * @param maxForce maximum force of the motor
  50936. * @param motorIndex index of the motor
  50937. */
  50938. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50939. /**
  50940. * Sets the motors limit
  50941. * @param joint joint to set limit on
  50942. * @param upperLimit upper limit
  50943. * @param lowerLimit lower limit
  50944. */
  50945. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50946. /**
  50947. * Syncs the position and rotation of a mesh with the impostor
  50948. * @param mesh mesh to sync
  50949. * @param impostor impostor to update the mesh with
  50950. */
  50951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50952. /**
  50953. * Gets the radius of the impostor
  50954. * @param impostor impostor to get radius from
  50955. * @returns the radius
  50956. */
  50957. getRadius(impostor: PhysicsImpostor): number;
  50958. /**
  50959. * Gets the box size of the impostor
  50960. * @param impostor impostor to get box size from
  50961. * @param result the resulting box size
  50962. */
  50963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50964. /**
  50965. * Disposes of the impostor
  50966. */
  50967. dispose(): void;
  50968. /**
  50969. * Does a raycast in the physics world
  50970. * @param from when should the ray start?
  50971. * @param to when should the ray end?
  50972. * @returns PhysicsRaycastResult
  50973. */
  50974. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50975. }
  50976. }
  50977. declare module "babylonjs/Probes/reflectionProbe" {
  50978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50979. import { Vector3 } from "babylonjs/Maths/math";
  50980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50981. import { Nullable } from "babylonjs/types";
  50982. import { Scene } from "babylonjs/scene";
  50983. module "babylonjs/abstractScene" {
  50984. interface AbstractScene {
  50985. /**
  50986. * The list of reflection probes added to the scene
  50987. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50988. */
  50989. reflectionProbes: Array<ReflectionProbe>;
  50990. /**
  50991. * Removes the given reflection probe from this scene.
  50992. * @param toRemove The reflection probe to remove
  50993. * @returns The index of the removed reflection probe
  50994. */
  50995. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50996. /**
  50997. * Adds the given reflection probe to this scene.
  50998. * @param newReflectionProbe The reflection probe to add
  50999. */
  51000. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51001. }
  51002. }
  51003. /**
  51004. * Class used to generate realtime reflection / refraction cube textures
  51005. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51006. */
  51007. export class ReflectionProbe {
  51008. /** defines the name of the probe */
  51009. name: string;
  51010. private _scene;
  51011. private _renderTargetTexture;
  51012. private _projectionMatrix;
  51013. private _viewMatrix;
  51014. private _target;
  51015. private _add;
  51016. private _attachedMesh;
  51017. private _invertYAxis;
  51018. /** Gets or sets probe position (center of the cube map) */
  51019. position: Vector3;
  51020. /**
  51021. * Creates a new reflection probe
  51022. * @param name defines the name of the probe
  51023. * @param size defines the texture resolution (for each face)
  51024. * @param scene defines the hosting scene
  51025. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51026. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51027. */
  51028. constructor(
  51029. /** defines the name of the probe */
  51030. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51031. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51032. samples: number;
  51033. /** Gets or sets the refresh rate to use (on every frame by default) */
  51034. refreshRate: number;
  51035. /**
  51036. * Gets the hosting scene
  51037. * @returns a Scene
  51038. */
  51039. getScene(): Scene;
  51040. /** Gets the internal CubeTexture used to render to */
  51041. readonly cubeTexture: RenderTargetTexture;
  51042. /** Gets the list of meshes to render */
  51043. readonly renderList: Nullable<AbstractMesh[]>;
  51044. /**
  51045. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51046. * @param mesh defines the mesh to attach to
  51047. */
  51048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51049. /**
  51050. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51051. * @param renderingGroupId The rendering group id corresponding to its index
  51052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51053. */
  51054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51055. /**
  51056. * Clean all associated resources
  51057. */
  51058. dispose(): void;
  51059. /**
  51060. * Converts the reflection probe information to a readable string for debug purpose.
  51061. * @param fullDetails Supports for multiple levels of logging within scene loading
  51062. * @returns the human readable reflection probe info
  51063. */
  51064. toString(fullDetails?: boolean): string;
  51065. /**
  51066. * Get the class name of the relfection probe.
  51067. * @returns "ReflectionProbe"
  51068. */
  51069. getClassName(): string;
  51070. /**
  51071. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51072. * @returns The JSON representation of the texture
  51073. */
  51074. serialize(): any;
  51075. /**
  51076. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51077. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51078. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51080. * @returns The parsed reflection probe if successful
  51081. */
  51082. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51083. }
  51084. }
  51085. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51086. /** @hidden */
  51087. export var _BabylonLoaderRegistered: boolean;
  51088. }
  51089. declare module "babylonjs/Loading/Plugins/index" {
  51090. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51091. }
  51092. declare module "babylonjs/Loading/index" {
  51093. export * from "babylonjs/Loading/loadingScreen";
  51094. export * from "babylonjs/Loading/Plugins/index";
  51095. export * from "babylonjs/Loading/sceneLoader";
  51096. export * from "babylonjs/Loading/sceneLoaderFlags";
  51097. }
  51098. declare module "babylonjs/Materials/Background/index" {
  51099. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51100. }
  51101. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51102. import { Scene } from "babylonjs/scene";
  51103. import { Color3 } from "babylonjs/Maths/math";
  51104. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51106. /**
  51107. * The Physically based simple base material of BJS.
  51108. *
  51109. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51110. * It is used as the base class for both the specGloss and metalRough conventions.
  51111. */
  51112. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51113. /**
  51114. * Number of Simultaneous lights allowed on the material.
  51115. */
  51116. maxSimultaneousLights: number;
  51117. /**
  51118. * If sets to true, disables all the lights affecting the material.
  51119. */
  51120. disableLighting: boolean;
  51121. /**
  51122. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51123. */
  51124. environmentTexture: BaseTexture;
  51125. /**
  51126. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51127. */
  51128. invertNormalMapX: boolean;
  51129. /**
  51130. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51131. */
  51132. invertNormalMapY: boolean;
  51133. /**
  51134. * Normal map used in the model.
  51135. */
  51136. normalTexture: BaseTexture;
  51137. /**
  51138. * Emissivie color used to self-illuminate the model.
  51139. */
  51140. emissiveColor: Color3;
  51141. /**
  51142. * Emissivie texture used to self-illuminate the model.
  51143. */
  51144. emissiveTexture: BaseTexture;
  51145. /**
  51146. * Occlusion Channel Strenght.
  51147. */
  51148. occlusionStrength: number;
  51149. /**
  51150. * Occlusion Texture of the material (adding extra occlusion effects).
  51151. */
  51152. occlusionTexture: BaseTexture;
  51153. /**
  51154. * Defines the alpha limits in alpha test mode.
  51155. */
  51156. alphaCutOff: number;
  51157. /**
  51158. * Gets the current double sided mode.
  51159. */
  51160. /**
  51161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51162. */
  51163. doubleSided: boolean;
  51164. /**
  51165. * Stores the pre-calculated light information of a mesh in a texture.
  51166. */
  51167. lightmapTexture: BaseTexture;
  51168. /**
  51169. * If true, the light map contains occlusion information instead of lighting info.
  51170. */
  51171. useLightmapAsShadowmap: boolean;
  51172. /**
  51173. * Instantiates a new PBRMaterial instance.
  51174. *
  51175. * @param name The material name
  51176. * @param scene The scene the material will be use in.
  51177. */
  51178. constructor(name: string, scene: Scene);
  51179. getClassName(): string;
  51180. }
  51181. }
  51182. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51183. import { Scene } from "babylonjs/scene";
  51184. import { Color3 } from "babylonjs/Maths/math";
  51185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51186. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51187. /**
  51188. * The PBR material of BJS following the metal roughness convention.
  51189. *
  51190. * This fits to the PBR convention in the GLTF definition:
  51191. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51192. */
  51193. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51194. /**
  51195. * The base color has two different interpretations depending on the value of metalness.
  51196. * When the material is a metal, the base color is the specific measured reflectance value
  51197. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51198. * of the material.
  51199. */
  51200. baseColor: Color3;
  51201. /**
  51202. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51203. * well as opacity information in the alpha channel.
  51204. */
  51205. baseTexture: BaseTexture;
  51206. /**
  51207. * Specifies the metallic scalar value of the material.
  51208. * Can also be used to scale the metalness values of the metallic texture.
  51209. */
  51210. metallic: number;
  51211. /**
  51212. * Specifies the roughness scalar value of the material.
  51213. * Can also be used to scale the roughness values of the metallic texture.
  51214. */
  51215. roughness: number;
  51216. /**
  51217. * Texture containing both the metallic value in the B channel and the
  51218. * roughness value in the G channel to keep better precision.
  51219. */
  51220. metallicRoughnessTexture: BaseTexture;
  51221. /**
  51222. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51223. *
  51224. * @param name The material name
  51225. * @param scene The scene the material will be use in.
  51226. */
  51227. constructor(name: string, scene: Scene);
  51228. /**
  51229. * Return the currrent class name of the material.
  51230. */
  51231. getClassName(): string;
  51232. /**
  51233. * Makes a duplicate of the current material.
  51234. * @param name - name to use for the new material.
  51235. */
  51236. clone(name: string): PBRMetallicRoughnessMaterial;
  51237. /**
  51238. * Serialize the material to a parsable JSON object.
  51239. */
  51240. serialize(): any;
  51241. /**
  51242. * Parses a JSON object correponding to the serialize function.
  51243. */
  51244. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51245. }
  51246. }
  51247. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51248. import { Scene } from "babylonjs/scene";
  51249. import { Color3 } from "babylonjs/Maths/math";
  51250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51251. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51252. /**
  51253. * The PBR material of BJS following the specular glossiness convention.
  51254. *
  51255. * This fits to the PBR convention in the GLTF definition:
  51256. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51257. */
  51258. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51259. /**
  51260. * Specifies the diffuse color of the material.
  51261. */
  51262. diffuseColor: Color3;
  51263. /**
  51264. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51265. * channel.
  51266. */
  51267. diffuseTexture: BaseTexture;
  51268. /**
  51269. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51270. */
  51271. specularColor: Color3;
  51272. /**
  51273. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51274. */
  51275. glossiness: number;
  51276. /**
  51277. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51278. */
  51279. specularGlossinessTexture: BaseTexture;
  51280. /**
  51281. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51282. *
  51283. * @param name The material name
  51284. * @param scene The scene the material will be use in.
  51285. */
  51286. constructor(name: string, scene: Scene);
  51287. /**
  51288. * Return the currrent class name of the material.
  51289. */
  51290. getClassName(): string;
  51291. /**
  51292. * Makes a duplicate of the current material.
  51293. * @param name - name to use for the new material.
  51294. */
  51295. clone(name: string): PBRSpecularGlossinessMaterial;
  51296. /**
  51297. * Serialize the material to a parsable JSON object.
  51298. */
  51299. serialize(): any;
  51300. /**
  51301. * Parses a JSON object correponding to the serialize function.
  51302. */
  51303. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51304. }
  51305. }
  51306. declare module "babylonjs/Materials/PBR/index" {
  51307. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51308. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51309. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51310. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51311. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51312. }
  51313. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51314. import { Nullable } from "babylonjs/types";
  51315. import { Scene } from "babylonjs/scene";
  51316. import { Matrix } from "babylonjs/Maths/math";
  51317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51318. /**
  51319. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51320. * It can help converting any input color in a desired output one. This can then be used to create effects
  51321. * from sepia, black and white to sixties or futuristic rendering...
  51322. *
  51323. * The only supported format is currently 3dl.
  51324. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51325. */
  51326. export class ColorGradingTexture extends BaseTexture {
  51327. /**
  51328. * The current texture matrix. (will always be identity in color grading texture)
  51329. */
  51330. private _textureMatrix;
  51331. /**
  51332. * The texture URL.
  51333. */
  51334. url: string;
  51335. /**
  51336. * Empty line regex stored for GC.
  51337. */
  51338. private static _noneEmptyLineRegex;
  51339. private _engine;
  51340. /**
  51341. * Instantiates a ColorGradingTexture from the following parameters.
  51342. *
  51343. * @param url The location of the color gradind data (currently only supporting 3dl)
  51344. * @param scene The scene the texture will be used in
  51345. */
  51346. constructor(url: string, scene: Scene);
  51347. /**
  51348. * Returns the texture matrix used in most of the material.
  51349. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51350. */
  51351. getTextureMatrix(): Matrix;
  51352. /**
  51353. * Occurs when the file being loaded is a .3dl LUT file.
  51354. */
  51355. private load3dlTexture;
  51356. /**
  51357. * Starts the loading process of the texture.
  51358. */
  51359. private loadTexture;
  51360. /**
  51361. * Clones the color gradind texture.
  51362. */
  51363. clone(): ColorGradingTexture;
  51364. /**
  51365. * Called during delayed load for textures.
  51366. */
  51367. delayLoad(): void;
  51368. /**
  51369. * Parses a color grading texture serialized by Babylon.
  51370. * @param parsedTexture The texture information being parsedTexture
  51371. * @param scene The scene to load the texture in
  51372. * @param rootUrl The root url of the data assets to load
  51373. * @return A color gradind texture
  51374. */
  51375. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51376. /**
  51377. * Serializes the LUT texture to json format.
  51378. */
  51379. serialize(): any;
  51380. }
  51381. }
  51382. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51384. import { Scene } from "babylonjs/scene";
  51385. import { Nullable } from "babylonjs/types";
  51386. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51387. /**
  51388. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51389. */
  51390. export class EquiRectangularCubeTexture extends BaseTexture {
  51391. /** The six faces of the cube. */
  51392. private static _FacesMapping;
  51393. private _noMipmap;
  51394. private _onLoad;
  51395. private _onError;
  51396. /** The size of the cubemap. */
  51397. private _size;
  51398. /** The buffer of the image. */
  51399. private _buffer;
  51400. /** The width of the input image. */
  51401. private _width;
  51402. /** The height of the input image. */
  51403. private _height;
  51404. /** The URL to the image. */
  51405. url: string;
  51406. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51407. coordinatesMode: number;
  51408. /**
  51409. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51410. * @param url The location of the image
  51411. * @param scene The scene the texture will be used in
  51412. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51413. * @param noMipmap Forces to not generate the mipmap if true
  51414. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51415. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51416. * @param onLoad — defines a callback called when texture is loaded
  51417. * @param onError — defines a callback called if there is an error
  51418. */
  51419. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51420. /**
  51421. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51422. */
  51423. private loadImage;
  51424. /**
  51425. * Convert the image buffer into a cubemap and create a CubeTexture.
  51426. */
  51427. private loadTexture;
  51428. /**
  51429. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51430. * @param buffer The ArrayBuffer that should be converted.
  51431. * @returns The buffer as Float32Array.
  51432. */
  51433. private getFloat32ArrayFromArrayBuffer;
  51434. /**
  51435. * Get the current class name of the texture useful for serialization or dynamic coding.
  51436. * @returns "EquiRectangularCubeTexture"
  51437. */
  51438. getClassName(): string;
  51439. /**
  51440. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51441. * @returns A clone of the current EquiRectangularCubeTexture.
  51442. */
  51443. clone(): EquiRectangularCubeTexture;
  51444. }
  51445. }
  51446. declare module "babylonjs/Misc/tga" {
  51447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51448. /**
  51449. * Based on jsTGALoader - Javascript loader for TGA file
  51450. * By Vincent Thibault
  51451. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51452. */
  51453. export class TGATools {
  51454. private static _TYPE_INDEXED;
  51455. private static _TYPE_RGB;
  51456. private static _TYPE_GREY;
  51457. private static _TYPE_RLE_INDEXED;
  51458. private static _TYPE_RLE_RGB;
  51459. private static _TYPE_RLE_GREY;
  51460. private static _ORIGIN_MASK;
  51461. private static _ORIGIN_SHIFT;
  51462. private static _ORIGIN_BL;
  51463. private static _ORIGIN_BR;
  51464. private static _ORIGIN_UL;
  51465. private static _ORIGIN_UR;
  51466. /**
  51467. * Gets the header of a TGA file
  51468. * @param data defines the TGA data
  51469. * @returns the header
  51470. */
  51471. static GetTGAHeader(data: Uint8Array): any;
  51472. /**
  51473. * Uploads TGA content to a Babylon Texture
  51474. * @hidden
  51475. */
  51476. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51477. /** @hidden */
  51478. 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;
  51479. /** @hidden */
  51480. 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;
  51481. /** @hidden */
  51482. 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;
  51483. /** @hidden */
  51484. 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;
  51485. /** @hidden */
  51486. 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;
  51487. /** @hidden */
  51488. 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;
  51489. }
  51490. }
  51491. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51492. import { Nullable } from "babylonjs/types";
  51493. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51494. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51495. /**
  51496. * Implementation of the TGA Texture Loader.
  51497. * @hidden
  51498. */
  51499. export class _TGATextureLoader implements IInternalTextureLoader {
  51500. /**
  51501. * Defines wether the loader supports cascade loading the different faces.
  51502. */
  51503. readonly supportCascades: boolean;
  51504. /**
  51505. * This returns if the loader support the current file information.
  51506. * @param extension defines the file extension of the file being loaded
  51507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51508. * @param fallback defines the fallback internal texture if any
  51509. * @param isBase64 defines whether the texture is encoded as a base64
  51510. * @param isBuffer defines whether the texture data are stored as a buffer
  51511. * @returns true if the loader can load the specified file
  51512. */
  51513. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51514. /**
  51515. * Transform the url before loading if required.
  51516. * @param rootUrl the url of the texture
  51517. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51518. * @returns the transformed texture
  51519. */
  51520. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51521. /**
  51522. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51523. * @param rootUrl the url of the texture
  51524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51525. * @returns the fallback texture
  51526. */
  51527. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51528. /**
  51529. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51530. * @param data contains the texture data
  51531. * @param texture defines the BabylonJS internal texture
  51532. * @param createPolynomials will be true if polynomials have been requested
  51533. * @param onLoad defines the callback to trigger once the texture is ready
  51534. * @param onError defines the callback to trigger in case of error
  51535. */
  51536. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51537. /**
  51538. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51539. * @param data contains the texture data
  51540. * @param texture defines the BabylonJS internal texture
  51541. * @param callback defines the method to call once ready to upload
  51542. */
  51543. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51544. }
  51545. }
  51546. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51547. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51548. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51549. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51550. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51551. }
  51552. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51553. import { Scene } from "babylonjs/scene";
  51554. import { Texture } from "babylonjs/Materials/Textures/texture";
  51555. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51556. /**
  51557. * 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.
  51558. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51559. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51560. */
  51561. export class CustomProceduralTexture extends ProceduralTexture {
  51562. private _animate;
  51563. private _time;
  51564. private _config;
  51565. private _texturePath;
  51566. /**
  51567. * Instantiates a new Custom Procedural Texture.
  51568. * 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.
  51569. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51570. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51571. * @param name Define the name of the texture
  51572. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51573. * @param size Define the size of the texture to create
  51574. * @param scene Define the scene the texture belongs to
  51575. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51576. * @param generateMipMaps Define if the texture should creates mip maps or not
  51577. */
  51578. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51579. private _loadJson;
  51580. /**
  51581. * Is the texture ready to be used ? (rendered at least once)
  51582. * @returns true if ready, otherwise, false.
  51583. */
  51584. isReady(): boolean;
  51585. /**
  51586. * Render the texture to its associated render target.
  51587. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51588. */
  51589. render(useCameraPostProcess?: boolean): void;
  51590. /**
  51591. * Update the list of dependant textures samplers in the shader.
  51592. */
  51593. updateTextures(): void;
  51594. /**
  51595. * Update the uniform values of the procedural texture in the shader.
  51596. */
  51597. updateShaderUniforms(): void;
  51598. /**
  51599. * Define if the texture animates or not.
  51600. */
  51601. animate: boolean;
  51602. }
  51603. }
  51604. declare module "babylonjs/Shaders/noise.fragment" {
  51605. /** @hidden */
  51606. export var noisePixelShader: {
  51607. name: string;
  51608. shader: string;
  51609. };
  51610. }
  51611. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51612. import { Nullable } from "babylonjs/types";
  51613. import { Scene } from "babylonjs/scene";
  51614. import { Texture } from "babylonjs/Materials/Textures/texture";
  51615. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51616. import "babylonjs/Shaders/noise.fragment";
  51617. /**
  51618. * Class used to generate noise procedural textures
  51619. */
  51620. export class NoiseProceduralTexture extends ProceduralTexture {
  51621. private _time;
  51622. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51623. brightness: number;
  51624. /** Defines the number of octaves to process */
  51625. octaves: number;
  51626. /** Defines the level of persistence (0.8 by default) */
  51627. persistence: number;
  51628. /** Gets or sets animation speed factor (default is 1) */
  51629. animationSpeedFactor: number;
  51630. /**
  51631. * Creates a new NoiseProceduralTexture
  51632. * @param name defines the name fo the texture
  51633. * @param size defines the size of the texture (default is 256)
  51634. * @param scene defines the hosting scene
  51635. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51636. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51637. */
  51638. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51639. private _updateShaderUniforms;
  51640. protected _getDefines(): string;
  51641. /** Generate the current state of the procedural texture */
  51642. render(useCameraPostProcess?: boolean): void;
  51643. /**
  51644. * Serializes this noise procedural texture
  51645. * @returns a serialized noise procedural texture object
  51646. */
  51647. serialize(): any;
  51648. /**
  51649. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51650. * @param parsedTexture defines parsed texture data
  51651. * @param scene defines the current scene
  51652. * @param rootUrl defines the root URL containing noise procedural texture information
  51653. * @returns a parsed NoiseProceduralTexture
  51654. */
  51655. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51656. }
  51657. }
  51658. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51659. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51660. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51661. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51662. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51663. }
  51664. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51665. import { Nullable } from "babylonjs/types";
  51666. import { Scene } from "babylonjs/scene";
  51667. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51668. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51669. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51670. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51671. /**
  51672. * Raw cube texture where the raw buffers are passed in
  51673. */
  51674. export class RawCubeTexture extends CubeTexture {
  51675. /**
  51676. * Creates a cube texture where the raw buffers are passed in.
  51677. * @param scene defines the scene the texture is attached to
  51678. * @param data defines the array of data to use to create each face
  51679. * @param size defines the size of the textures
  51680. * @param format defines the format of the data
  51681. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51682. * @param generateMipMaps defines if the engine should generate the mip levels
  51683. * @param invertY defines if data must be stored with Y axis inverted
  51684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51685. * @param compression defines the compression used (null by default)
  51686. */
  51687. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51688. /**
  51689. * Updates the raw cube texture.
  51690. * @param data defines the data to store
  51691. * @param format defines the data format
  51692. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51693. * @param invertY defines if data must be stored with Y axis inverted
  51694. * @param compression defines the compression used (null by default)
  51695. * @param level defines which level of the texture to update
  51696. */
  51697. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51698. /**
  51699. * Updates a raw cube texture with RGBD encoded data.
  51700. * @param data defines the array of data [mipmap][face] to use to create each face
  51701. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51702. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51703. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51704. * @returns a promsie that resolves when the operation is complete
  51705. */
  51706. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51707. /**
  51708. * Clones the raw cube texture.
  51709. * @return a new cube texture
  51710. */
  51711. clone(): CubeTexture;
  51712. /** @hidden */
  51713. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51714. }
  51715. }
  51716. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51717. import { Scene } from "babylonjs/scene";
  51718. import { Texture } from "babylonjs/Materials/Textures/texture";
  51719. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51720. /**
  51721. * Class used to store 3D textures containing user data
  51722. */
  51723. export class RawTexture3D extends Texture {
  51724. /** Gets or sets the texture format to use */
  51725. format: number;
  51726. private _engine;
  51727. /**
  51728. * Create a new RawTexture3D
  51729. * @param data defines the data of the texture
  51730. * @param width defines the width of the texture
  51731. * @param height defines the height of the texture
  51732. * @param depth defines the depth of the texture
  51733. * @param format defines the texture format to use
  51734. * @param scene defines the hosting scene
  51735. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51736. * @param invertY defines if texture must be stored with Y axis inverted
  51737. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51739. */
  51740. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51741. /** Gets or sets the texture format to use */
  51742. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51743. /**
  51744. * Update the texture with new data
  51745. * @param data defines the data to store in the texture
  51746. */
  51747. update(data: ArrayBufferView): void;
  51748. }
  51749. }
  51750. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51751. import { Scene } from "babylonjs/scene";
  51752. import { Plane } from "babylonjs/Maths/math";
  51753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51754. /**
  51755. * Creates a refraction texture used by refraction channel of the standard material.
  51756. * It is like a mirror but to see through a material.
  51757. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51758. */
  51759. export class RefractionTexture extends RenderTargetTexture {
  51760. /**
  51761. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51762. * 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.
  51763. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51764. */
  51765. refractionPlane: Plane;
  51766. /**
  51767. * Define how deep under the surface we should see.
  51768. */
  51769. depth: number;
  51770. /**
  51771. * Creates a refraction texture used by refraction channel of the standard material.
  51772. * It is like a mirror but to see through a material.
  51773. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51774. * @param name Define the texture name
  51775. * @param size Define the size of the underlying texture
  51776. * @param scene Define the scene the refraction belongs to
  51777. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51778. */
  51779. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51780. /**
  51781. * Clone the refraction texture.
  51782. * @returns the cloned texture
  51783. */
  51784. clone(): RefractionTexture;
  51785. /**
  51786. * Serialize the texture to a JSON representation you could use in Parse later on
  51787. * @returns the serialized JSON representation
  51788. */
  51789. serialize(): any;
  51790. }
  51791. }
  51792. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51793. import { Nullable } from "babylonjs/types";
  51794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51795. import { Matrix } from "babylonjs/Maths/math";
  51796. import { Engine } from "babylonjs/Engines/engine";
  51797. import { Scene } from "babylonjs/scene";
  51798. /**
  51799. * Defines the options related to the creation of an HtmlElementTexture
  51800. */
  51801. export interface IHtmlElementTextureOptions {
  51802. /**
  51803. * Defines wether mip maps should be created or not.
  51804. */
  51805. generateMipMaps?: boolean;
  51806. /**
  51807. * Defines the sampling mode of the texture.
  51808. */
  51809. samplingMode?: number;
  51810. /**
  51811. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51812. */
  51813. engine: Nullable<Engine>;
  51814. /**
  51815. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51816. */
  51817. scene: Nullable<Scene>;
  51818. }
  51819. /**
  51820. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51821. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51822. * is automatically managed.
  51823. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51824. * in your application.
  51825. *
  51826. * As the update is not automatic, you need to call them manually.
  51827. */
  51828. export class HtmlElementTexture extends BaseTexture {
  51829. /**
  51830. * The texture URL.
  51831. */
  51832. element: HTMLVideoElement | HTMLCanvasElement;
  51833. private static readonly DefaultOptions;
  51834. private _textureMatrix;
  51835. private _engine;
  51836. private _isVideo;
  51837. private _generateMipMaps;
  51838. private _samplingMode;
  51839. /**
  51840. * Instantiates a HtmlElementTexture from the following parameters.
  51841. *
  51842. * @param name Defines the name of the texture
  51843. * @param element Defines the video or canvas the texture is filled with
  51844. * @param options Defines the other none mandatory texture creation options
  51845. */
  51846. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51847. private _createInternalTexture;
  51848. /**
  51849. * Returns the texture matrix used in most of the material.
  51850. */
  51851. getTextureMatrix(): Matrix;
  51852. /**
  51853. * Updates the content of the texture.
  51854. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51855. */
  51856. update(invertY?: Nullable<boolean>): void;
  51857. }
  51858. }
  51859. declare module "babylonjs/Materials/Textures/index" {
  51860. export * from "babylonjs/Materials/Textures/baseTexture";
  51861. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51862. export * from "babylonjs/Materials/Textures/cubeTexture";
  51863. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51864. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51865. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51866. export * from "babylonjs/Materials/Textures/internalTexture";
  51867. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51868. export * from "babylonjs/Materials/Textures/Loaders/index";
  51869. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51870. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51871. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51872. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51873. export * from "babylonjs/Materials/Textures/rawTexture";
  51874. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51875. export * from "babylonjs/Materials/Textures/refractionTexture";
  51876. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51877. export * from "babylonjs/Materials/Textures/texture";
  51878. export * from "babylonjs/Materials/Textures/videoTexture";
  51879. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51880. }
  51881. declare module "babylonjs/Materials/index" {
  51882. export * from "babylonjs/Materials/Background/index";
  51883. export * from "babylonjs/Materials/colorCurves";
  51884. export * from "babylonjs/Materials/effect";
  51885. export * from "babylonjs/Materials/fresnelParameters";
  51886. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51887. export * from "babylonjs/Materials/material";
  51888. export * from "babylonjs/Materials/materialDefines";
  51889. export * from "babylonjs/Materials/materialHelper";
  51890. export * from "babylonjs/Materials/multiMaterial";
  51891. export * from "babylonjs/Materials/PBR/index";
  51892. export * from "babylonjs/Materials/pushMaterial";
  51893. export * from "babylonjs/Materials/shaderMaterial";
  51894. export * from "babylonjs/Materials/standardMaterial";
  51895. export * from "babylonjs/Materials/Textures/index";
  51896. export * from "babylonjs/Materials/uniformBuffer";
  51897. export * from "babylonjs/Materials/materialFlags";
  51898. }
  51899. declare module "babylonjs/Maths/index" {
  51900. export * from "babylonjs/Maths/math.scalar";
  51901. export * from "babylonjs/Maths/math";
  51902. export * from "babylonjs/Maths/sphericalPolynomial";
  51903. }
  51904. declare module "babylonjs/Misc/workerPool" {
  51905. import { IDisposable } from "babylonjs/scene";
  51906. /**
  51907. * Helper class to push actions to a pool of workers.
  51908. */
  51909. export class WorkerPool implements IDisposable {
  51910. private _workerInfos;
  51911. private _pendingActions;
  51912. /**
  51913. * Constructor
  51914. * @param workers Array of workers to use for actions
  51915. */
  51916. constructor(workers: Array<Worker>);
  51917. /**
  51918. * Terminates all workers and clears any pending actions.
  51919. */
  51920. dispose(): void;
  51921. /**
  51922. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51923. * pended until a worker has completed its action.
  51924. * @param action The action to perform. Call onComplete when the action is complete.
  51925. */
  51926. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51927. private _execute;
  51928. }
  51929. }
  51930. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51931. import { IDisposable } from "babylonjs/scene";
  51932. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51933. /**
  51934. * Configuration for Draco compression
  51935. */
  51936. export interface IDracoCompressionConfiguration {
  51937. /**
  51938. * Configuration for the decoder.
  51939. */
  51940. decoder?: {
  51941. /**
  51942. * The url to the WebAssembly module.
  51943. */
  51944. wasmUrl?: string;
  51945. /**
  51946. * The url to the WebAssembly binary.
  51947. */
  51948. wasmBinaryUrl?: string;
  51949. /**
  51950. * The url to the fallback JavaScript module.
  51951. */
  51952. fallbackUrl?: string;
  51953. };
  51954. }
  51955. /**
  51956. * Draco compression (https://google.github.io/draco/)
  51957. *
  51958. * This class wraps the Draco module.
  51959. *
  51960. * **Encoder**
  51961. *
  51962. * The encoder is not currently implemented.
  51963. *
  51964. * **Decoder**
  51965. *
  51966. * 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.
  51967. *
  51968. * To update the configuration, use the following code:
  51969. * ```javascript
  51970. * DracoCompression.Configuration = {
  51971. * decoder: {
  51972. * wasmUrl: "<url to the WebAssembly library>",
  51973. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51974. * fallbackUrl: "<url to the fallback JavaScript library>",
  51975. * }
  51976. * };
  51977. * ```
  51978. *
  51979. * 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.
  51980. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51981. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51982. *
  51983. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51984. * ```javascript
  51985. * var dracoCompression = new DracoCompression();
  51986. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51987. * [VertexBuffer.PositionKind]: 0
  51988. * });
  51989. * ```
  51990. *
  51991. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51992. */
  51993. export class DracoCompression implements IDisposable {
  51994. private _workerPoolPromise;
  51995. /**
  51996. * The configuration. Defaults to the following urls:
  51997. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51998. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51999. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52000. */
  52001. static Configuration: IDracoCompressionConfiguration;
  52002. /**
  52003. * Returns true if the decoder is available.
  52004. */
  52005. static readonly DecoderAvailable: boolean;
  52006. /**
  52007. * Default number of workers to create when creating the draco compression object.
  52008. */
  52009. static DefaultNumWorkers: number;
  52010. private static GetDefaultNumWorkers;
  52011. /**
  52012. * Constructor
  52013. * @param numWorkers The number of workers for async operations
  52014. */
  52015. constructor(numWorkers?: number);
  52016. /**
  52017. * Stop all async operations and release resources.
  52018. */
  52019. dispose(): void;
  52020. /**
  52021. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52022. * @returns a promise that resolves when ready
  52023. */
  52024. whenReadyAsync(): Promise<void>;
  52025. /**
  52026. * Decode Draco compressed mesh data to vertex data.
  52027. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52028. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52029. * @returns A promise that resolves with the decoded vertex data
  52030. */
  52031. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52032. [kind: string]: number;
  52033. }): Promise<VertexData>;
  52034. /**
  52035. * The worker function that gets converted to a blob url to pass into a worker.
  52036. */
  52037. private static _Worker;
  52038. private _loadDecoderWasmBinaryAsync;
  52039. }
  52040. }
  52041. declare module "babylonjs/Meshes/Compression/index" {
  52042. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52043. }
  52044. declare module "babylonjs/Meshes/csg" {
  52045. import { Nullable } from "babylonjs/types";
  52046. import { Scene } from "babylonjs/scene";
  52047. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52048. import { Mesh } from "babylonjs/Meshes/mesh";
  52049. import { Material } from "babylonjs/Materials/material";
  52050. /**
  52051. * Class for building Constructive Solid Geometry
  52052. */
  52053. export class CSG {
  52054. private polygons;
  52055. /**
  52056. * The world matrix
  52057. */
  52058. matrix: Matrix;
  52059. /**
  52060. * Stores the position
  52061. */
  52062. position: Vector3;
  52063. /**
  52064. * Stores the rotation
  52065. */
  52066. rotation: Vector3;
  52067. /**
  52068. * Stores the rotation quaternion
  52069. */
  52070. rotationQuaternion: Nullable<Quaternion>;
  52071. /**
  52072. * Stores the scaling vector
  52073. */
  52074. scaling: Vector3;
  52075. /**
  52076. * Convert the Mesh to CSG
  52077. * @param mesh The Mesh to convert to CSG
  52078. * @returns A new CSG from the Mesh
  52079. */
  52080. static FromMesh(mesh: Mesh): CSG;
  52081. /**
  52082. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52083. * @param polygons Polygons used to construct a CSG solid
  52084. */
  52085. private static FromPolygons;
  52086. /**
  52087. * Clones, or makes a deep copy, of the CSG
  52088. * @returns A new CSG
  52089. */
  52090. clone(): CSG;
  52091. /**
  52092. * Unions this CSG with another CSG
  52093. * @param csg The CSG to union against this CSG
  52094. * @returns The unioned CSG
  52095. */
  52096. union(csg: CSG): CSG;
  52097. /**
  52098. * Unions this CSG with another CSG in place
  52099. * @param csg The CSG to union against this CSG
  52100. */
  52101. unionInPlace(csg: CSG): void;
  52102. /**
  52103. * Subtracts this CSG with another CSG
  52104. * @param csg The CSG to subtract against this CSG
  52105. * @returns A new CSG
  52106. */
  52107. subtract(csg: CSG): CSG;
  52108. /**
  52109. * Subtracts this CSG with another CSG in place
  52110. * @param csg The CSG to subtact against this CSG
  52111. */
  52112. subtractInPlace(csg: CSG): void;
  52113. /**
  52114. * Intersect this CSG with another CSG
  52115. * @param csg The CSG to intersect against this CSG
  52116. * @returns A new CSG
  52117. */
  52118. intersect(csg: CSG): CSG;
  52119. /**
  52120. * Intersects this CSG with another CSG in place
  52121. * @param csg The CSG to intersect against this CSG
  52122. */
  52123. intersectInPlace(csg: CSG): void;
  52124. /**
  52125. * Return a new CSG solid with solid and empty space switched. This solid is
  52126. * not modified.
  52127. * @returns A new CSG solid with solid and empty space switched
  52128. */
  52129. inverse(): CSG;
  52130. /**
  52131. * Inverses the CSG in place
  52132. */
  52133. inverseInPlace(): void;
  52134. /**
  52135. * This is used to keep meshes transformations so they can be restored
  52136. * when we build back a Babylon Mesh
  52137. * NB : All CSG operations are performed in world coordinates
  52138. * @param csg The CSG to copy the transform attributes from
  52139. * @returns This CSG
  52140. */
  52141. copyTransformAttributes(csg: CSG): CSG;
  52142. /**
  52143. * Build Raw mesh from CSG
  52144. * Coordinates here are in world space
  52145. * @param name The name of the mesh geometry
  52146. * @param scene The Scene
  52147. * @param keepSubMeshes Specifies if the submeshes should be kept
  52148. * @returns A new Mesh
  52149. */
  52150. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52151. /**
  52152. * Build Mesh from CSG taking material and transforms into account
  52153. * @param name The name of the Mesh
  52154. * @param material The material of the Mesh
  52155. * @param scene The Scene
  52156. * @param keepSubMeshes Specifies if submeshes should be kept
  52157. * @returns The new Mesh
  52158. */
  52159. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52160. }
  52161. }
  52162. declare module "babylonjs/Meshes/trailMesh" {
  52163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52164. import { Mesh } from "babylonjs/Meshes/mesh";
  52165. import { Scene } from "babylonjs/scene";
  52166. /**
  52167. * Class used to create a trail following a mesh
  52168. */
  52169. export class TrailMesh extends Mesh {
  52170. private _generator;
  52171. private _autoStart;
  52172. private _running;
  52173. private _diameter;
  52174. private _length;
  52175. private _sectionPolygonPointsCount;
  52176. private _sectionVectors;
  52177. private _sectionNormalVectors;
  52178. private _beforeRenderObserver;
  52179. /**
  52180. * @constructor
  52181. * @param name The value used by scene.getMeshByName() to do a lookup.
  52182. * @param generator The mesh to generate a trail.
  52183. * @param scene The scene to add this mesh to.
  52184. * @param diameter Diameter of trailing mesh. Default is 1.
  52185. * @param length Length of trailing mesh. Default is 60.
  52186. * @param autoStart Automatically start trailing mesh. Default true.
  52187. */
  52188. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52189. /**
  52190. * "TrailMesh"
  52191. * @returns "TrailMesh"
  52192. */
  52193. getClassName(): string;
  52194. private _createMesh;
  52195. /**
  52196. * Start trailing mesh.
  52197. */
  52198. start(): void;
  52199. /**
  52200. * Stop trailing mesh.
  52201. */
  52202. stop(): void;
  52203. /**
  52204. * Update trailing mesh geometry.
  52205. */
  52206. update(): void;
  52207. /**
  52208. * Returns a new TrailMesh object.
  52209. * @param name is a string, the name given to the new mesh
  52210. * @param newGenerator use new generator object for cloned trail mesh
  52211. * @returns a new mesh
  52212. */
  52213. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52214. /**
  52215. * Serializes this trail mesh
  52216. * @param serializationObject object to write serialization to
  52217. */
  52218. serialize(serializationObject: any): void;
  52219. /**
  52220. * Parses a serialized trail mesh
  52221. * @param parsedMesh the serialized mesh
  52222. * @param scene the scene to create the trail mesh in
  52223. * @returns the created trail mesh
  52224. */
  52225. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52226. }
  52227. }
  52228. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52229. import { Vector4 } from "babylonjs/Maths/math";
  52230. import { Mesh } from "babylonjs/Meshes/mesh";
  52231. /**
  52232. * Class containing static functions to help procedurally build meshes
  52233. */
  52234. export class TorusKnotBuilder {
  52235. /**
  52236. * Creates a torus knot mesh
  52237. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52238. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52239. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52240. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52244. * @param name defines the name of the mesh
  52245. * @param options defines the options used to create the mesh
  52246. * @param scene defines the hosting scene
  52247. * @returns the torus knot mesh
  52248. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52249. */
  52250. static CreateTorusKnot(name: string, options: {
  52251. radius?: number;
  52252. tube?: number;
  52253. radialSegments?: number;
  52254. tubularSegments?: number;
  52255. p?: number;
  52256. q?: number;
  52257. updatable?: boolean;
  52258. sideOrientation?: number;
  52259. frontUVs?: Vector4;
  52260. backUVs?: Vector4;
  52261. }, scene: any): Mesh;
  52262. }
  52263. }
  52264. declare module "babylonjs/Meshes/polygonMesh" {
  52265. import { Scene } from "babylonjs/scene";
  52266. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52267. import { Mesh } from "babylonjs/Meshes/mesh";
  52268. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52269. /**
  52270. * Polygon
  52271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52272. */
  52273. export class Polygon {
  52274. /**
  52275. * Creates a rectangle
  52276. * @param xmin bottom X coord
  52277. * @param ymin bottom Y coord
  52278. * @param xmax top X coord
  52279. * @param ymax top Y coord
  52280. * @returns points that make the resulting rectation
  52281. */
  52282. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52283. /**
  52284. * Creates a circle
  52285. * @param radius radius of circle
  52286. * @param cx scale in x
  52287. * @param cy scale in y
  52288. * @param numberOfSides number of sides that make up the circle
  52289. * @returns points that make the resulting circle
  52290. */
  52291. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52292. /**
  52293. * Creates a polygon from input string
  52294. * @param input Input polygon data
  52295. * @returns the parsed points
  52296. */
  52297. static Parse(input: string): Vector2[];
  52298. /**
  52299. * Starts building a polygon from x and y coordinates
  52300. * @param x x coordinate
  52301. * @param y y coordinate
  52302. * @returns the started path2
  52303. */
  52304. static StartingAt(x: number, y: number): Path2;
  52305. }
  52306. /**
  52307. * Builds a polygon
  52308. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52309. */
  52310. export class PolygonMeshBuilder {
  52311. private _points;
  52312. private _outlinepoints;
  52313. private _holes;
  52314. private _name;
  52315. private _scene;
  52316. private _epoints;
  52317. private _eholes;
  52318. private _addToepoint;
  52319. /**
  52320. * Babylon reference to the earcut plugin.
  52321. */
  52322. bjsEarcut: any;
  52323. /**
  52324. * Creates a PolygonMeshBuilder
  52325. * @param name name of the builder
  52326. * @param contours Path of the polygon
  52327. * @param scene scene to add to when creating the mesh
  52328. * @param earcutInjection can be used to inject your own earcut reference
  52329. */
  52330. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52331. /**
  52332. * Adds a whole within the polygon
  52333. * @param hole Array of points defining the hole
  52334. * @returns this
  52335. */
  52336. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52337. /**
  52338. * Creates the polygon
  52339. * @param updatable If the mesh should be updatable
  52340. * @param depth The depth of the mesh created
  52341. * @returns the created mesh
  52342. */
  52343. build(updatable?: boolean, depth?: number): Mesh;
  52344. /**
  52345. * Creates the polygon
  52346. * @param depth The depth of the mesh created
  52347. * @returns the created VertexData
  52348. */
  52349. buildVertexData(depth?: number): VertexData;
  52350. /**
  52351. * Adds a side to the polygon
  52352. * @param positions points that make the polygon
  52353. * @param normals normals of the polygon
  52354. * @param uvs uvs of the polygon
  52355. * @param indices indices of the polygon
  52356. * @param bounds bounds of the polygon
  52357. * @param points points of the polygon
  52358. * @param depth depth of the polygon
  52359. * @param flip flip of the polygon
  52360. */
  52361. private addSide;
  52362. }
  52363. }
  52364. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52365. import { Scene } from "babylonjs/scene";
  52366. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52367. import { Mesh } from "babylonjs/Meshes/mesh";
  52368. import { Nullable } from "babylonjs/types";
  52369. /**
  52370. * Class containing static functions to help procedurally build meshes
  52371. */
  52372. export class PolygonBuilder {
  52373. /**
  52374. * Creates a polygon mesh
  52375. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52376. * * 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
  52377. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52380. * * Remember you can only change the shape positions, not their number when updating a polygon
  52381. * @param name defines the name of the mesh
  52382. * @param options defines the options used to create the mesh
  52383. * @param scene defines the hosting scene
  52384. * @param earcutInjection can be used to inject your own earcut reference
  52385. * @returns the polygon mesh
  52386. */
  52387. static CreatePolygon(name: string, options: {
  52388. shape: Vector3[];
  52389. holes?: Vector3[][];
  52390. depth?: number;
  52391. faceUV?: Vector4[];
  52392. faceColors?: Color4[];
  52393. updatable?: boolean;
  52394. sideOrientation?: number;
  52395. frontUVs?: Vector4;
  52396. backUVs?: Vector4;
  52397. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52398. /**
  52399. * Creates an extruded polygon mesh, with depth in the Y direction.
  52400. * * 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)
  52401. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52402. * @param name defines the name of the mesh
  52403. * @param options defines the options used to create the mesh
  52404. * @param scene defines the hosting scene
  52405. * @param earcutInjection can be used to inject your own earcut reference
  52406. * @returns the polygon mesh
  52407. */
  52408. static ExtrudePolygon(name: string, options: {
  52409. shape: Vector3[];
  52410. holes?: Vector3[][];
  52411. depth?: number;
  52412. faceUV?: Vector4[];
  52413. faceColors?: Color4[];
  52414. updatable?: boolean;
  52415. sideOrientation?: number;
  52416. frontUVs?: Vector4;
  52417. backUVs?: Vector4;
  52418. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52419. }
  52420. }
  52421. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52422. import { Scene } from "babylonjs/scene";
  52423. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52424. import { Mesh } from "babylonjs/Meshes/mesh";
  52425. import { Nullable } from "babylonjs/types";
  52426. /**
  52427. * Class containing static functions to help procedurally build meshes
  52428. */
  52429. export class LatheBuilder {
  52430. /**
  52431. * Creates lathe mesh.
  52432. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52433. * * 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
  52434. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52435. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52436. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52437. * * 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
  52438. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52439. * * 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
  52440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52444. * @param name defines the name of the mesh
  52445. * @param options defines the options used to create the mesh
  52446. * @param scene defines the hosting scene
  52447. * @returns the lathe mesh
  52448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52449. */
  52450. static CreateLathe(name: string, options: {
  52451. shape: Vector3[];
  52452. radius?: number;
  52453. tessellation?: number;
  52454. clip?: number;
  52455. arc?: number;
  52456. closed?: boolean;
  52457. updatable?: boolean;
  52458. sideOrientation?: number;
  52459. frontUVs?: Vector4;
  52460. backUVs?: Vector4;
  52461. cap?: number;
  52462. invertUV?: boolean;
  52463. }, scene?: Nullable<Scene>): Mesh;
  52464. }
  52465. }
  52466. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52467. import { Nullable } from "babylonjs/types";
  52468. import { Scene } from "babylonjs/scene";
  52469. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52470. import { Mesh } from "babylonjs/Meshes/mesh";
  52471. /**
  52472. * Class containing static functions to help procedurally build meshes
  52473. */
  52474. export class TubeBuilder {
  52475. /**
  52476. * Creates a tube mesh.
  52477. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52478. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52479. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52480. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52481. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52482. * * 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)
  52483. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52484. * * 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
  52485. * * 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
  52486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52490. * @param name defines the name of the mesh
  52491. * @param options defines the options used to create the mesh
  52492. * @param scene defines the hosting scene
  52493. * @returns the tube mesh
  52494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52495. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52496. */
  52497. static CreateTube(name: string, options: {
  52498. path: Vector3[];
  52499. radius?: number;
  52500. tessellation?: number;
  52501. radiusFunction?: {
  52502. (i: number, distance: number): number;
  52503. };
  52504. cap?: number;
  52505. arc?: number;
  52506. updatable?: boolean;
  52507. sideOrientation?: number;
  52508. frontUVs?: Vector4;
  52509. backUVs?: Vector4;
  52510. instance?: Mesh;
  52511. invertUV?: boolean;
  52512. }, scene?: Nullable<Scene>): Mesh;
  52513. }
  52514. }
  52515. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52516. import { Scene } from "babylonjs/scene";
  52517. import { Vector4 } from "babylonjs/Maths/math";
  52518. import { Mesh } from "babylonjs/Meshes/mesh";
  52519. import { Nullable } from "babylonjs/types";
  52520. /**
  52521. * Class containing static functions to help procedurally build meshes
  52522. */
  52523. export class IcoSphereBuilder {
  52524. /**
  52525. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52526. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52527. * * 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`)
  52528. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52529. * * 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
  52530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 icosahedron mesh
  52537. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52538. */
  52539. static CreateIcoSphere(name: string, options: {
  52540. radius?: number;
  52541. radiusX?: number;
  52542. radiusY?: number;
  52543. radiusZ?: number;
  52544. flat?: boolean;
  52545. subdivisions?: number;
  52546. sideOrientation?: number;
  52547. frontUVs?: Vector4;
  52548. backUVs?: Vector4;
  52549. updatable?: boolean;
  52550. }, scene?: Nullable<Scene>): Mesh;
  52551. }
  52552. }
  52553. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52554. import { Vector3 } from "babylonjs/Maths/math";
  52555. import { Mesh } from "babylonjs/Meshes/mesh";
  52556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52557. /**
  52558. * Class containing static functions to help procedurally build meshes
  52559. */
  52560. export class DecalBuilder {
  52561. /**
  52562. * Creates a decal mesh.
  52563. * 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
  52564. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52565. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52566. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52567. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52568. * @param name defines the name of the mesh
  52569. * @param sourceMesh defines the mesh where the decal must be applied
  52570. * @param options defines the options used to create the mesh
  52571. * @param scene defines the hosting scene
  52572. * @returns the decal mesh
  52573. * @see https://doc.babylonjs.com/how_to/decals
  52574. */
  52575. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52576. position?: Vector3;
  52577. normal?: Vector3;
  52578. size?: Vector3;
  52579. angle?: number;
  52580. }): Mesh;
  52581. }
  52582. }
  52583. declare module "babylonjs/Meshes/meshBuilder" {
  52584. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52585. import { Nullable } from "babylonjs/types";
  52586. import { Scene } from "babylonjs/scene";
  52587. import { Mesh } from "babylonjs/Meshes/mesh";
  52588. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52589. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52591. /**
  52592. * Class containing static functions to help procedurally build meshes
  52593. */
  52594. export class MeshBuilder {
  52595. /**
  52596. * Creates a box mesh
  52597. * * The parameter `size` sets the size (float) of each box side (default 1)
  52598. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52599. * * 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)
  52600. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52604. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52605. * @param name defines the name of the mesh
  52606. * @param options defines the options used to create the mesh
  52607. * @param scene defines the hosting scene
  52608. * @returns the box mesh
  52609. */
  52610. static CreateBox(name: string, options: {
  52611. size?: number;
  52612. width?: number;
  52613. height?: number;
  52614. depth?: number;
  52615. faceUV?: Vector4[];
  52616. faceColors?: Color4[];
  52617. sideOrientation?: number;
  52618. frontUVs?: Vector4;
  52619. backUVs?: Vector4;
  52620. updatable?: boolean;
  52621. }, scene?: Nullable<Scene>): Mesh;
  52622. /**
  52623. * Creates a sphere mesh
  52624. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52625. * * 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`)
  52626. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52627. * * 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
  52628. * * 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)
  52629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52632. * @param name defines the name of the mesh
  52633. * @param options defines the options used to create the mesh
  52634. * @param scene defines the hosting scene
  52635. * @returns the sphere mesh
  52636. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52637. */
  52638. static CreateSphere(name: string, options: {
  52639. segments?: number;
  52640. diameter?: number;
  52641. diameterX?: number;
  52642. diameterY?: number;
  52643. diameterZ?: number;
  52644. arc?: number;
  52645. slice?: number;
  52646. sideOrientation?: number;
  52647. frontUVs?: Vector4;
  52648. backUVs?: Vector4;
  52649. updatable?: boolean;
  52650. }, scene?: Nullable<Scene>): Mesh;
  52651. /**
  52652. * Creates a plane polygonal mesh. By default, this is a disc
  52653. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52654. * * 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
  52655. * * 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
  52656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52659. * @param name defines the name of the mesh
  52660. * @param options defines the options used to create the mesh
  52661. * @param scene defines the hosting scene
  52662. * @returns the plane polygonal mesh
  52663. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52664. */
  52665. static CreateDisc(name: string, options: {
  52666. radius?: number;
  52667. tessellation?: number;
  52668. arc?: number;
  52669. updatable?: boolean;
  52670. sideOrientation?: number;
  52671. frontUVs?: Vector4;
  52672. backUVs?: Vector4;
  52673. }, scene?: Nullable<Scene>): Mesh;
  52674. /**
  52675. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52676. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52677. * * 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`)
  52678. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52679. * * 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
  52680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52683. * @param name defines the name of the mesh
  52684. * @param options defines the options used to create the mesh
  52685. * @param scene defines the hosting scene
  52686. * @returns the icosahedron mesh
  52687. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52688. */
  52689. static CreateIcoSphere(name: string, options: {
  52690. radius?: number;
  52691. radiusX?: number;
  52692. radiusY?: number;
  52693. radiusZ?: number;
  52694. flat?: boolean;
  52695. subdivisions?: number;
  52696. sideOrientation?: number;
  52697. frontUVs?: Vector4;
  52698. backUVs?: Vector4;
  52699. updatable?: boolean;
  52700. }, scene?: Nullable<Scene>): Mesh;
  52701. /**
  52702. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52703. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52704. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52705. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52706. * * 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
  52707. * * 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
  52708. * * 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
  52709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52712. * * 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
  52713. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52714. * * 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
  52715. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52717. * @param name defines the name of the mesh
  52718. * @param options defines the options used to create the mesh
  52719. * @param scene defines the hosting scene
  52720. * @returns the ribbon mesh
  52721. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52723. */
  52724. static CreateRibbon(name: string, options: {
  52725. pathArray: Vector3[][];
  52726. closeArray?: boolean;
  52727. closePath?: boolean;
  52728. offset?: number;
  52729. updatable?: boolean;
  52730. sideOrientation?: number;
  52731. frontUVs?: Vector4;
  52732. backUVs?: Vector4;
  52733. instance?: Mesh;
  52734. invertUV?: boolean;
  52735. uvs?: Vector2[];
  52736. colors?: Color4[];
  52737. }, scene?: Nullable<Scene>): Mesh;
  52738. /**
  52739. * Creates a cylinder or a cone mesh
  52740. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52741. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52742. * * 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.
  52743. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52744. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52745. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52746. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52747. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52748. * * 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).
  52749. * * 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
  52750. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52751. * * 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
  52752. * * 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.
  52753. * * If `enclose` is false, a ring surface is one element.
  52754. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52755. * * 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
  52756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52759. * @param name defines the name of the mesh
  52760. * @param options defines the options used to create the mesh
  52761. * @param scene defines the hosting scene
  52762. * @returns the cylinder mesh
  52763. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52764. */
  52765. static CreateCylinder(name: string, options: {
  52766. height?: number;
  52767. diameterTop?: number;
  52768. diameterBottom?: number;
  52769. diameter?: number;
  52770. tessellation?: number;
  52771. subdivisions?: number;
  52772. arc?: number;
  52773. faceColors?: Color4[];
  52774. faceUV?: Vector4[];
  52775. updatable?: boolean;
  52776. hasRings?: boolean;
  52777. enclose?: boolean;
  52778. sideOrientation?: number;
  52779. frontUVs?: Vector4;
  52780. backUVs?: Vector4;
  52781. }, scene?: Nullable<Scene>): Mesh;
  52782. /**
  52783. * Creates a torus mesh
  52784. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52785. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52786. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52790. * @param name defines the name of the mesh
  52791. * @param options defines the options used to create the mesh
  52792. * @param scene defines the hosting scene
  52793. * @returns the torus mesh
  52794. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52795. */
  52796. static CreateTorus(name: string, options: {
  52797. diameter?: number;
  52798. thickness?: number;
  52799. tessellation?: number;
  52800. updatable?: boolean;
  52801. sideOrientation?: number;
  52802. frontUVs?: Vector4;
  52803. backUVs?: Vector4;
  52804. }, scene?: Nullable<Scene>): Mesh;
  52805. /**
  52806. * Creates a torus knot mesh
  52807. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52808. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52809. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52810. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52814. * @param name defines the name of the mesh
  52815. * @param options defines the options used to create the mesh
  52816. * @param scene defines the hosting scene
  52817. * @returns the torus knot mesh
  52818. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52819. */
  52820. static CreateTorusKnot(name: string, options: {
  52821. radius?: number;
  52822. tube?: number;
  52823. radialSegments?: number;
  52824. tubularSegments?: number;
  52825. p?: number;
  52826. q?: number;
  52827. updatable?: boolean;
  52828. sideOrientation?: number;
  52829. frontUVs?: Vector4;
  52830. backUVs?: Vector4;
  52831. }, scene?: Nullable<Scene>): Mesh;
  52832. /**
  52833. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52834. * * 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
  52835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52836. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52837. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52838. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52839. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52840. * * 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
  52841. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52844. * @param name defines the name of the new line system
  52845. * @param options defines the options used to create the line system
  52846. * @param scene defines the hosting scene
  52847. * @returns a new line system mesh
  52848. */
  52849. static CreateLineSystem(name: string, options: {
  52850. lines: Vector3[][];
  52851. updatable?: boolean;
  52852. instance?: Nullable<LinesMesh>;
  52853. colors?: Nullable<Color4[][]>;
  52854. useVertexAlpha?: boolean;
  52855. }, scene: Nullable<Scene>): LinesMesh;
  52856. /**
  52857. * Creates a line mesh
  52858. * 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
  52859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52860. * * The parameter `points` is an array successive Vector3
  52861. * * 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
  52862. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52863. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52864. * * When updating an instance, remember that only point positions can change, not the number of points
  52865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52867. * @param name defines the name of the new line system
  52868. * @param options defines the options used to create the line system
  52869. * @param scene defines the hosting scene
  52870. * @returns a new line mesh
  52871. */
  52872. static CreateLines(name: string, options: {
  52873. points: Vector3[];
  52874. updatable?: boolean;
  52875. instance?: Nullable<LinesMesh>;
  52876. colors?: Color4[];
  52877. useVertexAlpha?: boolean;
  52878. }, scene?: Nullable<Scene>): LinesMesh;
  52879. /**
  52880. * Creates a dashed line mesh
  52881. * * 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
  52882. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52883. * * The parameter `points` is an array successive Vector3
  52884. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52885. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52886. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52887. * * 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
  52888. * * When updating an instance, remember that only point positions can change, not the number of points
  52889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52890. * @param name defines the name of the mesh
  52891. * @param options defines the options used to create the mesh
  52892. * @param scene defines the hosting scene
  52893. * @returns the dashed line mesh
  52894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52895. */
  52896. static CreateDashedLines(name: string, options: {
  52897. points: Vector3[];
  52898. dashSize?: number;
  52899. gapSize?: number;
  52900. dashNb?: number;
  52901. updatable?: boolean;
  52902. instance?: LinesMesh;
  52903. }, scene?: Nullable<Scene>): LinesMesh;
  52904. /**
  52905. * 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.
  52906. * * 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.
  52907. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52908. * * 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.
  52909. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52910. * * 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
  52911. * * 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
  52912. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52917. * @param name defines the name of the mesh
  52918. * @param options defines the options used to create the mesh
  52919. * @param scene defines the hosting scene
  52920. * @returns the extruded shape mesh
  52921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52923. */
  52924. static ExtrudeShape(name: string, options: {
  52925. shape: Vector3[];
  52926. path: Vector3[];
  52927. scale?: number;
  52928. rotation?: number;
  52929. cap?: number;
  52930. updatable?: boolean;
  52931. sideOrientation?: number;
  52932. frontUVs?: Vector4;
  52933. backUVs?: Vector4;
  52934. instance?: Mesh;
  52935. invertUV?: boolean;
  52936. }, scene?: Nullable<Scene>): Mesh;
  52937. /**
  52938. * Creates an custom extruded shape mesh.
  52939. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52940. * * 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.
  52941. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52942. * * 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
  52943. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52944. * * 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
  52945. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52946. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52947. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52948. * * 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
  52949. * * 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
  52950. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52953. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  52956. * @param options defines the options used to create the mesh
  52957. * @param scene defines the hosting scene
  52958. * @returns the custom extruded shape mesh
  52959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52962. */
  52963. static ExtrudeShapeCustom(name: string, options: {
  52964. shape: Vector3[];
  52965. path: Vector3[];
  52966. scaleFunction?: any;
  52967. rotationFunction?: any;
  52968. ribbonCloseArray?: boolean;
  52969. ribbonClosePath?: boolean;
  52970. cap?: number;
  52971. updatable?: boolean;
  52972. sideOrientation?: number;
  52973. frontUVs?: Vector4;
  52974. backUVs?: Vector4;
  52975. instance?: Mesh;
  52976. invertUV?: boolean;
  52977. }, scene?: Nullable<Scene>): Mesh;
  52978. /**
  52979. * Creates lathe mesh.
  52980. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52981. * * 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
  52982. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52983. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52984. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52985. * * 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
  52986. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52987. * * 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
  52988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52992. * @param name defines the name of the mesh
  52993. * @param options defines the options used to create the mesh
  52994. * @param scene defines the hosting scene
  52995. * @returns the lathe mesh
  52996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52997. */
  52998. static CreateLathe(name: string, options: {
  52999. shape: Vector3[];
  53000. radius?: number;
  53001. tessellation?: number;
  53002. clip?: number;
  53003. arc?: number;
  53004. closed?: boolean;
  53005. updatable?: boolean;
  53006. sideOrientation?: number;
  53007. frontUVs?: Vector4;
  53008. backUVs?: Vector4;
  53009. cap?: number;
  53010. invertUV?: boolean;
  53011. }, scene?: Nullable<Scene>): Mesh;
  53012. /**
  53013. * Creates a plane mesh
  53014. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53015. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53016. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53020. * @param name defines the name of the mesh
  53021. * @param options defines the options used to create the mesh
  53022. * @param scene defines the hosting scene
  53023. * @returns the plane mesh
  53024. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53025. */
  53026. static CreatePlane(name: string, options: {
  53027. size?: number;
  53028. width?: number;
  53029. height?: number;
  53030. sideOrientation?: number;
  53031. frontUVs?: Vector4;
  53032. backUVs?: Vector4;
  53033. updatable?: boolean;
  53034. sourcePlane?: Plane;
  53035. }, scene?: Nullable<Scene>): Mesh;
  53036. /**
  53037. * Creates a ground mesh
  53038. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53039. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53041. * @param name defines the name of the mesh
  53042. * @param options defines the options used to create the mesh
  53043. * @param scene defines the hosting scene
  53044. * @returns the ground mesh
  53045. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53046. */
  53047. static CreateGround(name: string, options: {
  53048. width?: number;
  53049. height?: number;
  53050. subdivisions?: number;
  53051. subdivisionsX?: number;
  53052. subdivisionsY?: number;
  53053. updatable?: boolean;
  53054. }, scene?: Nullable<Scene>): Mesh;
  53055. /**
  53056. * Creates a tiled ground mesh
  53057. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53058. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53059. * * 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
  53060. * * 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
  53061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53062. * @param name defines the name of the mesh
  53063. * @param options defines the options used to create the mesh
  53064. * @param scene defines the hosting scene
  53065. * @returns the tiled ground mesh
  53066. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53067. */
  53068. static CreateTiledGround(name: string, options: {
  53069. xmin: number;
  53070. zmin: number;
  53071. xmax: number;
  53072. zmax: number;
  53073. subdivisions?: {
  53074. w: number;
  53075. h: number;
  53076. };
  53077. precision?: {
  53078. w: number;
  53079. h: number;
  53080. };
  53081. updatable?: boolean;
  53082. }, scene?: Nullable<Scene>): Mesh;
  53083. /**
  53084. * Creates a ground mesh from a height map
  53085. * * The parameter `url` sets the URL of the height map image resource.
  53086. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53087. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53088. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53089. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53090. * * 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.
  53091. * * 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).
  53092. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53094. * @param name defines the name of the mesh
  53095. * @param url defines the url to the height map
  53096. * @param options defines the options used to create the mesh
  53097. * @param scene defines the hosting scene
  53098. * @returns the ground mesh
  53099. * @see https://doc.babylonjs.com/babylon101/height_map
  53100. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53101. */
  53102. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53103. width?: number;
  53104. height?: number;
  53105. subdivisions?: number;
  53106. minHeight?: number;
  53107. maxHeight?: number;
  53108. colorFilter?: Color3;
  53109. alphaFilter?: number;
  53110. updatable?: boolean;
  53111. onReady?: (mesh: GroundMesh) => void;
  53112. }, scene?: Nullable<Scene>): GroundMesh;
  53113. /**
  53114. * Creates a polygon mesh
  53115. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53116. * * 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
  53117. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53120. * * Remember you can only change the shape positions, not their number when updating a polygon
  53121. * @param name defines the name of the mesh
  53122. * @param options defines the options used to create the mesh
  53123. * @param scene defines the hosting scene
  53124. * @param earcutInjection can be used to inject your own earcut reference
  53125. * @returns the polygon mesh
  53126. */
  53127. static CreatePolygon(name: string, options: {
  53128. shape: Vector3[];
  53129. holes?: Vector3[][];
  53130. depth?: number;
  53131. faceUV?: Vector4[];
  53132. faceColors?: Color4[];
  53133. updatable?: boolean;
  53134. sideOrientation?: number;
  53135. frontUVs?: Vector4;
  53136. backUVs?: Vector4;
  53137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53138. /**
  53139. * Creates an extruded polygon mesh, with depth in the Y direction.
  53140. * * 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)
  53141. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53142. * @param name defines the name of the mesh
  53143. * @param options defines the options used to create the mesh
  53144. * @param scene defines the hosting scene
  53145. * @param earcutInjection can be used to inject your own earcut reference
  53146. * @returns the polygon mesh
  53147. */
  53148. static ExtrudePolygon(name: string, options: {
  53149. shape: Vector3[];
  53150. holes?: Vector3[][];
  53151. depth?: number;
  53152. faceUV?: Vector4[];
  53153. faceColors?: Color4[];
  53154. updatable?: boolean;
  53155. sideOrientation?: number;
  53156. frontUVs?: Vector4;
  53157. backUVs?: Vector4;
  53158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53159. /**
  53160. * Creates a tube mesh.
  53161. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53162. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53163. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53164. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53165. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53166. * * 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)
  53167. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53168. * * 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
  53169. * * 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
  53170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53174. * @param name defines the name of the mesh
  53175. * @param options defines the options used to create the mesh
  53176. * @param scene defines the hosting scene
  53177. * @returns the tube mesh
  53178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53179. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53180. */
  53181. static CreateTube(name: string, options: {
  53182. path: Vector3[];
  53183. radius?: number;
  53184. tessellation?: number;
  53185. radiusFunction?: {
  53186. (i: number, distance: number): number;
  53187. };
  53188. cap?: number;
  53189. arc?: number;
  53190. updatable?: boolean;
  53191. sideOrientation?: number;
  53192. frontUVs?: Vector4;
  53193. backUVs?: Vector4;
  53194. instance?: Mesh;
  53195. invertUV?: boolean;
  53196. }, scene?: Nullable<Scene>): Mesh;
  53197. /**
  53198. * Creates a polyhedron mesh
  53199. * * 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
  53200. * * The parameter `size` (positive float, default 1) sets the polygon size
  53201. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53202. * * 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`
  53203. * * 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
  53204. * * 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)`)
  53205. * * 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
  53206. * * 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
  53207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the polyhedron mesh
  53214. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53215. */
  53216. static CreatePolyhedron(name: string, options: {
  53217. type?: number;
  53218. size?: number;
  53219. sizeX?: number;
  53220. sizeY?: number;
  53221. sizeZ?: number;
  53222. custom?: any;
  53223. faceUV?: Vector4[];
  53224. faceColors?: Color4[];
  53225. flat?: boolean;
  53226. updatable?: boolean;
  53227. sideOrientation?: number;
  53228. frontUVs?: Vector4;
  53229. backUVs?: Vector4;
  53230. }, scene?: Nullable<Scene>): Mesh;
  53231. /**
  53232. * Creates a decal mesh.
  53233. * 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
  53234. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53235. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53236. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53237. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53238. * @param name defines the name of the mesh
  53239. * @param sourceMesh defines the mesh where the decal must be applied
  53240. * @param options defines the options used to create the mesh
  53241. * @param scene defines the hosting scene
  53242. * @returns the decal mesh
  53243. * @see https://doc.babylonjs.com/how_to/decals
  53244. */
  53245. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53246. position?: Vector3;
  53247. normal?: Vector3;
  53248. size?: Vector3;
  53249. angle?: number;
  53250. }): Mesh;
  53251. }
  53252. }
  53253. declare module "babylonjs/Meshes/meshSimplification" {
  53254. import { Mesh } from "babylonjs/Meshes/mesh";
  53255. /**
  53256. * A simplifier interface for future simplification implementations
  53257. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53258. */
  53259. export interface ISimplifier {
  53260. /**
  53261. * Simplification of a given mesh according to the given settings.
  53262. * Since this requires computation, it is assumed that the function runs async.
  53263. * @param settings The settings of the simplification, including quality and distance
  53264. * @param successCallback A callback that will be called after the mesh was simplified.
  53265. * @param errorCallback in case of an error, this callback will be called. optional.
  53266. */
  53267. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53268. }
  53269. /**
  53270. * Expected simplification settings.
  53271. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53272. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53273. */
  53274. export interface ISimplificationSettings {
  53275. /**
  53276. * Gets or sets the expected quality
  53277. */
  53278. quality: number;
  53279. /**
  53280. * Gets or sets the distance when this optimized version should be used
  53281. */
  53282. distance: number;
  53283. /**
  53284. * Gets an already optimized mesh
  53285. */
  53286. optimizeMesh?: boolean;
  53287. }
  53288. /**
  53289. * Class used to specify simplification options
  53290. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53291. */
  53292. export class SimplificationSettings implements ISimplificationSettings {
  53293. /** expected quality */
  53294. quality: number;
  53295. /** distance when this optimized version should be used */
  53296. distance: number;
  53297. /** already optimized mesh */
  53298. optimizeMesh?: boolean | undefined;
  53299. /**
  53300. * Creates a SimplificationSettings
  53301. * @param quality expected quality
  53302. * @param distance distance when this optimized version should be used
  53303. * @param optimizeMesh already optimized mesh
  53304. */
  53305. constructor(
  53306. /** expected quality */
  53307. quality: number,
  53308. /** distance when this optimized version should be used */
  53309. distance: number,
  53310. /** already optimized mesh */
  53311. optimizeMesh?: boolean | undefined);
  53312. }
  53313. /**
  53314. * Interface used to define a simplification task
  53315. */
  53316. export interface ISimplificationTask {
  53317. /**
  53318. * Array of settings
  53319. */
  53320. settings: Array<ISimplificationSettings>;
  53321. /**
  53322. * Simplification type
  53323. */
  53324. simplificationType: SimplificationType;
  53325. /**
  53326. * Mesh to simplify
  53327. */
  53328. mesh: Mesh;
  53329. /**
  53330. * Callback called on success
  53331. */
  53332. successCallback?: () => void;
  53333. /**
  53334. * Defines if parallel processing can be used
  53335. */
  53336. parallelProcessing: boolean;
  53337. }
  53338. /**
  53339. * Queue used to order the simplification tasks
  53340. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53341. */
  53342. export class SimplificationQueue {
  53343. private _simplificationArray;
  53344. /**
  53345. * Gets a boolean indicating that the process is still running
  53346. */
  53347. running: boolean;
  53348. /**
  53349. * Creates a new queue
  53350. */
  53351. constructor();
  53352. /**
  53353. * Adds a new simplification task
  53354. * @param task defines a task to add
  53355. */
  53356. addTask(task: ISimplificationTask): void;
  53357. /**
  53358. * Execute next task
  53359. */
  53360. executeNext(): void;
  53361. /**
  53362. * Execute a simplification task
  53363. * @param task defines the task to run
  53364. */
  53365. runSimplification(task: ISimplificationTask): void;
  53366. private getSimplifier;
  53367. }
  53368. /**
  53369. * The implemented types of simplification
  53370. * At the moment only Quadratic Error Decimation is implemented
  53371. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53372. */
  53373. export enum SimplificationType {
  53374. /** Quadratic error decimation */
  53375. QUADRATIC = 0
  53376. }
  53377. }
  53378. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53379. import { Scene } from "babylonjs/scene";
  53380. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53381. import { ISceneComponent } from "babylonjs/sceneComponent";
  53382. module "babylonjs/scene" {
  53383. interface Scene {
  53384. /** @hidden (Backing field) */
  53385. _simplificationQueue: SimplificationQueue;
  53386. /**
  53387. * Gets or sets the simplification queue attached to the scene
  53388. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53389. */
  53390. simplificationQueue: SimplificationQueue;
  53391. }
  53392. }
  53393. module "babylonjs/Meshes/mesh" {
  53394. interface Mesh {
  53395. /**
  53396. * Simplify the mesh according to the given array of settings.
  53397. * Function will return immediately and will simplify async
  53398. * @param settings a collection of simplification settings
  53399. * @param parallelProcessing should all levels calculate parallel or one after the other
  53400. * @param simplificationType the type of simplification to run
  53401. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53402. * @returns the current mesh
  53403. */
  53404. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53405. }
  53406. }
  53407. /**
  53408. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53409. * created in a scene
  53410. */
  53411. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53412. /**
  53413. * The component name helpfull to identify the component in the list of scene components.
  53414. */
  53415. readonly name: string;
  53416. /**
  53417. * The scene the component belongs to.
  53418. */
  53419. scene: Scene;
  53420. /**
  53421. * Creates a new instance of the component for the given scene
  53422. * @param scene Defines the scene to register the component in
  53423. */
  53424. constructor(scene: Scene);
  53425. /**
  53426. * Registers the component in a given scene
  53427. */
  53428. register(): void;
  53429. /**
  53430. * Rebuilds the elements related to this component in case of
  53431. * context lost for instance.
  53432. */
  53433. rebuild(): void;
  53434. /**
  53435. * Disposes the component and the associated ressources
  53436. */
  53437. dispose(): void;
  53438. private _beforeCameraUpdate;
  53439. }
  53440. }
  53441. declare module "babylonjs/Meshes/Builders/index" {
  53442. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53443. export * from "babylonjs/Meshes/Builders/discBuilder";
  53444. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53445. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53446. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53447. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53448. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53449. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53450. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53451. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53452. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53453. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53454. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53455. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53456. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53457. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53458. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53459. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53460. }
  53461. declare module "babylonjs/Meshes/index" {
  53462. export * from "babylonjs/Meshes/abstractMesh";
  53463. export * from "babylonjs/Meshes/buffer";
  53464. export * from "babylonjs/Meshes/Compression/index";
  53465. export * from "babylonjs/Meshes/csg";
  53466. export * from "babylonjs/Meshes/geometry";
  53467. export * from "babylonjs/Meshes/groundMesh";
  53468. export * from "babylonjs/Meshes/trailMesh";
  53469. export * from "babylonjs/Meshes/instancedMesh";
  53470. export * from "babylonjs/Meshes/linesMesh";
  53471. export * from "babylonjs/Meshes/mesh";
  53472. export * from "babylonjs/Meshes/mesh.vertexData";
  53473. export * from "babylonjs/Meshes/meshBuilder";
  53474. export * from "babylonjs/Meshes/meshSimplification";
  53475. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53476. export * from "babylonjs/Meshes/polygonMesh";
  53477. export * from "babylonjs/Meshes/subMesh";
  53478. export * from "babylonjs/Meshes/meshLODLevel";
  53479. export * from "babylonjs/Meshes/transformNode";
  53480. export * from "babylonjs/Meshes/Builders/index";
  53481. export * from "babylonjs/Meshes/dataBuffer";
  53482. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53483. }
  53484. declare module "babylonjs/Morph/index" {
  53485. export * from "babylonjs/Morph/morphTarget";
  53486. export * from "babylonjs/Morph/morphTargetManager";
  53487. }
  53488. declare module "babylonjs/Offline/database" {
  53489. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53490. /**
  53491. * Class used to enable access to IndexedDB
  53492. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53493. */
  53494. export class Database implements IOfflineProvider {
  53495. private _callbackManifestChecked;
  53496. private _currentSceneUrl;
  53497. private _db;
  53498. private _enableSceneOffline;
  53499. private _enableTexturesOffline;
  53500. private _manifestVersionFound;
  53501. private _mustUpdateRessources;
  53502. private _hasReachedQuota;
  53503. private _isSupported;
  53504. private _idbFactory;
  53505. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53506. private static IsUASupportingBlobStorage;
  53507. /**
  53508. * Gets a boolean indicating if Database storate is enabled (off by default)
  53509. */
  53510. static IDBStorageEnabled: boolean;
  53511. /**
  53512. * Gets a boolean indicating if scene must be saved in the database
  53513. */
  53514. readonly enableSceneOffline: boolean;
  53515. /**
  53516. * Gets a boolean indicating if textures must be saved in the database
  53517. */
  53518. readonly enableTexturesOffline: boolean;
  53519. /**
  53520. * Creates a new Database
  53521. * @param urlToScene defines the url to load the scene
  53522. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53523. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53524. */
  53525. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53526. private static _ParseURL;
  53527. private static _ReturnFullUrlLocation;
  53528. private _checkManifestFile;
  53529. /**
  53530. * Open the database and make it available
  53531. * @param successCallback defines the callback to call on success
  53532. * @param errorCallback defines the callback to call on error
  53533. */
  53534. open(successCallback: () => void, errorCallback: () => void): void;
  53535. /**
  53536. * Loads an image from the database
  53537. * @param url defines the url to load from
  53538. * @param image defines the target DOM image
  53539. */
  53540. loadImage(url: string, image: HTMLImageElement): void;
  53541. private _loadImageFromDBAsync;
  53542. private _saveImageIntoDBAsync;
  53543. private _checkVersionFromDB;
  53544. private _loadVersionFromDBAsync;
  53545. private _saveVersionIntoDBAsync;
  53546. /**
  53547. * Loads a file from database
  53548. * @param url defines the URL to load from
  53549. * @param sceneLoaded defines a callback to call on success
  53550. * @param progressCallBack defines a callback to call when progress changed
  53551. * @param errorCallback defines a callback to call on error
  53552. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53553. */
  53554. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53555. private _loadFileAsync;
  53556. private _saveFileAsync;
  53557. /**
  53558. * Validates if xhr data is correct
  53559. * @param xhr defines the request to validate
  53560. * @param dataType defines the expected data type
  53561. * @returns true if data is correct
  53562. */
  53563. private static _ValidateXHRData;
  53564. }
  53565. }
  53566. declare module "babylonjs/Offline/index" {
  53567. export * from "babylonjs/Offline/database";
  53568. export * from "babylonjs/Offline/IOfflineProvider";
  53569. }
  53570. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53571. /** @hidden */
  53572. export var gpuUpdateParticlesPixelShader: {
  53573. name: string;
  53574. shader: string;
  53575. };
  53576. }
  53577. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53578. /** @hidden */
  53579. export var gpuUpdateParticlesVertexShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53585. /** @hidden */
  53586. export var clipPlaneFragmentDeclaration2: {
  53587. name: string;
  53588. shader: string;
  53589. };
  53590. }
  53591. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53592. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53593. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53594. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53595. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53597. /** @hidden */
  53598. export var gpuRenderParticlesPixelShader: {
  53599. name: string;
  53600. shader: string;
  53601. };
  53602. }
  53603. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53604. /** @hidden */
  53605. export var clipPlaneVertexDeclaration2: {
  53606. name: string;
  53607. shader: string;
  53608. };
  53609. }
  53610. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53611. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53612. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53613. /** @hidden */
  53614. export var gpuRenderParticlesVertexShader: {
  53615. name: string;
  53616. shader: string;
  53617. };
  53618. }
  53619. declare module "babylonjs/Particles/gpuParticleSystem" {
  53620. import { Nullable } from "babylonjs/types";
  53621. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53622. import { Observable } from "babylonjs/Misc/observable";
  53623. import { Color4, Color3 } from "babylonjs/Maths/math";
  53624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53625. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53626. import { Scene, IDisposable } from "babylonjs/scene";
  53627. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53628. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53629. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53630. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53631. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53632. /**
  53633. * This represents a GPU particle system in Babylon
  53634. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53635. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53636. */
  53637. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53638. /**
  53639. * The layer mask we are rendering the particles through.
  53640. */
  53641. layerMask: number;
  53642. private _capacity;
  53643. private _activeCount;
  53644. private _currentActiveCount;
  53645. private _accumulatedCount;
  53646. private _renderEffect;
  53647. private _updateEffect;
  53648. private _buffer0;
  53649. private _buffer1;
  53650. private _spriteBuffer;
  53651. private _updateVAO;
  53652. private _renderVAO;
  53653. private _targetIndex;
  53654. private _sourceBuffer;
  53655. private _targetBuffer;
  53656. private _engine;
  53657. private _currentRenderId;
  53658. private _started;
  53659. private _stopped;
  53660. private _timeDelta;
  53661. private _randomTexture;
  53662. private _randomTexture2;
  53663. private _attributesStrideSize;
  53664. private _updateEffectOptions;
  53665. private _randomTextureSize;
  53666. private _actualFrame;
  53667. private readonly _rawTextureWidth;
  53668. /**
  53669. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53670. */
  53671. static readonly IsSupported: boolean;
  53672. /**
  53673. * An event triggered when the system is disposed.
  53674. */
  53675. onDisposeObservable: Observable<GPUParticleSystem>;
  53676. /**
  53677. * Gets the maximum number of particles active at the same time.
  53678. * @returns The max number of active particles.
  53679. */
  53680. getCapacity(): number;
  53681. /**
  53682. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53683. * to override the particles.
  53684. */
  53685. forceDepthWrite: boolean;
  53686. /**
  53687. * Gets or set the number of active particles
  53688. */
  53689. activeParticleCount: number;
  53690. private _preWarmDone;
  53691. /**
  53692. * Is this system ready to be used/rendered
  53693. * @return true if the system is ready
  53694. */
  53695. isReady(): boolean;
  53696. /**
  53697. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53698. * @returns True if it has been started, otherwise false.
  53699. */
  53700. isStarted(): boolean;
  53701. /**
  53702. * Starts the particle system and begins to emit
  53703. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53704. */
  53705. start(delay?: number): void;
  53706. /**
  53707. * Stops the particle system.
  53708. */
  53709. stop(): void;
  53710. /**
  53711. * Remove all active particles
  53712. */
  53713. reset(): void;
  53714. /**
  53715. * Returns the string "GPUParticleSystem"
  53716. * @returns a string containing the class name
  53717. */
  53718. getClassName(): string;
  53719. private _colorGradientsTexture;
  53720. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53721. /**
  53722. * Adds a new color gradient
  53723. * @param gradient defines the gradient to use (between 0 and 1)
  53724. * @param color1 defines the color to affect to the specified gradient
  53725. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53726. * @returns the current particle system
  53727. */
  53728. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53729. /**
  53730. * Remove a specific color gradient
  53731. * @param gradient defines the gradient to remove
  53732. * @returns the current particle system
  53733. */
  53734. removeColorGradient(gradient: number): GPUParticleSystem;
  53735. private _angularSpeedGradientsTexture;
  53736. private _sizeGradientsTexture;
  53737. private _velocityGradientsTexture;
  53738. private _limitVelocityGradientsTexture;
  53739. private _dragGradientsTexture;
  53740. private _addFactorGradient;
  53741. /**
  53742. * Adds a new size gradient
  53743. * @param gradient defines the gradient to use (between 0 and 1)
  53744. * @param factor defines the size factor to affect to the specified gradient
  53745. * @returns the current particle system
  53746. */
  53747. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53748. /**
  53749. * Remove a specific size gradient
  53750. * @param gradient defines the gradient to remove
  53751. * @returns the current particle system
  53752. */
  53753. removeSizeGradient(gradient: number): GPUParticleSystem;
  53754. /**
  53755. * Adds a new angular speed gradient
  53756. * @param gradient defines the gradient to use (between 0 and 1)
  53757. * @param factor defines the angular speed to affect to the specified gradient
  53758. * @returns the current particle system
  53759. */
  53760. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53761. /**
  53762. * Remove a specific angular speed gradient
  53763. * @param gradient defines the gradient to remove
  53764. * @returns the current particle system
  53765. */
  53766. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53767. /**
  53768. * Adds a new velocity gradient
  53769. * @param gradient defines the gradient to use (between 0 and 1)
  53770. * @param factor defines the velocity to affect to the specified gradient
  53771. * @returns the current particle system
  53772. */
  53773. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53774. /**
  53775. * Remove a specific velocity gradient
  53776. * @param gradient defines the gradient to remove
  53777. * @returns the current particle system
  53778. */
  53779. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53780. /**
  53781. * Adds a new limit velocity gradient
  53782. * @param gradient defines the gradient to use (between 0 and 1)
  53783. * @param factor defines the limit velocity value to affect to the specified gradient
  53784. * @returns the current particle system
  53785. */
  53786. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53787. /**
  53788. * Remove a specific limit velocity gradient
  53789. * @param gradient defines the gradient to remove
  53790. * @returns the current particle system
  53791. */
  53792. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53793. /**
  53794. * Adds a new drag gradient
  53795. * @param gradient defines the gradient to use (between 0 and 1)
  53796. * @param factor defines the drag value to affect to the specified gradient
  53797. * @returns the current particle system
  53798. */
  53799. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53800. /**
  53801. * Remove a specific drag gradient
  53802. * @param gradient defines the gradient to remove
  53803. * @returns the current particle system
  53804. */
  53805. removeDragGradient(gradient: number): GPUParticleSystem;
  53806. /**
  53807. * Not supported by GPUParticleSystem
  53808. * @param gradient defines the gradient to use (between 0 and 1)
  53809. * @param factor defines the emit rate value to affect to the specified gradient
  53810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53811. * @returns the current particle system
  53812. */
  53813. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53814. /**
  53815. * Not supported by GPUParticleSystem
  53816. * @param gradient defines the gradient to remove
  53817. * @returns the current particle system
  53818. */
  53819. removeEmitRateGradient(gradient: number): IParticleSystem;
  53820. /**
  53821. * Not supported by GPUParticleSystem
  53822. * @param gradient defines the gradient to use (between 0 and 1)
  53823. * @param factor defines the start size value to affect to the specified gradient
  53824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53825. * @returns the current particle system
  53826. */
  53827. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53828. /**
  53829. * Not supported by GPUParticleSystem
  53830. * @param gradient defines the gradient to remove
  53831. * @returns the current particle system
  53832. */
  53833. removeStartSizeGradient(gradient: number): IParticleSystem;
  53834. /**
  53835. * Not supported by GPUParticleSystem
  53836. * @param gradient defines the gradient to use (between 0 and 1)
  53837. * @param min defines the color remap minimal range
  53838. * @param max defines the color remap maximal range
  53839. * @returns the current particle system
  53840. */
  53841. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53842. /**
  53843. * Not supported by GPUParticleSystem
  53844. * @param gradient defines the gradient to remove
  53845. * @returns the current particle system
  53846. */
  53847. removeColorRemapGradient(): IParticleSystem;
  53848. /**
  53849. * Not supported by GPUParticleSystem
  53850. * @param gradient defines the gradient to use (between 0 and 1)
  53851. * @param min defines the alpha remap minimal range
  53852. * @param max defines the alpha remap maximal range
  53853. * @returns the current particle system
  53854. */
  53855. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53856. /**
  53857. * Not supported by GPUParticleSystem
  53858. * @param gradient defines the gradient to remove
  53859. * @returns the current particle system
  53860. */
  53861. removeAlphaRemapGradient(): IParticleSystem;
  53862. /**
  53863. * Not supported by GPUParticleSystem
  53864. * @param gradient defines the gradient to use (between 0 and 1)
  53865. * @param color defines the color to affect to the specified gradient
  53866. * @returns the current particle system
  53867. */
  53868. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53869. /**
  53870. * Not supported by GPUParticleSystem
  53871. * @param gradient defines the gradient to remove
  53872. * @returns the current particle system
  53873. */
  53874. removeRampGradient(): IParticleSystem;
  53875. /**
  53876. * Not supported by GPUParticleSystem
  53877. * @returns the list of ramp gradients
  53878. */
  53879. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53880. /**
  53881. * Not supported by GPUParticleSystem
  53882. * Gets or sets a boolean indicating that ramp gradients must be used
  53883. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53884. */
  53885. useRampGradients: boolean;
  53886. /**
  53887. * Not supported by GPUParticleSystem
  53888. * @param gradient defines the gradient to use (between 0 and 1)
  53889. * @param factor defines the life time factor to affect to the specified gradient
  53890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53891. * @returns the current particle system
  53892. */
  53893. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53894. /**
  53895. * Not supported by GPUParticleSystem
  53896. * @param gradient defines the gradient to remove
  53897. * @returns the current particle system
  53898. */
  53899. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53900. /**
  53901. * Instantiates a GPU particle system.
  53902. * 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.
  53903. * @param name The name of the particle system
  53904. * @param options The options used to create the system
  53905. * @param scene The scene the particle system belongs to
  53906. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53907. */
  53908. constructor(name: string, options: Partial<{
  53909. capacity: number;
  53910. randomTextureSize: number;
  53911. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53912. protected _reset(): void;
  53913. private _createUpdateVAO;
  53914. private _createRenderVAO;
  53915. private _initialize;
  53916. /** @hidden */
  53917. _recreateUpdateEffect(): void;
  53918. /** @hidden */
  53919. _recreateRenderEffect(): void;
  53920. /**
  53921. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53922. * @param preWarm defines if we are in the pre-warmimg phase
  53923. */
  53924. animate(preWarm?: boolean): void;
  53925. private _createFactorGradientTexture;
  53926. private _createSizeGradientTexture;
  53927. private _createAngularSpeedGradientTexture;
  53928. private _createVelocityGradientTexture;
  53929. private _createLimitVelocityGradientTexture;
  53930. private _createDragGradientTexture;
  53931. private _createColorGradientTexture;
  53932. /**
  53933. * Renders the particle system in its current state
  53934. * @param preWarm defines if the system should only update the particles but not render them
  53935. * @returns the current number of particles
  53936. */
  53937. render(preWarm?: boolean): number;
  53938. /**
  53939. * Rebuilds the particle system
  53940. */
  53941. rebuild(): void;
  53942. private _releaseBuffers;
  53943. private _releaseVAOs;
  53944. /**
  53945. * Disposes the particle system and free the associated resources
  53946. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53947. */
  53948. dispose(disposeTexture?: boolean): void;
  53949. /**
  53950. * Clones the particle system.
  53951. * @param name The name of the cloned object
  53952. * @param newEmitter The new emitter to use
  53953. * @returns the cloned particle system
  53954. */
  53955. clone(name: string, newEmitter: any): GPUParticleSystem;
  53956. /**
  53957. * Serializes the particle system to a JSON object.
  53958. * @returns the JSON object
  53959. */
  53960. serialize(): any;
  53961. /**
  53962. * Parses a JSON object to create a GPU particle system.
  53963. * @param parsedParticleSystem The JSON object to parse
  53964. * @param scene The scene to create the particle system in
  53965. * @param rootUrl The root url to use to load external dependencies like texture
  53966. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53967. * @returns the parsed GPU particle system
  53968. */
  53969. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53970. }
  53971. }
  53972. declare module "babylonjs/Particles/particleSystemSet" {
  53973. import { Nullable } from "babylonjs/types";
  53974. import { Color3 } from "babylonjs/Maths/math";
  53975. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53977. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53978. import { Scene, IDisposable } from "babylonjs/scene";
  53979. /**
  53980. * Represents a set of particle systems working together to create a specific effect
  53981. */
  53982. export class ParticleSystemSet implements IDisposable {
  53983. private _emitterCreationOptions;
  53984. private _emitterNode;
  53985. /**
  53986. * Gets the particle system list
  53987. */
  53988. systems: IParticleSystem[];
  53989. /**
  53990. * Gets the emitter node used with this set
  53991. */
  53992. readonly emitterNode: Nullable<TransformNode>;
  53993. /**
  53994. * Creates a new emitter mesh as a sphere
  53995. * @param options defines the options used to create the sphere
  53996. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53997. * @param scene defines the hosting scene
  53998. */
  53999. setEmitterAsSphere(options: {
  54000. diameter: number;
  54001. segments: number;
  54002. color: Color3;
  54003. }, renderingGroupId: number, scene: Scene): void;
  54004. /**
  54005. * Starts all particle systems of the set
  54006. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54007. */
  54008. start(emitter?: AbstractMesh): void;
  54009. /**
  54010. * Release all associated resources
  54011. */
  54012. dispose(): void;
  54013. /**
  54014. * Serialize the set into a JSON compatible object
  54015. * @returns a JSON compatible representation of the set
  54016. */
  54017. serialize(): any;
  54018. /**
  54019. * Parse a new ParticleSystemSet from a serialized source
  54020. * @param data defines a JSON compatible representation of the set
  54021. * @param scene defines the hosting scene
  54022. * @param gpu defines if we want GPU particles or CPU particles
  54023. * @returns a new ParticleSystemSet
  54024. */
  54025. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54026. }
  54027. }
  54028. declare module "babylonjs/Particles/particleHelper" {
  54029. import { Nullable } from "babylonjs/types";
  54030. import { Scene } from "babylonjs/scene";
  54031. import { Vector3 } from "babylonjs/Maths/math";
  54032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54033. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54034. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54035. /**
  54036. * This class is made for on one-liner static method to help creating particle system set.
  54037. */
  54038. export class ParticleHelper {
  54039. /**
  54040. * Gets or sets base Assets URL
  54041. */
  54042. static BaseAssetsUrl: string;
  54043. /**
  54044. * Create a default particle system that you can tweak
  54045. * @param emitter defines the emitter to use
  54046. * @param capacity defines the system capacity (default is 500 particles)
  54047. * @param scene defines the hosting scene
  54048. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54049. * @returns the new Particle system
  54050. */
  54051. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54052. /**
  54053. * This is the main static method (one-liner) of this helper to create different particle systems
  54054. * @param type This string represents the type to the particle system to create
  54055. * @param scene The scene where the particle system should live
  54056. * @param gpu If the system will use gpu
  54057. * @returns the ParticleSystemSet created
  54058. */
  54059. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54060. /**
  54061. * Static function used to export a particle system to a ParticleSystemSet variable.
  54062. * Please note that the emitter shape is not exported
  54063. * @param systems defines the particle systems to export
  54064. * @returns the created particle system set
  54065. */
  54066. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54067. }
  54068. }
  54069. declare module "babylonjs/Particles/particleSystemComponent" {
  54070. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54071. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54072. import "babylonjs/Shaders/particles.vertex";
  54073. module "babylonjs/Engines/engine" {
  54074. interface Engine {
  54075. /**
  54076. * Create an effect to use with particle systems.
  54077. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54078. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54079. * @param uniformsNames defines a list of attribute names
  54080. * @param samplers defines an array of string used to represent textures
  54081. * @param defines defines the string containing the defines to use to compile the shaders
  54082. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54083. * @param onCompiled defines a function to call when the effect creation is successful
  54084. * @param onError defines a function to call when the effect creation has failed
  54085. * @returns the new Effect
  54086. */
  54087. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54088. }
  54089. }
  54090. module "babylonjs/Meshes/mesh" {
  54091. interface Mesh {
  54092. /**
  54093. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54094. * @returns an array of IParticleSystem
  54095. */
  54096. getEmittedParticleSystems(): IParticleSystem[];
  54097. /**
  54098. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54099. * @returns an array of IParticleSystem
  54100. */
  54101. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54102. }
  54103. }
  54104. /**
  54105. * @hidden
  54106. */
  54107. export var _IDoNeedToBeInTheBuild: number;
  54108. }
  54109. declare module "babylonjs/Particles/index" {
  54110. export * from "babylonjs/Particles/baseParticleSystem";
  54111. export * from "babylonjs/Particles/EmitterTypes/index";
  54112. export * from "babylonjs/Particles/gpuParticleSystem";
  54113. export * from "babylonjs/Particles/IParticleSystem";
  54114. export * from "babylonjs/Particles/particle";
  54115. export * from "babylonjs/Particles/particleHelper";
  54116. export * from "babylonjs/Particles/particleSystem";
  54117. export * from "babylonjs/Particles/particleSystemComponent";
  54118. export * from "babylonjs/Particles/particleSystemSet";
  54119. export * from "babylonjs/Particles/solidParticle";
  54120. export * from "babylonjs/Particles/solidParticleSystem";
  54121. export * from "babylonjs/Particles/subEmitter";
  54122. }
  54123. declare module "babylonjs/Physics/physicsEngineComponent" {
  54124. import { Nullable } from "babylonjs/types";
  54125. import { Observable, Observer } from "babylonjs/Misc/observable";
  54126. import { Vector3 } from "babylonjs/Maths/math";
  54127. import { Mesh } from "babylonjs/Meshes/mesh";
  54128. import { ISceneComponent } from "babylonjs/sceneComponent";
  54129. import { Scene } from "babylonjs/scene";
  54130. import { Node } from "babylonjs/node";
  54131. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54132. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54133. module "babylonjs/scene" {
  54134. interface Scene {
  54135. /** @hidden (Backing field) */
  54136. _physicsEngine: Nullable<IPhysicsEngine>;
  54137. /**
  54138. * Gets the current physics engine
  54139. * @returns a IPhysicsEngine or null if none attached
  54140. */
  54141. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54142. /**
  54143. * Enables physics to the current scene
  54144. * @param gravity defines the scene's gravity for the physics engine
  54145. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54146. * @return a boolean indicating if the physics engine was initialized
  54147. */
  54148. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54149. /**
  54150. * Disables and disposes the physics engine associated with the scene
  54151. */
  54152. disablePhysicsEngine(): void;
  54153. /**
  54154. * Gets a boolean indicating if there is an active physics engine
  54155. * @returns a boolean indicating if there is an active physics engine
  54156. */
  54157. isPhysicsEnabled(): boolean;
  54158. /**
  54159. * Deletes a physics compound impostor
  54160. * @param compound defines the compound to delete
  54161. */
  54162. deleteCompoundImpostor(compound: any): void;
  54163. /**
  54164. * An event triggered when physic simulation is about to be run
  54165. */
  54166. onBeforePhysicsObservable: Observable<Scene>;
  54167. /**
  54168. * An event triggered when physic simulation has been done
  54169. */
  54170. onAfterPhysicsObservable: Observable<Scene>;
  54171. }
  54172. }
  54173. module "babylonjs/Meshes/abstractMesh" {
  54174. interface AbstractMesh {
  54175. /** @hidden */
  54176. _physicsImpostor: Nullable<PhysicsImpostor>;
  54177. /**
  54178. * Gets or sets impostor used for physic simulation
  54179. * @see http://doc.babylonjs.com/features/physics_engine
  54180. */
  54181. physicsImpostor: Nullable<PhysicsImpostor>;
  54182. /**
  54183. * Gets the current physics impostor
  54184. * @see http://doc.babylonjs.com/features/physics_engine
  54185. * @returns a physics impostor or null
  54186. */
  54187. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54188. /** Apply a physic impulse to the mesh
  54189. * @param force defines the force to apply
  54190. * @param contactPoint defines where to apply the force
  54191. * @returns the current mesh
  54192. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54193. */
  54194. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54195. /**
  54196. * Creates a physic joint between two meshes
  54197. * @param otherMesh defines the other mesh to use
  54198. * @param pivot1 defines the pivot to use on this mesh
  54199. * @param pivot2 defines the pivot to use on the other mesh
  54200. * @param options defines additional options (can be plugin dependent)
  54201. * @returns the current mesh
  54202. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54203. */
  54204. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54205. /** @hidden */
  54206. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54207. }
  54208. }
  54209. /**
  54210. * Defines the physics engine scene component responsible to manage a physics engine
  54211. */
  54212. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54213. /**
  54214. * The component name helpful to identify the component in the list of scene components.
  54215. */
  54216. readonly name: string;
  54217. /**
  54218. * The scene the component belongs to.
  54219. */
  54220. scene: Scene;
  54221. /**
  54222. * Creates a new instance of the component for the given scene
  54223. * @param scene Defines the scene to register the component in
  54224. */
  54225. constructor(scene: Scene);
  54226. /**
  54227. * Registers the component in a given scene
  54228. */
  54229. register(): void;
  54230. /**
  54231. * Rebuilds the elements related to this component in case of
  54232. * context lost for instance.
  54233. */
  54234. rebuild(): void;
  54235. /**
  54236. * Disposes the component and the associated ressources
  54237. */
  54238. dispose(): void;
  54239. }
  54240. }
  54241. declare module "babylonjs/Physics/physicsHelper" {
  54242. import { Nullable } from "babylonjs/types";
  54243. import { Vector3 } from "babylonjs/Maths/math";
  54244. import { Mesh } from "babylonjs/Meshes/mesh";
  54245. import { Scene } from "babylonjs/scene";
  54246. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54247. /**
  54248. * A helper for physics simulations
  54249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54250. */
  54251. export class PhysicsHelper {
  54252. private _scene;
  54253. private _physicsEngine;
  54254. /**
  54255. * Initializes the Physics helper
  54256. * @param scene Babylon.js scene
  54257. */
  54258. constructor(scene: Scene);
  54259. /**
  54260. * Applies a radial explosion impulse
  54261. * @param origin the origin of the explosion
  54262. * @param radiusOrEventOptions the radius or the options of radial explosion
  54263. * @param strength the explosion strength
  54264. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54265. * @returns A physics radial explosion event, or null
  54266. */
  54267. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54268. /**
  54269. * Applies a radial explosion force
  54270. * @param origin the origin of the explosion
  54271. * @param radiusOrEventOptions the radius or the options of radial explosion
  54272. * @param strength the explosion strength
  54273. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54274. * @returns A physics radial explosion event, or null
  54275. */
  54276. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54277. /**
  54278. * Creates a gravitational field
  54279. * @param origin the origin of the explosion
  54280. * @param radiusOrEventOptions the radius or the options of radial explosion
  54281. * @param strength the explosion strength
  54282. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54283. * @returns A physics gravitational field event, or null
  54284. */
  54285. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54286. /**
  54287. * Creates a physics updraft event
  54288. * @param origin the origin of the updraft
  54289. * @param radiusOrEventOptions the radius or the options of the updraft
  54290. * @param strength the strength of the updraft
  54291. * @param height the height of the updraft
  54292. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54293. * @returns A physics updraft event, or null
  54294. */
  54295. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54296. /**
  54297. * Creates a physics vortex event
  54298. * @param origin the of the vortex
  54299. * @param radiusOrEventOptions the radius or the options of the vortex
  54300. * @param strength the strength of the vortex
  54301. * @param height the height of the vortex
  54302. * @returns a Physics vortex event, or null
  54303. * A physics vortex event or null
  54304. */
  54305. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54306. }
  54307. /**
  54308. * Represents a physics radial explosion event
  54309. */
  54310. class PhysicsRadialExplosionEvent {
  54311. private _scene;
  54312. private _options;
  54313. private _sphere;
  54314. private _dataFetched;
  54315. /**
  54316. * Initializes a radial explosioin event
  54317. * @param _scene BabylonJS scene
  54318. * @param _options The options for the vortex event
  54319. */
  54320. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54321. /**
  54322. * Returns the data related to the radial explosion event (sphere).
  54323. * @returns The radial explosion event data
  54324. */
  54325. getData(): PhysicsRadialExplosionEventData;
  54326. /**
  54327. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54328. * @param impostor A physics imposter
  54329. * @param origin the origin of the explosion
  54330. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54331. */
  54332. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54333. /**
  54334. * Triggers affecterd impostors callbacks
  54335. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54336. */
  54337. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54338. /**
  54339. * Disposes the sphere.
  54340. * @param force Specifies if the sphere should be disposed by force
  54341. */
  54342. dispose(force?: boolean): void;
  54343. /*** Helpers ***/
  54344. private _prepareSphere;
  54345. private _intersectsWithSphere;
  54346. }
  54347. /**
  54348. * Represents a gravitational field event
  54349. */
  54350. class PhysicsGravitationalFieldEvent {
  54351. private _physicsHelper;
  54352. private _scene;
  54353. private _origin;
  54354. private _options;
  54355. private _tickCallback;
  54356. private _sphere;
  54357. private _dataFetched;
  54358. /**
  54359. * Initializes the physics gravitational field event
  54360. * @param _physicsHelper A physics helper
  54361. * @param _scene BabylonJS scene
  54362. * @param _origin The origin position of the gravitational field event
  54363. * @param _options The options for the vortex event
  54364. */
  54365. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54366. /**
  54367. * Returns the data related to the gravitational field event (sphere).
  54368. * @returns A gravitational field event
  54369. */
  54370. getData(): PhysicsGravitationalFieldEventData;
  54371. /**
  54372. * Enables the gravitational field.
  54373. */
  54374. enable(): void;
  54375. /**
  54376. * Disables the gravitational field.
  54377. */
  54378. disable(): void;
  54379. /**
  54380. * Disposes the sphere.
  54381. * @param force The force to dispose from the gravitational field event
  54382. */
  54383. dispose(force?: boolean): void;
  54384. private _tick;
  54385. }
  54386. /**
  54387. * Represents a physics updraft event
  54388. */
  54389. class PhysicsUpdraftEvent {
  54390. private _scene;
  54391. private _origin;
  54392. private _options;
  54393. private _physicsEngine;
  54394. private _originTop;
  54395. private _originDirection;
  54396. private _tickCallback;
  54397. private _cylinder;
  54398. private _cylinderPosition;
  54399. private _dataFetched;
  54400. /**
  54401. * Initializes the physics updraft event
  54402. * @param _scene BabylonJS scene
  54403. * @param _origin The origin position of the updraft
  54404. * @param _options The options for the updraft event
  54405. */
  54406. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54407. /**
  54408. * Returns the data related to the updraft event (cylinder).
  54409. * @returns A physics updraft event
  54410. */
  54411. getData(): PhysicsUpdraftEventData;
  54412. /**
  54413. * Enables the updraft.
  54414. */
  54415. enable(): void;
  54416. /**
  54417. * Disables the updraft.
  54418. */
  54419. disable(): void;
  54420. /**
  54421. * Disposes the cylinder.
  54422. * @param force Specifies if the updraft should be disposed by force
  54423. */
  54424. dispose(force?: boolean): void;
  54425. private getImpostorHitData;
  54426. private _tick;
  54427. /*** Helpers ***/
  54428. private _prepareCylinder;
  54429. private _intersectsWithCylinder;
  54430. }
  54431. /**
  54432. * Represents a physics vortex event
  54433. */
  54434. class PhysicsVortexEvent {
  54435. private _scene;
  54436. private _origin;
  54437. private _options;
  54438. private _physicsEngine;
  54439. private _originTop;
  54440. private _tickCallback;
  54441. private _cylinder;
  54442. private _cylinderPosition;
  54443. private _dataFetched;
  54444. /**
  54445. * Initializes the physics vortex event
  54446. * @param _scene The BabylonJS scene
  54447. * @param _origin The origin position of the vortex
  54448. * @param _options The options for the vortex event
  54449. */
  54450. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54451. /**
  54452. * Returns the data related to the vortex event (cylinder).
  54453. * @returns The physics vortex event data
  54454. */
  54455. getData(): PhysicsVortexEventData;
  54456. /**
  54457. * Enables the vortex.
  54458. */
  54459. enable(): void;
  54460. /**
  54461. * Disables the cortex.
  54462. */
  54463. disable(): void;
  54464. /**
  54465. * Disposes the sphere.
  54466. * @param force
  54467. */
  54468. dispose(force?: boolean): void;
  54469. private getImpostorHitData;
  54470. private _tick;
  54471. /*** Helpers ***/
  54472. private _prepareCylinder;
  54473. private _intersectsWithCylinder;
  54474. }
  54475. /**
  54476. * Options fot the radial explosion event
  54477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54478. */
  54479. export class PhysicsRadialExplosionEventOptions {
  54480. /**
  54481. * The radius of the sphere for the radial explosion.
  54482. */
  54483. radius: number;
  54484. /**
  54485. * The strenth of the explosion.
  54486. */
  54487. strength: number;
  54488. /**
  54489. * The strenght of the force in correspondence to the distance of the affected object
  54490. */
  54491. falloff: PhysicsRadialImpulseFalloff;
  54492. /**
  54493. * Sphere options for the radial explosion.
  54494. */
  54495. sphere: {
  54496. segments: number;
  54497. diameter: number;
  54498. };
  54499. /**
  54500. * Sphere options for the radial explosion.
  54501. */
  54502. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54503. }
  54504. /**
  54505. * Options fot the updraft event
  54506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54507. */
  54508. export class PhysicsUpdraftEventOptions {
  54509. /**
  54510. * The radius of the cylinder for the vortex
  54511. */
  54512. radius: number;
  54513. /**
  54514. * The strenth of the updraft.
  54515. */
  54516. strength: number;
  54517. /**
  54518. * The height of the cylinder for the updraft.
  54519. */
  54520. height: number;
  54521. /**
  54522. * The mode for the the updraft.
  54523. */
  54524. updraftMode: PhysicsUpdraftMode;
  54525. }
  54526. /**
  54527. * Options fot the vortex event
  54528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54529. */
  54530. export class PhysicsVortexEventOptions {
  54531. /**
  54532. * The radius of the cylinder for the vortex
  54533. */
  54534. radius: number;
  54535. /**
  54536. * The strenth of the vortex.
  54537. */
  54538. strength: number;
  54539. /**
  54540. * The height of the cylinder for the vortex.
  54541. */
  54542. height: number;
  54543. /**
  54544. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54545. */
  54546. centripetalForceThreshold: number;
  54547. /**
  54548. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54549. */
  54550. centripetalForceMultiplier: number;
  54551. /**
  54552. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54553. */
  54554. centrifugalForceMultiplier: number;
  54555. /**
  54556. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54557. */
  54558. updraftForceMultiplier: number;
  54559. }
  54560. /**
  54561. * The strenght of the force in correspondence to the distance of the affected object
  54562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54563. */
  54564. export enum PhysicsRadialImpulseFalloff {
  54565. /** Defines that impulse is constant in strength across it's whole radius */
  54566. Constant = 0,
  54567. /** Defines that impulse gets weaker if it's further from the origin */
  54568. Linear = 1
  54569. }
  54570. /**
  54571. * The strength of the force in correspondence to the distance of the affected object
  54572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54573. */
  54574. export enum PhysicsUpdraftMode {
  54575. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54576. Center = 0,
  54577. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54578. Perpendicular = 1
  54579. }
  54580. /**
  54581. * Interface for a physics hit data
  54582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54583. */
  54584. export interface PhysicsHitData {
  54585. /**
  54586. * The force applied at the contact point
  54587. */
  54588. force: Vector3;
  54589. /**
  54590. * The contact point
  54591. */
  54592. contactPoint: Vector3;
  54593. /**
  54594. * The distance from the origin to the contact point
  54595. */
  54596. distanceFromOrigin: number;
  54597. }
  54598. /**
  54599. * Interface for radial explosion event data
  54600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54601. */
  54602. export interface PhysicsRadialExplosionEventData {
  54603. /**
  54604. * A sphere used for the radial explosion event
  54605. */
  54606. sphere: Mesh;
  54607. }
  54608. /**
  54609. * Interface for gravitational field event data
  54610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54611. */
  54612. export interface PhysicsGravitationalFieldEventData {
  54613. /**
  54614. * A sphere mesh used for the gravitational field event
  54615. */
  54616. sphere: Mesh;
  54617. }
  54618. /**
  54619. * Interface for updraft event data
  54620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54621. */
  54622. export interface PhysicsUpdraftEventData {
  54623. /**
  54624. * A cylinder used for the updraft event
  54625. */
  54626. cylinder: Mesh;
  54627. }
  54628. /**
  54629. * Interface for vortex event data
  54630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54631. */
  54632. export interface PhysicsVortexEventData {
  54633. /**
  54634. * A cylinder used for the vortex event
  54635. */
  54636. cylinder: Mesh;
  54637. }
  54638. /**
  54639. * Interface for an affected physics impostor
  54640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54641. */
  54642. export interface PhysicsAffectedImpostorWithData {
  54643. /**
  54644. * The impostor affected by the effect
  54645. */
  54646. impostor: PhysicsImpostor;
  54647. /**
  54648. * The data about the hit/horce from the explosion
  54649. */
  54650. hitData: PhysicsHitData;
  54651. }
  54652. }
  54653. declare module "babylonjs/Physics/Plugins/index" {
  54654. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54655. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54656. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54657. }
  54658. declare module "babylonjs/Physics/index" {
  54659. export * from "babylonjs/Physics/IPhysicsEngine";
  54660. export * from "babylonjs/Physics/physicsEngine";
  54661. export * from "babylonjs/Physics/physicsEngineComponent";
  54662. export * from "babylonjs/Physics/physicsHelper";
  54663. export * from "babylonjs/Physics/physicsImpostor";
  54664. export * from "babylonjs/Physics/physicsJoint";
  54665. export * from "babylonjs/Physics/Plugins/index";
  54666. }
  54667. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54668. /** @hidden */
  54669. export var blackAndWhitePixelShader: {
  54670. name: string;
  54671. shader: string;
  54672. };
  54673. }
  54674. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54675. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54676. import { Camera } from "babylonjs/Cameras/camera";
  54677. import { Engine } from "babylonjs/Engines/engine";
  54678. import "babylonjs/Shaders/blackAndWhite.fragment";
  54679. /**
  54680. * Post process used to render in black and white
  54681. */
  54682. export class BlackAndWhitePostProcess extends PostProcess {
  54683. /**
  54684. * Linear about to convert he result to black and white (default: 1)
  54685. */
  54686. degree: number;
  54687. /**
  54688. * Creates a black and white post process
  54689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54690. * @param name The name of the effect.
  54691. * @param options The required width/height ratio to downsize to before computing the render pass.
  54692. * @param camera The camera to apply the render pass to.
  54693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54694. * @param engine The engine which the post process will be applied. (default: current engine)
  54695. * @param reusable If the post process can be reused on the same frame. (default: false)
  54696. */
  54697. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54698. }
  54699. }
  54700. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54701. import { Nullable } from "babylonjs/types";
  54702. import { Camera } from "babylonjs/Cameras/camera";
  54703. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54704. import { Engine } from "babylonjs/Engines/engine";
  54705. /**
  54706. * This represents a set of one or more post processes in Babylon.
  54707. * A post process can be used to apply a shader to a texture after it is rendered.
  54708. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54709. */
  54710. export class PostProcessRenderEffect {
  54711. private _postProcesses;
  54712. private _getPostProcesses;
  54713. private _singleInstance;
  54714. private _cameras;
  54715. private _indicesForCamera;
  54716. /**
  54717. * Name of the effect
  54718. * @hidden
  54719. */
  54720. _name: string;
  54721. /**
  54722. * Instantiates a post process render effect.
  54723. * A post process can be used to apply a shader to a texture after it is rendered.
  54724. * @param engine The engine the effect is tied to
  54725. * @param name The name of the effect
  54726. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54727. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54728. */
  54729. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54730. /**
  54731. * Checks if all the post processes in the effect are supported.
  54732. */
  54733. readonly isSupported: boolean;
  54734. /**
  54735. * Updates the current state of the effect
  54736. * @hidden
  54737. */
  54738. _update(): void;
  54739. /**
  54740. * Attaches the effect on cameras
  54741. * @param cameras The camera to attach to.
  54742. * @hidden
  54743. */
  54744. _attachCameras(cameras: Camera): void;
  54745. /**
  54746. * Attaches the effect on cameras
  54747. * @param cameras The camera to attach to.
  54748. * @hidden
  54749. */
  54750. _attachCameras(cameras: Camera[]): void;
  54751. /**
  54752. * Detaches the effect on cameras
  54753. * @param cameras The camera to detatch from.
  54754. * @hidden
  54755. */
  54756. _detachCameras(cameras: Camera): void;
  54757. /**
  54758. * Detatches the effect on cameras
  54759. * @param cameras The camera to detatch from.
  54760. * @hidden
  54761. */
  54762. _detachCameras(cameras: Camera[]): void;
  54763. /**
  54764. * Enables the effect on given cameras
  54765. * @param cameras The camera to enable.
  54766. * @hidden
  54767. */
  54768. _enable(cameras: Camera): void;
  54769. /**
  54770. * Enables the effect on given cameras
  54771. * @param cameras The camera to enable.
  54772. * @hidden
  54773. */
  54774. _enable(cameras: Nullable<Camera[]>): void;
  54775. /**
  54776. * Disables the effect on the given cameras
  54777. * @param cameras The camera to disable.
  54778. * @hidden
  54779. */
  54780. _disable(cameras: Camera): void;
  54781. /**
  54782. * Disables the effect on the given cameras
  54783. * @param cameras The camera to disable.
  54784. * @hidden
  54785. */
  54786. _disable(cameras: Nullable<Camera[]>): void;
  54787. /**
  54788. * Gets a list of the post processes contained in the effect.
  54789. * @param camera The camera to get the post processes on.
  54790. * @returns The list of the post processes in the effect.
  54791. */
  54792. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54793. }
  54794. }
  54795. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54797. /** @hidden */
  54798. export var extractHighlightsPixelShader: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54804. import { Nullable } from "babylonjs/types";
  54805. import { Camera } from "babylonjs/Cameras/camera";
  54806. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54807. import { Engine } from "babylonjs/Engines/engine";
  54808. import "babylonjs/Shaders/extractHighlights.fragment";
  54809. /**
  54810. * 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.
  54811. */
  54812. export class ExtractHighlightsPostProcess extends PostProcess {
  54813. /**
  54814. * The luminance threshold, pixels below this value will be set to black.
  54815. */
  54816. threshold: number;
  54817. /** @hidden */
  54818. _exposure: number;
  54819. /**
  54820. * Post process which has the input texture to be used when performing highlight extraction
  54821. * @hidden
  54822. */
  54823. _inputPostProcess: Nullable<PostProcess>;
  54824. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54825. }
  54826. }
  54827. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54828. /** @hidden */
  54829. export var bloomMergePixelShader: {
  54830. name: string;
  54831. shader: string;
  54832. };
  54833. }
  54834. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54835. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54836. import { Nullable } from "babylonjs/types";
  54837. import { Engine } from "babylonjs/Engines/engine";
  54838. import { Camera } from "babylonjs/Cameras/camera";
  54839. import "babylonjs/Shaders/bloomMerge.fragment";
  54840. /**
  54841. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54842. */
  54843. export class BloomMergePostProcess extends PostProcess {
  54844. /** Weight of the bloom to be added to the original input. */
  54845. weight: number;
  54846. /**
  54847. * Creates a new instance of @see BloomMergePostProcess
  54848. * @param name The name of the effect.
  54849. * @param originalFromInput Post process which's input will be used for the merge.
  54850. * @param blurred Blurred highlights post process which's output will be used.
  54851. * @param weight Weight of the bloom to be added to the original input.
  54852. * @param options The required width/height ratio to downsize to before computing the render pass.
  54853. * @param camera The camera to apply the render pass to.
  54854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54855. * @param engine The engine which the post process will be applied. (default: current engine)
  54856. * @param reusable If the post process can be reused on the same frame. (default: false)
  54857. * @param textureType Type of textures used when performing the post process. (default: 0)
  54858. * @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)
  54859. */
  54860. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54861. /** Weight of the bloom to be added to the original input. */
  54862. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54863. }
  54864. }
  54865. declare module "babylonjs/PostProcesses/bloomEffect" {
  54866. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54867. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54868. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54869. import { Camera } from "babylonjs/Cameras/camera";
  54870. import { Scene } from "babylonjs/scene";
  54871. /**
  54872. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54873. */
  54874. export class BloomEffect extends PostProcessRenderEffect {
  54875. private bloomScale;
  54876. /**
  54877. * @hidden Internal
  54878. */
  54879. _effects: Array<PostProcess>;
  54880. /**
  54881. * @hidden Internal
  54882. */
  54883. _downscale: ExtractHighlightsPostProcess;
  54884. private _blurX;
  54885. private _blurY;
  54886. private _merge;
  54887. /**
  54888. * The luminance threshold to find bright areas of the image to bloom.
  54889. */
  54890. threshold: number;
  54891. /**
  54892. * The strength of the bloom.
  54893. */
  54894. weight: number;
  54895. /**
  54896. * Specifies the size of the bloom blur kernel, relative to the final output size
  54897. */
  54898. kernel: number;
  54899. /**
  54900. * Creates a new instance of @see BloomEffect
  54901. * @param scene The scene the effect belongs to.
  54902. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54903. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54904. * @param bloomWeight The the strength of bloom.
  54905. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54906. * @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)
  54907. */
  54908. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54909. /**
  54910. * Disposes each of the internal effects for a given camera.
  54911. * @param camera The camera to dispose the effect on.
  54912. */
  54913. disposeEffects(camera: Camera): void;
  54914. /**
  54915. * @hidden Internal
  54916. */
  54917. _updateEffects(): void;
  54918. /**
  54919. * Internal
  54920. * @returns if all the contained post processes are ready.
  54921. * @hidden
  54922. */
  54923. _isReady(): boolean;
  54924. }
  54925. }
  54926. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54927. /** @hidden */
  54928. export var chromaticAberrationPixelShader: {
  54929. name: string;
  54930. shader: string;
  54931. };
  54932. }
  54933. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54934. import { Vector2 } from "babylonjs/Maths/math";
  54935. import { Nullable } from "babylonjs/types";
  54936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54937. import { Camera } from "babylonjs/Cameras/camera";
  54938. import { Engine } from "babylonjs/Engines/engine";
  54939. import "babylonjs/Shaders/chromaticAberration.fragment";
  54940. /**
  54941. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54942. */
  54943. export class ChromaticAberrationPostProcess extends PostProcess {
  54944. /**
  54945. * The amount of seperation of rgb channels (default: 30)
  54946. */
  54947. aberrationAmount: number;
  54948. /**
  54949. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54950. */
  54951. radialIntensity: number;
  54952. /**
  54953. * 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))
  54954. */
  54955. direction: Vector2;
  54956. /**
  54957. * 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))
  54958. */
  54959. centerPosition: Vector2;
  54960. /**
  54961. * Creates a new instance ChromaticAberrationPostProcess
  54962. * @param name The name of the effect.
  54963. * @param screenWidth The width of the screen to apply the effect on.
  54964. * @param screenHeight The height of the screen to apply the effect on.
  54965. * @param options The required width/height ratio to downsize to before computing the render pass.
  54966. * @param camera The camera to apply the render pass to.
  54967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54968. * @param engine The engine which the post process will be applied. (default: current engine)
  54969. * @param reusable If the post process can be reused on the same frame. (default: false)
  54970. * @param textureType Type of textures used when performing the post process. (default: 0)
  54971. * @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)
  54972. */
  54973. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54974. }
  54975. }
  54976. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54977. /** @hidden */
  54978. export var circleOfConfusionPixelShader: {
  54979. name: string;
  54980. shader: string;
  54981. };
  54982. }
  54983. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54984. import { Nullable } from "babylonjs/types";
  54985. import { Engine } from "babylonjs/Engines/engine";
  54986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54988. import { Camera } from "babylonjs/Cameras/camera";
  54989. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54990. /**
  54991. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54992. */
  54993. export class CircleOfConfusionPostProcess extends PostProcess {
  54994. /**
  54995. * 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.
  54996. */
  54997. lensSize: number;
  54998. /**
  54999. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55000. */
  55001. fStop: number;
  55002. /**
  55003. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55004. */
  55005. focusDistance: number;
  55006. /**
  55007. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55008. */
  55009. focalLength: number;
  55010. private _depthTexture;
  55011. /**
  55012. * Creates a new instance CircleOfConfusionPostProcess
  55013. * @param name The name of the effect.
  55014. * @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.
  55015. * @param options The required width/height ratio to downsize to before computing the render pass.
  55016. * @param camera The camera to apply the render pass to.
  55017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55018. * @param engine The engine which the post process will be applied. (default: current engine)
  55019. * @param reusable If the post process can be reused on the same frame. (default: false)
  55020. * @param textureType Type of textures used when performing the post process. (default: 0)
  55021. * @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)
  55022. */
  55023. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55024. /**
  55025. * 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.
  55026. */
  55027. depthTexture: RenderTargetTexture;
  55028. }
  55029. }
  55030. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55031. /** @hidden */
  55032. export var colorCorrectionPixelShader: {
  55033. name: string;
  55034. shader: string;
  55035. };
  55036. }
  55037. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55038. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55039. import { Engine } from "babylonjs/Engines/engine";
  55040. import { Camera } from "babylonjs/Cameras/camera";
  55041. import "babylonjs/Shaders/colorCorrection.fragment";
  55042. /**
  55043. *
  55044. * This post-process allows the modification of rendered colors by using
  55045. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55046. *
  55047. * The object needs to be provided an url to a texture containing the color
  55048. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55049. * Use an image editing software to tweak the LUT to match your needs.
  55050. *
  55051. * For an example of a color LUT, see here:
  55052. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55053. * For explanations on color grading, see here:
  55054. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55055. *
  55056. */
  55057. export class ColorCorrectionPostProcess extends PostProcess {
  55058. private _colorTableTexture;
  55059. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55060. }
  55061. }
  55062. declare module "babylonjs/Shaders/convolution.fragment" {
  55063. /** @hidden */
  55064. export var convolutionPixelShader: {
  55065. name: string;
  55066. shader: string;
  55067. };
  55068. }
  55069. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55070. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55071. import { Nullable } from "babylonjs/types";
  55072. import { Camera } from "babylonjs/Cameras/camera";
  55073. import { Engine } from "babylonjs/Engines/engine";
  55074. import "babylonjs/Shaders/convolution.fragment";
  55075. /**
  55076. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55077. * input texture to perform effects such as edge detection or sharpening
  55078. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55079. */
  55080. export class ConvolutionPostProcess extends PostProcess {
  55081. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55082. kernel: number[];
  55083. /**
  55084. * Creates a new instance ConvolutionPostProcess
  55085. * @param name The name of the effect.
  55086. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55087. * @param options The required width/height ratio to downsize to before computing the render pass.
  55088. * @param camera The camera to apply the render pass to.
  55089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55090. * @param engine The engine which the post process will be applied. (default: current engine)
  55091. * @param reusable If the post process can be reused on the same frame. (default: false)
  55092. * @param textureType Type of textures used when performing the post process. (default: 0)
  55093. */
  55094. constructor(name: string,
  55095. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55096. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55097. /**
  55098. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55099. */
  55100. static EdgeDetect0Kernel: number[];
  55101. /**
  55102. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55103. */
  55104. static EdgeDetect1Kernel: number[];
  55105. /**
  55106. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55107. */
  55108. static EdgeDetect2Kernel: number[];
  55109. /**
  55110. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55111. */
  55112. static SharpenKernel: number[];
  55113. /**
  55114. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55115. */
  55116. static EmbossKernel: number[];
  55117. /**
  55118. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. static GaussianKernel: number[];
  55121. }
  55122. }
  55123. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55124. import { Nullable } from "babylonjs/types";
  55125. import { Vector2 } from "babylonjs/Maths/math";
  55126. import { Camera } from "babylonjs/Cameras/camera";
  55127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55128. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55129. import { Engine } from "babylonjs/Engines/engine";
  55130. import { Scene } from "babylonjs/scene";
  55131. /**
  55132. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55133. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55134. * based on samples that have a large difference in distance than the center pixel.
  55135. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55136. */
  55137. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55138. direction: Vector2;
  55139. /**
  55140. * Creates a new instance CircleOfConfusionPostProcess
  55141. * @param name The name of the effect.
  55142. * @param scene The scene the effect belongs to.
  55143. * @param direction The direction the blur should be applied.
  55144. * @param kernel The size of the kernel used to blur.
  55145. * @param options The required width/height ratio to downsize to before computing the render pass.
  55146. * @param camera The camera to apply the render pass to.
  55147. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55148. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55150. * @param engine The engine which the post process will be applied. (default: current engine)
  55151. * @param reusable If the post process can be reused on the same frame. (default: false)
  55152. * @param textureType Type of textures used when performing the post process. (default: 0)
  55153. * @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)
  55154. */
  55155. 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);
  55156. }
  55157. }
  55158. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55159. /** @hidden */
  55160. export var depthOfFieldMergePixelShader: {
  55161. name: string;
  55162. shader: string;
  55163. };
  55164. }
  55165. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55166. import { Nullable } from "babylonjs/types";
  55167. import { Camera } from "babylonjs/Cameras/camera";
  55168. import { Effect } from "babylonjs/Materials/effect";
  55169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55170. import { Engine } from "babylonjs/Engines/engine";
  55171. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55172. /**
  55173. * Options to be set when merging outputs from the default pipeline.
  55174. */
  55175. export class DepthOfFieldMergePostProcessOptions {
  55176. /**
  55177. * The original image to merge on top of
  55178. */
  55179. originalFromInput: PostProcess;
  55180. /**
  55181. * Parameters to perform the merge of the depth of field effect
  55182. */
  55183. depthOfField?: {
  55184. circleOfConfusion: PostProcess;
  55185. blurSteps: Array<PostProcess>;
  55186. };
  55187. /**
  55188. * Parameters to perform the merge of bloom effect
  55189. */
  55190. bloom?: {
  55191. blurred: PostProcess;
  55192. weight: number;
  55193. };
  55194. }
  55195. /**
  55196. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55197. */
  55198. export class DepthOfFieldMergePostProcess extends PostProcess {
  55199. private blurSteps;
  55200. /**
  55201. * Creates a new instance of DepthOfFieldMergePostProcess
  55202. * @param name The name of the effect.
  55203. * @param originalFromInput Post process which's input will be used for the merge.
  55204. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55205. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55206. * @param options The required width/height ratio to downsize to before computing the render pass.
  55207. * @param camera The camera to apply the render pass to.
  55208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55209. * @param engine The engine which the post process will be applied. (default: current engine)
  55210. * @param reusable If the post process can be reused on the same frame. (default: false)
  55211. * @param textureType Type of textures used when performing the post process. (default: 0)
  55212. * @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)
  55213. */
  55214. 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);
  55215. /**
  55216. * Updates the effect with the current post process compile time values and recompiles the shader.
  55217. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55218. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55219. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55220. * @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
  55221. * @param onCompiled Called when the shader has been compiled.
  55222. * @param onError Called if there is an error when compiling a shader.
  55223. */
  55224. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55225. }
  55226. }
  55227. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55228. import { Nullable } from "babylonjs/types";
  55229. import { Camera } from "babylonjs/Cameras/camera";
  55230. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55232. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55233. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55234. import { Scene } from "babylonjs/scene";
  55235. /**
  55236. * Specifies the level of max blur that should be applied when using the depth of field effect
  55237. */
  55238. export enum DepthOfFieldEffectBlurLevel {
  55239. /**
  55240. * Subtle blur
  55241. */
  55242. Low = 0,
  55243. /**
  55244. * Medium blur
  55245. */
  55246. Medium = 1,
  55247. /**
  55248. * Large blur
  55249. */
  55250. High = 2
  55251. }
  55252. /**
  55253. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55254. */
  55255. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55256. private _circleOfConfusion;
  55257. /**
  55258. * @hidden Internal, blurs from high to low
  55259. */
  55260. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55261. private _depthOfFieldBlurY;
  55262. private _dofMerge;
  55263. /**
  55264. * @hidden Internal post processes in depth of field effect
  55265. */
  55266. _effects: Array<PostProcess>;
  55267. /**
  55268. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55269. */
  55270. focalLength: number;
  55271. /**
  55272. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55273. */
  55274. fStop: number;
  55275. /**
  55276. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55277. */
  55278. focusDistance: number;
  55279. /**
  55280. * 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.
  55281. */
  55282. lensSize: number;
  55283. /**
  55284. * Creates a new instance DepthOfFieldEffect
  55285. * @param scene The scene the effect belongs to.
  55286. * @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.
  55287. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55288. * @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)
  55289. */
  55290. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55291. /**
  55292. * Get the current class name of the current effet
  55293. * @returns "DepthOfFieldEffect"
  55294. */
  55295. getClassName(): string;
  55296. /**
  55297. * 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.
  55298. */
  55299. depthTexture: RenderTargetTexture;
  55300. /**
  55301. * Disposes each of the internal effects for a given camera.
  55302. * @param camera The camera to dispose the effect on.
  55303. */
  55304. disposeEffects(camera: Camera): void;
  55305. /**
  55306. * @hidden Internal
  55307. */
  55308. _updateEffects(): void;
  55309. /**
  55310. * Internal
  55311. * @returns if all the contained post processes are ready.
  55312. * @hidden
  55313. */
  55314. _isReady(): boolean;
  55315. }
  55316. }
  55317. declare module "babylonjs/Shaders/displayPass.fragment" {
  55318. /** @hidden */
  55319. export var displayPassPixelShader: {
  55320. name: string;
  55321. shader: string;
  55322. };
  55323. }
  55324. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55325. import { Nullable } from "babylonjs/types";
  55326. import { Camera } from "babylonjs/Cameras/camera";
  55327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55328. import { Engine } from "babylonjs/Engines/engine";
  55329. import "babylonjs/Shaders/displayPass.fragment";
  55330. /**
  55331. * DisplayPassPostProcess which produces an output the same as it's input
  55332. */
  55333. export class DisplayPassPostProcess extends PostProcess {
  55334. /**
  55335. * Creates the DisplayPassPostProcess
  55336. * @param name The name of the effect.
  55337. * @param options The required width/height ratio to downsize to before computing the render pass.
  55338. * @param camera The camera to apply the render pass to.
  55339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55340. * @param engine The engine which the post process will be applied. (default: current engine)
  55341. * @param reusable If the post process can be reused on the same frame. (default: false)
  55342. */
  55343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55344. }
  55345. }
  55346. declare module "babylonjs/Shaders/filter.fragment" {
  55347. /** @hidden */
  55348. export var filterPixelShader: {
  55349. name: string;
  55350. shader: string;
  55351. };
  55352. }
  55353. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55354. import { Nullable } from "babylonjs/types";
  55355. import { Matrix } from "babylonjs/Maths/math";
  55356. import { Camera } from "babylonjs/Cameras/camera";
  55357. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55358. import { Engine } from "babylonjs/Engines/engine";
  55359. import "babylonjs/Shaders/filter.fragment";
  55360. /**
  55361. * Applies a kernel filter to the image
  55362. */
  55363. export class FilterPostProcess extends PostProcess {
  55364. /** The matrix to be applied to the image */
  55365. kernelMatrix: Matrix;
  55366. /**
  55367. *
  55368. * @param name The name of the effect.
  55369. * @param kernelMatrix The matrix to be applied to the image
  55370. * @param options The required width/height ratio to downsize to before computing the render pass.
  55371. * @param camera The camera to apply the render pass to.
  55372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55373. * @param engine The engine which the post process will be applied. (default: current engine)
  55374. * @param reusable If the post process can be reused on the same frame. (default: false)
  55375. */
  55376. constructor(name: string,
  55377. /** The matrix to be applied to the image */
  55378. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55379. }
  55380. }
  55381. declare module "babylonjs/Shaders/fxaa.fragment" {
  55382. /** @hidden */
  55383. export var fxaaPixelShader: {
  55384. name: string;
  55385. shader: string;
  55386. };
  55387. }
  55388. declare module "babylonjs/Shaders/fxaa.vertex" {
  55389. /** @hidden */
  55390. export var fxaaVertexShader: {
  55391. name: string;
  55392. shader: string;
  55393. };
  55394. }
  55395. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55396. import { Nullable } from "babylonjs/types";
  55397. import { Camera } from "babylonjs/Cameras/camera";
  55398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55399. import { Engine } from "babylonjs/Engines/engine";
  55400. import "babylonjs/Shaders/fxaa.fragment";
  55401. import "babylonjs/Shaders/fxaa.vertex";
  55402. /**
  55403. * Fxaa post process
  55404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55405. */
  55406. export class FxaaPostProcess extends PostProcess {
  55407. /** @hidden */
  55408. texelWidth: number;
  55409. /** @hidden */
  55410. texelHeight: number;
  55411. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55412. private _getDefines;
  55413. }
  55414. }
  55415. declare module "babylonjs/Shaders/grain.fragment" {
  55416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55417. /** @hidden */
  55418. export var grainPixelShader: {
  55419. name: string;
  55420. shader: string;
  55421. };
  55422. }
  55423. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55424. import { Nullable } from "babylonjs/types";
  55425. import { Camera } from "babylonjs/Cameras/camera";
  55426. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55427. import { Engine } from "babylonjs/Engines/engine";
  55428. import "babylonjs/Shaders/grain.fragment";
  55429. /**
  55430. * The GrainPostProcess adds noise to the image at mid luminance levels
  55431. */
  55432. export class GrainPostProcess extends PostProcess {
  55433. /**
  55434. * The intensity of the grain added (default: 30)
  55435. */
  55436. intensity: number;
  55437. /**
  55438. * If the grain should be randomized on every frame
  55439. */
  55440. animated: boolean;
  55441. /**
  55442. * Creates a new instance of @see GrainPostProcess
  55443. * @param name The name of the effect.
  55444. * @param options The required width/height ratio to downsize to before computing the render pass.
  55445. * @param camera The camera to apply the render pass to.
  55446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55447. * @param engine The engine which the post process will be applied. (default: current engine)
  55448. * @param reusable If the post process can be reused on the same frame. (default: false)
  55449. * @param textureType Type of textures used when performing the post process. (default: 0)
  55450. * @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)
  55451. */
  55452. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55453. }
  55454. }
  55455. declare module "babylonjs/Shaders/highlights.fragment" {
  55456. /** @hidden */
  55457. export var highlightsPixelShader: {
  55458. name: string;
  55459. shader: string;
  55460. };
  55461. }
  55462. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55463. import { Nullable } from "babylonjs/types";
  55464. import { Camera } from "babylonjs/Cameras/camera";
  55465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55466. import { Engine } from "babylonjs/Engines/engine";
  55467. import "babylonjs/Shaders/highlights.fragment";
  55468. /**
  55469. * Extracts highlights from the image
  55470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55471. */
  55472. export class HighlightsPostProcess extends PostProcess {
  55473. /**
  55474. * Extracts highlights from the image
  55475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55476. * @param name The name of the effect.
  55477. * @param options The required width/height ratio to downsize to before computing the render pass.
  55478. * @param camera The camera to apply the render pass to.
  55479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55480. * @param engine The engine which the post process will be applied. (default: current engine)
  55481. * @param reusable If the post process can be reused on the same frame. (default: false)
  55482. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55483. */
  55484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55485. }
  55486. }
  55487. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55488. /** @hidden */
  55489. export var mrtFragmentDeclaration: {
  55490. name: string;
  55491. shader: string;
  55492. };
  55493. }
  55494. declare module "babylonjs/Shaders/geometry.fragment" {
  55495. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55496. /** @hidden */
  55497. export var geometryPixelShader: {
  55498. name: string;
  55499. shader: string;
  55500. };
  55501. }
  55502. declare module "babylonjs/Shaders/geometry.vertex" {
  55503. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55504. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55505. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55506. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55507. /** @hidden */
  55508. export var geometryVertexShader: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55514. import { Matrix } from "babylonjs/Maths/math";
  55515. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55516. import { Mesh } from "babylonjs/Meshes/mesh";
  55517. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55518. import { Effect } from "babylonjs/Materials/effect";
  55519. import { Scene } from "babylonjs/scene";
  55520. import "babylonjs/Shaders/geometry.fragment";
  55521. import "babylonjs/Shaders/geometry.vertex";
  55522. /**
  55523. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55524. */
  55525. export class GeometryBufferRenderer {
  55526. /**
  55527. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55528. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55529. */
  55530. static readonly POSITION_TEXTURE_TYPE: number;
  55531. /**
  55532. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55533. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55534. */
  55535. static readonly VELOCITY_TEXTURE_TYPE: number;
  55536. /**
  55537. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55538. * in order to compute objects velocities when enableVelocity is set to "true"
  55539. * @hidden
  55540. */
  55541. _previousTransformationMatrices: {
  55542. [index: number]: Matrix;
  55543. };
  55544. private _scene;
  55545. private _multiRenderTarget;
  55546. private _ratio;
  55547. private _enablePosition;
  55548. private _enableVelocity;
  55549. private _positionIndex;
  55550. private _velocityIndex;
  55551. protected _effect: Effect;
  55552. protected _cachedDefines: string;
  55553. /**
  55554. * Set the render list (meshes to be rendered) used in the G buffer.
  55555. */
  55556. renderList: Mesh[];
  55557. /**
  55558. * Gets wether or not G buffer are supported by the running hardware.
  55559. * This requires draw buffer supports
  55560. */
  55561. readonly isSupported: boolean;
  55562. /**
  55563. * Returns the index of the given texture type in the G-Buffer textures array
  55564. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55565. * @returns the index of the given texture type in the G-Buffer textures array
  55566. */
  55567. getTextureIndex(textureType: number): number;
  55568. /**
  55569. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55570. */
  55571. /**
  55572. * Sets whether or not objects positions are enabled for the G buffer.
  55573. */
  55574. enablePosition: boolean;
  55575. /**
  55576. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55577. */
  55578. /**
  55579. * Sets wether or not objects velocities are enabled for the G buffer.
  55580. */
  55581. enableVelocity: boolean;
  55582. /**
  55583. * Gets the scene associated with the buffer.
  55584. */
  55585. readonly scene: Scene;
  55586. /**
  55587. * Gets the ratio used by the buffer during its creation.
  55588. * How big is the buffer related to the main canvas.
  55589. */
  55590. readonly ratio: number;
  55591. /** @hidden */
  55592. static _SceneComponentInitialization: (scene: Scene) => void;
  55593. /**
  55594. * Creates a new G Buffer for the scene
  55595. * @param scene The scene the buffer belongs to
  55596. * @param ratio How big is the buffer related to the main canvas.
  55597. */
  55598. constructor(scene: Scene, ratio?: number);
  55599. /**
  55600. * Checks wether everything is ready to render a submesh to the G buffer.
  55601. * @param subMesh the submesh to check readiness for
  55602. * @param useInstances is the mesh drawn using instance or not
  55603. * @returns true if ready otherwise false
  55604. */
  55605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55606. /**
  55607. * Gets the current underlying G Buffer.
  55608. * @returns the buffer
  55609. */
  55610. getGBuffer(): MultiRenderTarget;
  55611. /**
  55612. * Gets the number of samples used to render the buffer (anti aliasing).
  55613. */
  55614. /**
  55615. * Sets the number of samples used to render the buffer (anti aliasing).
  55616. */
  55617. samples: number;
  55618. /**
  55619. * Disposes the renderer and frees up associated resources.
  55620. */
  55621. dispose(): void;
  55622. protected _createRenderTargets(): void;
  55623. }
  55624. }
  55625. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55626. import { Nullable } from "babylonjs/types";
  55627. import { Scene } from "babylonjs/scene";
  55628. import { ISceneComponent } from "babylonjs/sceneComponent";
  55629. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55630. module "babylonjs/scene" {
  55631. interface Scene {
  55632. /** @hidden (Backing field) */
  55633. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55634. /**
  55635. * Gets or Sets the current geometry buffer associated to the scene.
  55636. */
  55637. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55638. /**
  55639. * Enables a GeometryBufferRender and associates it with the scene
  55640. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55641. * @returns the GeometryBufferRenderer
  55642. */
  55643. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55644. /**
  55645. * Disables the GeometryBufferRender associated with the scene
  55646. */
  55647. disableGeometryBufferRenderer(): void;
  55648. }
  55649. }
  55650. /**
  55651. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55652. * in several rendering techniques.
  55653. */
  55654. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55655. /**
  55656. * The component name helpful to identify the component in the list of scene components.
  55657. */
  55658. readonly name: string;
  55659. /**
  55660. * The scene the component belongs to.
  55661. */
  55662. scene: Scene;
  55663. /**
  55664. * Creates a new instance of the component for the given scene
  55665. * @param scene Defines the scene to register the component in
  55666. */
  55667. constructor(scene: Scene);
  55668. /**
  55669. * Registers the component in a given scene
  55670. */
  55671. register(): void;
  55672. /**
  55673. * Rebuilds the elements related to this component in case of
  55674. * context lost for instance.
  55675. */
  55676. rebuild(): void;
  55677. /**
  55678. * Disposes the component and the associated ressources
  55679. */
  55680. dispose(): void;
  55681. private _gatherRenderTargets;
  55682. }
  55683. }
  55684. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55685. /** @hidden */
  55686. export var motionBlurPixelShader: {
  55687. name: string;
  55688. shader: string;
  55689. };
  55690. }
  55691. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55692. import { Nullable } from "babylonjs/types";
  55693. import { Camera } from "babylonjs/Cameras/camera";
  55694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55695. import { Scene } from "babylonjs/scene";
  55696. import "babylonjs/Animations/animatable";
  55697. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55698. import "babylonjs/Shaders/motionBlur.fragment";
  55699. import { Engine } from "babylonjs/Engines/engine";
  55700. /**
  55701. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55702. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55703. * As an example, all you have to do is to create the post-process:
  55704. * var mb = new BABYLON.MotionBlurPostProcess(
  55705. * 'mb', // The name of the effect.
  55706. * scene, // The scene containing the objects to blur according to their velocity.
  55707. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55708. * camera // The camera to apply the render pass to.
  55709. * );
  55710. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55711. */
  55712. export class MotionBlurPostProcess extends PostProcess {
  55713. /**
  55714. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55715. */
  55716. motionStrength: number;
  55717. /**
  55718. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55719. */
  55720. /**
  55721. * Sets the number of iterations to be used for motion blur quality
  55722. */
  55723. motionBlurSamples: number;
  55724. private _motionBlurSamples;
  55725. private _geometryBufferRenderer;
  55726. /**
  55727. * Creates a new instance MotionBlurPostProcess
  55728. * @param name The name of the effect.
  55729. * @param scene The scene containing the objects to blur according to their velocity.
  55730. * @param options The required width/height ratio to downsize to before computing the render pass.
  55731. * @param camera The camera to apply the render pass to.
  55732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55733. * @param engine The engine which the post process will be applied. (default: current engine)
  55734. * @param reusable If the post process can be reused on the same frame. (default: false)
  55735. * @param textureType Type of textures used when performing the post process. (default: 0)
  55736. * @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)
  55737. */
  55738. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55739. /**
  55740. * Disposes the post process.
  55741. * @param camera The camera to dispose the post process on.
  55742. */
  55743. dispose(camera?: Camera): void;
  55744. }
  55745. }
  55746. declare module "babylonjs/Shaders/refraction.fragment" {
  55747. /** @hidden */
  55748. export var refractionPixelShader: {
  55749. name: string;
  55750. shader: string;
  55751. };
  55752. }
  55753. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55754. import { Color3 } from "babylonjs/Maths/math";
  55755. import { Camera } from "babylonjs/Cameras/camera";
  55756. import { Texture } from "babylonjs/Materials/Textures/texture";
  55757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55758. import { Engine } from "babylonjs/Engines/engine";
  55759. import "babylonjs/Shaders/refraction.fragment";
  55760. /**
  55761. * Post process which applies a refractin texture
  55762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55763. */
  55764. export class RefractionPostProcess extends PostProcess {
  55765. /** the base color of the refraction (used to taint the rendering) */
  55766. color: Color3;
  55767. /** simulated refraction depth */
  55768. depth: number;
  55769. /** the coefficient of the base color (0 to remove base color tainting) */
  55770. colorLevel: number;
  55771. private _refTexture;
  55772. private _ownRefractionTexture;
  55773. /**
  55774. * Gets or sets the refraction texture
  55775. * Please note that you are responsible for disposing the texture if you set it manually
  55776. */
  55777. refractionTexture: Texture;
  55778. /**
  55779. * Initializes the RefractionPostProcess
  55780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55781. * @param name The name of the effect.
  55782. * @param refractionTextureUrl Url of the refraction texture to use
  55783. * @param color the base color of the refraction (used to taint the rendering)
  55784. * @param depth simulated refraction depth
  55785. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55786. * @param camera The camera to apply the render pass to.
  55787. * @param options The required width/height ratio to downsize to before computing the render pass.
  55788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55789. * @param engine The engine which the post process will be applied. (default: current engine)
  55790. * @param reusable If the post process can be reused on the same frame. (default: false)
  55791. */
  55792. constructor(name: string, refractionTextureUrl: string,
  55793. /** the base color of the refraction (used to taint the rendering) */
  55794. color: Color3,
  55795. /** simulated refraction depth */
  55796. depth: number,
  55797. /** the coefficient of the base color (0 to remove base color tainting) */
  55798. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55799. /**
  55800. * Disposes of the post process
  55801. * @param camera Camera to dispose post process on
  55802. */
  55803. dispose(camera: Camera): void;
  55804. }
  55805. }
  55806. declare module "babylonjs/Shaders/sharpen.fragment" {
  55807. /** @hidden */
  55808. export var sharpenPixelShader: {
  55809. name: string;
  55810. shader: string;
  55811. };
  55812. }
  55813. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55814. import { Nullable } from "babylonjs/types";
  55815. import { Camera } from "babylonjs/Cameras/camera";
  55816. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55817. import "babylonjs/Shaders/sharpen.fragment";
  55818. import { Engine } from "babylonjs/Engines/engine";
  55819. /**
  55820. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55821. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55822. */
  55823. export class SharpenPostProcess extends PostProcess {
  55824. /**
  55825. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55826. */
  55827. colorAmount: number;
  55828. /**
  55829. * How much sharpness should be applied (default: 0.3)
  55830. */
  55831. edgeAmount: number;
  55832. /**
  55833. * Creates a new instance ConvolutionPostProcess
  55834. * @param name The name of the effect.
  55835. * @param options The required width/height ratio to downsize to before computing the render pass.
  55836. * @param camera The camera to apply the render pass to.
  55837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55838. * @param engine The engine which the post process will be applied. (default: current engine)
  55839. * @param reusable If the post process can be reused on the same frame. (default: false)
  55840. * @param textureType Type of textures used when performing the post process. (default: 0)
  55841. * @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)
  55842. */
  55843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55844. }
  55845. }
  55846. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55847. import { Nullable } from "babylonjs/types";
  55848. import { Camera } from "babylonjs/Cameras/camera";
  55849. import { Engine } from "babylonjs/Engines/engine";
  55850. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55851. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55852. /**
  55853. * PostProcessRenderPipeline
  55854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55855. */
  55856. export class PostProcessRenderPipeline {
  55857. private engine;
  55858. private _renderEffects;
  55859. private _renderEffectsForIsolatedPass;
  55860. /**
  55861. * List of inspectable custom properties (used by the Inspector)
  55862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55863. */
  55864. inspectableCustomProperties: IInspectable[];
  55865. /**
  55866. * @hidden
  55867. */
  55868. protected _cameras: Camera[];
  55869. /** @hidden */
  55870. _name: string;
  55871. /**
  55872. * Gets pipeline name
  55873. */
  55874. readonly name: string;
  55875. /**
  55876. * Initializes a PostProcessRenderPipeline
  55877. * @param engine engine to add the pipeline to
  55878. * @param name name of the pipeline
  55879. */
  55880. constructor(engine: Engine, name: string);
  55881. /**
  55882. * Gets the class name
  55883. * @returns "PostProcessRenderPipeline"
  55884. */
  55885. getClassName(): string;
  55886. /**
  55887. * If all the render effects in the pipeline are supported
  55888. */
  55889. readonly isSupported: boolean;
  55890. /**
  55891. * Adds an effect to the pipeline
  55892. * @param renderEffect the effect to add
  55893. */
  55894. addEffect(renderEffect: PostProcessRenderEffect): void;
  55895. /** @hidden */
  55896. _rebuild(): void;
  55897. /** @hidden */
  55898. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55899. /** @hidden */
  55900. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55901. /** @hidden */
  55902. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55903. /** @hidden */
  55904. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55905. /** @hidden */
  55906. _attachCameras(cameras: Camera, unique: boolean): void;
  55907. /** @hidden */
  55908. _attachCameras(cameras: Camera[], unique: boolean): void;
  55909. /** @hidden */
  55910. _detachCameras(cameras: Camera): void;
  55911. /** @hidden */
  55912. _detachCameras(cameras: Nullable<Camera[]>): void;
  55913. /** @hidden */
  55914. _update(): void;
  55915. /** @hidden */
  55916. _reset(): void;
  55917. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55918. /**
  55919. * Disposes of the pipeline
  55920. */
  55921. dispose(): void;
  55922. }
  55923. }
  55924. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55925. import { Camera } from "babylonjs/Cameras/camera";
  55926. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55927. /**
  55928. * PostProcessRenderPipelineManager class
  55929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55930. */
  55931. export class PostProcessRenderPipelineManager {
  55932. private _renderPipelines;
  55933. /**
  55934. * Initializes a PostProcessRenderPipelineManager
  55935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55936. */
  55937. constructor();
  55938. /**
  55939. * Gets the list of supported render pipelines
  55940. */
  55941. readonly supportedPipelines: PostProcessRenderPipeline[];
  55942. /**
  55943. * Adds a pipeline to the manager
  55944. * @param renderPipeline The pipeline to add
  55945. */
  55946. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55947. /**
  55948. * Attaches a camera to the pipeline
  55949. * @param renderPipelineName The name of the pipeline to attach to
  55950. * @param cameras the camera to attach
  55951. * @param unique if the camera can be attached multiple times to the pipeline
  55952. */
  55953. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55954. /**
  55955. * Detaches a camera from the pipeline
  55956. * @param renderPipelineName The name of the pipeline to detach from
  55957. * @param cameras the camera to detach
  55958. */
  55959. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55960. /**
  55961. * Enables an effect by name on a pipeline
  55962. * @param renderPipelineName the name of the pipeline to enable the effect in
  55963. * @param renderEffectName the name of the effect to enable
  55964. * @param cameras the cameras that the effect should be enabled on
  55965. */
  55966. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55967. /**
  55968. * Disables an effect by name on a pipeline
  55969. * @param renderPipelineName the name of the pipeline to disable the effect in
  55970. * @param renderEffectName the name of the effect to disable
  55971. * @param cameras the cameras that the effect should be disabled on
  55972. */
  55973. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55974. /**
  55975. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55976. */
  55977. update(): void;
  55978. /** @hidden */
  55979. _rebuild(): void;
  55980. /**
  55981. * Disposes of the manager and pipelines
  55982. */
  55983. dispose(): void;
  55984. }
  55985. }
  55986. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55987. import { ISceneComponent } from "babylonjs/sceneComponent";
  55988. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55989. import { Scene } from "babylonjs/scene";
  55990. module "babylonjs/scene" {
  55991. interface Scene {
  55992. /** @hidden (Backing field) */
  55993. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55994. /**
  55995. * Gets the postprocess render pipeline manager
  55996. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55997. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55998. */
  55999. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56000. }
  56001. }
  56002. /**
  56003. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56004. */
  56005. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56006. /**
  56007. * The component name helpfull to identify the component in the list of scene components.
  56008. */
  56009. readonly name: string;
  56010. /**
  56011. * The scene the component belongs to.
  56012. */
  56013. scene: Scene;
  56014. /**
  56015. * Creates a new instance of the component for the given scene
  56016. * @param scene Defines the scene to register the component in
  56017. */
  56018. constructor(scene: Scene);
  56019. /**
  56020. * Registers the component in a given scene
  56021. */
  56022. register(): void;
  56023. /**
  56024. * Rebuilds the elements related to this component in case of
  56025. * context lost for instance.
  56026. */
  56027. rebuild(): void;
  56028. /**
  56029. * Disposes the component and the associated ressources
  56030. */
  56031. dispose(): void;
  56032. private _gatherRenderTargets;
  56033. }
  56034. }
  56035. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56036. import { IAnimatable } from "babylonjs/Misc/tools";
  56037. import { Camera } from "babylonjs/Cameras/camera";
  56038. import { IDisposable } from "babylonjs/scene";
  56039. import { Scene } from "babylonjs/scene";
  56040. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56041. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56042. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56043. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56044. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56045. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56046. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56047. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56048. import { Animation } from "babylonjs/Animations/animation";
  56049. /**
  56050. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56051. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56052. */
  56053. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56054. private _scene;
  56055. private _camerasToBeAttached;
  56056. /**
  56057. * ID of the sharpen post process,
  56058. */
  56059. private readonly SharpenPostProcessId;
  56060. /**
  56061. * @ignore
  56062. * ID of the image processing post process;
  56063. */
  56064. readonly ImageProcessingPostProcessId: string;
  56065. /**
  56066. * @ignore
  56067. * ID of the Fast Approximate Anti-Aliasing post process;
  56068. */
  56069. readonly FxaaPostProcessId: string;
  56070. /**
  56071. * ID of the chromatic aberration post process,
  56072. */
  56073. private readonly ChromaticAberrationPostProcessId;
  56074. /**
  56075. * ID of the grain post process
  56076. */
  56077. private readonly GrainPostProcessId;
  56078. /**
  56079. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56080. */
  56081. sharpen: SharpenPostProcess;
  56082. private _sharpenEffect;
  56083. private bloom;
  56084. /**
  56085. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56086. */
  56087. depthOfField: DepthOfFieldEffect;
  56088. /**
  56089. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56090. */
  56091. fxaa: FxaaPostProcess;
  56092. /**
  56093. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56094. */
  56095. imageProcessing: ImageProcessingPostProcess;
  56096. /**
  56097. * Chromatic aberration post process which will shift rgb colors in the image
  56098. */
  56099. chromaticAberration: ChromaticAberrationPostProcess;
  56100. private _chromaticAberrationEffect;
  56101. /**
  56102. * Grain post process which add noise to the image
  56103. */
  56104. grain: GrainPostProcess;
  56105. private _grainEffect;
  56106. /**
  56107. * Glow post process which adds a glow to emissive areas of the image
  56108. */
  56109. private _glowLayer;
  56110. /**
  56111. * Animations which can be used to tweak settings over a period of time
  56112. */
  56113. animations: Animation[];
  56114. private _imageProcessingConfigurationObserver;
  56115. private _sharpenEnabled;
  56116. private _bloomEnabled;
  56117. private _depthOfFieldEnabled;
  56118. private _depthOfFieldBlurLevel;
  56119. private _fxaaEnabled;
  56120. private _imageProcessingEnabled;
  56121. private _defaultPipelineTextureType;
  56122. private _bloomScale;
  56123. private _chromaticAberrationEnabled;
  56124. private _grainEnabled;
  56125. private _buildAllowed;
  56126. /**
  56127. * Gets active scene
  56128. */
  56129. readonly scene: Scene;
  56130. /**
  56131. * Enable or disable the sharpen process from the pipeline
  56132. */
  56133. sharpenEnabled: boolean;
  56134. private _resizeObserver;
  56135. private _hardwareScaleLevel;
  56136. private _bloomKernel;
  56137. /**
  56138. * Specifies the size of the bloom blur kernel, relative to the final output size
  56139. */
  56140. bloomKernel: number;
  56141. /**
  56142. * Specifies the weight of the bloom in the final rendering
  56143. */
  56144. private _bloomWeight;
  56145. /**
  56146. * Specifies the luma threshold for the area that will be blurred by the bloom
  56147. */
  56148. private _bloomThreshold;
  56149. private _hdr;
  56150. /**
  56151. * The strength of the bloom.
  56152. */
  56153. bloomWeight: number;
  56154. /**
  56155. * The strength of the bloom.
  56156. */
  56157. bloomThreshold: number;
  56158. /**
  56159. * The scale of the bloom, lower value will provide better performance.
  56160. */
  56161. bloomScale: number;
  56162. /**
  56163. * Enable or disable the bloom from the pipeline
  56164. */
  56165. bloomEnabled: boolean;
  56166. private _rebuildBloom;
  56167. /**
  56168. * If the depth of field is enabled.
  56169. */
  56170. depthOfFieldEnabled: boolean;
  56171. /**
  56172. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56173. */
  56174. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56175. /**
  56176. * If the anti aliasing is enabled.
  56177. */
  56178. fxaaEnabled: boolean;
  56179. private _samples;
  56180. /**
  56181. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56182. */
  56183. samples: number;
  56184. /**
  56185. * If image processing is enabled.
  56186. */
  56187. imageProcessingEnabled: boolean;
  56188. /**
  56189. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56190. */
  56191. glowLayerEnabled: boolean;
  56192. /**
  56193. * Enable or disable the chromaticAberration process from the pipeline
  56194. */
  56195. chromaticAberrationEnabled: boolean;
  56196. /**
  56197. * Enable or disable the grain process from the pipeline
  56198. */
  56199. grainEnabled: boolean;
  56200. /**
  56201. * @constructor
  56202. * @param name - The rendering pipeline name (default: "")
  56203. * @param hdr - If high dynamic range textures should be used (default: true)
  56204. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56205. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56206. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56207. */
  56208. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56209. /**
  56210. * Get the class name
  56211. * @returns "DefaultRenderingPipeline"
  56212. */
  56213. getClassName(): string;
  56214. /**
  56215. * Force the compilation of the entire pipeline.
  56216. */
  56217. prepare(): void;
  56218. private _hasCleared;
  56219. private _prevPostProcess;
  56220. private _prevPrevPostProcess;
  56221. private _setAutoClearAndTextureSharing;
  56222. private _depthOfFieldSceneObserver;
  56223. private _buildPipeline;
  56224. private _disposePostProcesses;
  56225. /**
  56226. * Adds a camera to the pipeline
  56227. * @param camera the camera to be added
  56228. */
  56229. addCamera(camera: Camera): void;
  56230. /**
  56231. * Removes a camera from the pipeline
  56232. * @param camera the camera to remove
  56233. */
  56234. removeCamera(camera: Camera): void;
  56235. /**
  56236. * Dispose of the pipeline and stop all post processes
  56237. */
  56238. dispose(): void;
  56239. /**
  56240. * Serialize the rendering pipeline (Used when exporting)
  56241. * @returns the serialized object
  56242. */
  56243. serialize(): any;
  56244. /**
  56245. * Parse the serialized pipeline
  56246. * @param source Source pipeline.
  56247. * @param scene The scene to load the pipeline to.
  56248. * @param rootUrl The URL of the serialized pipeline.
  56249. * @returns An instantiated pipeline from the serialized object.
  56250. */
  56251. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56252. }
  56253. }
  56254. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56255. /** @hidden */
  56256. export var lensHighlightsPixelShader: {
  56257. name: string;
  56258. shader: string;
  56259. };
  56260. }
  56261. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56262. /** @hidden */
  56263. export var depthOfFieldPixelShader: {
  56264. name: string;
  56265. shader: string;
  56266. };
  56267. }
  56268. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56269. import { Camera } from "babylonjs/Cameras/camera";
  56270. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56271. import { Scene } from "babylonjs/scene";
  56272. import "babylonjs/Shaders/chromaticAberration.fragment";
  56273. import "babylonjs/Shaders/lensHighlights.fragment";
  56274. import "babylonjs/Shaders/depthOfField.fragment";
  56275. /**
  56276. * BABYLON.JS Chromatic Aberration GLSL Shader
  56277. * Author: Olivier Guyot
  56278. * Separates very slightly R, G and B colors on the edges of the screen
  56279. * Inspired by Francois Tarlier & Martins Upitis
  56280. */
  56281. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56282. /**
  56283. * @ignore
  56284. * The chromatic aberration PostProcess id in the pipeline
  56285. */
  56286. LensChromaticAberrationEffect: string;
  56287. /**
  56288. * @ignore
  56289. * The highlights enhancing PostProcess id in the pipeline
  56290. */
  56291. HighlightsEnhancingEffect: string;
  56292. /**
  56293. * @ignore
  56294. * The depth-of-field PostProcess id in the pipeline
  56295. */
  56296. LensDepthOfFieldEffect: string;
  56297. private _scene;
  56298. private _depthTexture;
  56299. private _grainTexture;
  56300. private _chromaticAberrationPostProcess;
  56301. private _highlightsPostProcess;
  56302. private _depthOfFieldPostProcess;
  56303. private _edgeBlur;
  56304. private _grainAmount;
  56305. private _chromaticAberration;
  56306. private _distortion;
  56307. private _highlightsGain;
  56308. private _highlightsThreshold;
  56309. private _dofDistance;
  56310. private _dofAperture;
  56311. private _dofDarken;
  56312. private _dofPentagon;
  56313. private _blurNoise;
  56314. /**
  56315. * @constructor
  56316. *
  56317. * Effect parameters are as follow:
  56318. * {
  56319. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56320. * edge_blur: number; // from 0 to x (1 for realism)
  56321. * distortion: number; // from 0 to x (1 for realism)
  56322. * grain_amount: number; // from 0 to 1
  56323. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56324. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56325. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56326. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56327. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56328. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56329. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56330. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56331. * }
  56332. * Note: if an effect parameter is unset, effect is disabled
  56333. *
  56334. * @param name The rendering pipeline name
  56335. * @param parameters - An object containing all parameters (see above)
  56336. * @param scene The scene linked to this pipeline
  56337. * @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)
  56338. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56339. */
  56340. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56341. /**
  56342. * Get the class name
  56343. * @returns "LensRenderingPipeline"
  56344. */
  56345. getClassName(): string;
  56346. /**
  56347. * Gets associated scene
  56348. */
  56349. readonly scene: Scene;
  56350. /**
  56351. * Gets or sets the edge blur
  56352. */
  56353. edgeBlur: number;
  56354. /**
  56355. * Gets or sets the grain amount
  56356. */
  56357. grainAmount: number;
  56358. /**
  56359. * Gets or sets the chromatic aberration amount
  56360. */
  56361. chromaticAberration: number;
  56362. /**
  56363. * Gets or sets the depth of field aperture
  56364. */
  56365. dofAperture: number;
  56366. /**
  56367. * Gets or sets the edge distortion
  56368. */
  56369. edgeDistortion: number;
  56370. /**
  56371. * Gets or sets the depth of field distortion
  56372. */
  56373. dofDistortion: number;
  56374. /**
  56375. * Gets or sets the darken out of focus amount
  56376. */
  56377. darkenOutOfFocus: number;
  56378. /**
  56379. * Gets or sets a boolean indicating if blur noise is enabled
  56380. */
  56381. blurNoise: boolean;
  56382. /**
  56383. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56384. */
  56385. pentagonBokeh: boolean;
  56386. /**
  56387. * Gets or sets the highlight grain amount
  56388. */
  56389. highlightsGain: number;
  56390. /**
  56391. * Gets or sets the highlight threshold
  56392. */
  56393. highlightsThreshold: number;
  56394. /**
  56395. * Sets the amount of blur at the edges
  56396. * @param amount blur amount
  56397. */
  56398. setEdgeBlur(amount: number): void;
  56399. /**
  56400. * Sets edge blur to 0
  56401. */
  56402. disableEdgeBlur(): void;
  56403. /**
  56404. * Sets the amout of grain
  56405. * @param amount Amount of grain
  56406. */
  56407. setGrainAmount(amount: number): void;
  56408. /**
  56409. * Set grain amount to 0
  56410. */
  56411. disableGrain(): void;
  56412. /**
  56413. * Sets the chromatic aberration amount
  56414. * @param amount amount of chromatic aberration
  56415. */
  56416. setChromaticAberration(amount: number): void;
  56417. /**
  56418. * Sets chromatic aberration amount to 0
  56419. */
  56420. disableChromaticAberration(): void;
  56421. /**
  56422. * Sets the EdgeDistortion amount
  56423. * @param amount amount of EdgeDistortion
  56424. */
  56425. setEdgeDistortion(amount: number): void;
  56426. /**
  56427. * Sets edge distortion to 0
  56428. */
  56429. disableEdgeDistortion(): void;
  56430. /**
  56431. * Sets the FocusDistance amount
  56432. * @param amount amount of FocusDistance
  56433. */
  56434. setFocusDistance(amount: number): void;
  56435. /**
  56436. * Disables depth of field
  56437. */
  56438. disableDepthOfField(): void;
  56439. /**
  56440. * Sets the Aperture amount
  56441. * @param amount amount of Aperture
  56442. */
  56443. setAperture(amount: number): void;
  56444. /**
  56445. * Sets the DarkenOutOfFocus amount
  56446. * @param amount amount of DarkenOutOfFocus
  56447. */
  56448. setDarkenOutOfFocus(amount: number): void;
  56449. private _pentagonBokehIsEnabled;
  56450. /**
  56451. * Creates a pentagon bokeh effect
  56452. */
  56453. enablePentagonBokeh(): void;
  56454. /**
  56455. * Disables the pentagon bokeh effect
  56456. */
  56457. disablePentagonBokeh(): void;
  56458. /**
  56459. * Enables noise blur
  56460. */
  56461. enableNoiseBlur(): void;
  56462. /**
  56463. * Disables noise blur
  56464. */
  56465. disableNoiseBlur(): void;
  56466. /**
  56467. * Sets the HighlightsGain amount
  56468. * @param amount amount of HighlightsGain
  56469. */
  56470. setHighlightsGain(amount: number): void;
  56471. /**
  56472. * Sets the HighlightsThreshold amount
  56473. * @param amount amount of HighlightsThreshold
  56474. */
  56475. setHighlightsThreshold(amount: number): void;
  56476. /**
  56477. * Disables highlights
  56478. */
  56479. disableHighlights(): void;
  56480. /**
  56481. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56482. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56483. */
  56484. dispose(disableDepthRender?: boolean): void;
  56485. private _createChromaticAberrationPostProcess;
  56486. private _createHighlightsPostProcess;
  56487. private _createDepthOfFieldPostProcess;
  56488. private _createGrainTexture;
  56489. }
  56490. }
  56491. declare module "babylonjs/Shaders/ssao2.fragment" {
  56492. /** @hidden */
  56493. export var ssao2PixelShader: {
  56494. name: string;
  56495. shader: string;
  56496. };
  56497. }
  56498. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56499. /** @hidden */
  56500. export var ssaoCombinePixelShader: {
  56501. name: string;
  56502. shader: string;
  56503. };
  56504. }
  56505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56506. import { Camera } from "babylonjs/Cameras/camera";
  56507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56508. import { Scene } from "babylonjs/scene";
  56509. import "babylonjs/Shaders/ssao2.fragment";
  56510. import "babylonjs/Shaders/ssaoCombine.fragment";
  56511. /**
  56512. * Render pipeline to produce ssao effect
  56513. */
  56514. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56515. /**
  56516. * @ignore
  56517. * The PassPostProcess id in the pipeline that contains the original scene color
  56518. */
  56519. SSAOOriginalSceneColorEffect: string;
  56520. /**
  56521. * @ignore
  56522. * The SSAO PostProcess id in the pipeline
  56523. */
  56524. SSAORenderEffect: string;
  56525. /**
  56526. * @ignore
  56527. * The horizontal blur PostProcess id in the pipeline
  56528. */
  56529. SSAOBlurHRenderEffect: string;
  56530. /**
  56531. * @ignore
  56532. * The vertical blur PostProcess id in the pipeline
  56533. */
  56534. SSAOBlurVRenderEffect: string;
  56535. /**
  56536. * @ignore
  56537. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56538. */
  56539. SSAOCombineRenderEffect: string;
  56540. /**
  56541. * The output strength of the SSAO post-process. Default value is 1.0.
  56542. */
  56543. totalStrength: number;
  56544. /**
  56545. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56546. */
  56547. maxZ: number;
  56548. /**
  56549. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56550. */
  56551. minZAspect: number;
  56552. private _samples;
  56553. /**
  56554. * Number of samples used for the SSAO calculations. Default value is 8
  56555. */
  56556. samples: number;
  56557. private _textureSamples;
  56558. /**
  56559. * Number of samples to use for antialiasing
  56560. */
  56561. textureSamples: number;
  56562. /**
  56563. * Ratio object used for SSAO ratio and blur ratio
  56564. */
  56565. private _ratio;
  56566. /**
  56567. * Dynamically generated sphere sampler.
  56568. */
  56569. private _sampleSphere;
  56570. /**
  56571. * Blur filter offsets
  56572. */
  56573. private _samplerOffsets;
  56574. private _expensiveBlur;
  56575. /**
  56576. * If bilateral blur should be used
  56577. */
  56578. expensiveBlur: boolean;
  56579. /**
  56580. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56581. */
  56582. radius: number;
  56583. /**
  56584. * The base color of the SSAO post-process
  56585. * The final result is "base + ssao" between [0, 1]
  56586. */
  56587. base: number;
  56588. /**
  56589. * Support test.
  56590. */
  56591. static readonly IsSupported: boolean;
  56592. private _scene;
  56593. private _depthTexture;
  56594. private _normalTexture;
  56595. private _randomTexture;
  56596. private _originalColorPostProcess;
  56597. private _ssaoPostProcess;
  56598. private _blurHPostProcess;
  56599. private _blurVPostProcess;
  56600. private _ssaoCombinePostProcess;
  56601. private _firstUpdate;
  56602. /**
  56603. * Gets active scene
  56604. */
  56605. readonly scene: Scene;
  56606. /**
  56607. * @constructor
  56608. * @param name The rendering pipeline name
  56609. * @param scene The scene linked to this pipeline
  56610. * @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 }
  56611. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56612. */
  56613. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56614. /**
  56615. * Get the class name
  56616. * @returns "SSAO2RenderingPipeline"
  56617. */
  56618. getClassName(): string;
  56619. /**
  56620. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56621. */
  56622. dispose(disableGeometryBufferRenderer?: boolean): void;
  56623. private _createBlurPostProcess;
  56624. /** @hidden */
  56625. _rebuild(): void;
  56626. private _bits;
  56627. private _radicalInverse_VdC;
  56628. private _hammersley;
  56629. private _hemisphereSample_uniform;
  56630. private _generateHemisphere;
  56631. private _createSSAOPostProcess;
  56632. private _createSSAOCombinePostProcess;
  56633. private _createRandomTexture;
  56634. /**
  56635. * Serialize the rendering pipeline (Used when exporting)
  56636. * @returns the serialized object
  56637. */
  56638. serialize(): any;
  56639. /**
  56640. * Parse the serialized pipeline
  56641. * @param source Source pipeline.
  56642. * @param scene The scene to load the pipeline to.
  56643. * @param rootUrl The URL of the serialized pipeline.
  56644. * @returns An instantiated pipeline from the serialized object.
  56645. */
  56646. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56647. }
  56648. }
  56649. declare module "babylonjs/Shaders/ssao.fragment" {
  56650. /** @hidden */
  56651. export var ssaoPixelShader: {
  56652. name: string;
  56653. shader: string;
  56654. };
  56655. }
  56656. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56657. import { Camera } from "babylonjs/Cameras/camera";
  56658. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56659. import { Scene } from "babylonjs/scene";
  56660. import "babylonjs/Shaders/ssao.fragment";
  56661. import "babylonjs/Shaders/ssaoCombine.fragment";
  56662. /**
  56663. * Render pipeline to produce ssao effect
  56664. */
  56665. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56666. /**
  56667. * @ignore
  56668. * The PassPostProcess id in the pipeline that contains the original scene color
  56669. */
  56670. SSAOOriginalSceneColorEffect: string;
  56671. /**
  56672. * @ignore
  56673. * The SSAO PostProcess id in the pipeline
  56674. */
  56675. SSAORenderEffect: string;
  56676. /**
  56677. * @ignore
  56678. * The horizontal blur PostProcess id in the pipeline
  56679. */
  56680. SSAOBlurHRenderEffect: string;
  56681. /**
  56682. * @ignore
  56683. * The vertical blur PostProcess id in the pipeline
  56684. */
  56685. SSAOBlurVRenderEffect: string;
  56686. /**
  56687. * @ignore
  56688. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56689. */
  56690. SSAOCombineRenderEffect: string;
  56691. /**
  56692. * The output strength of the SSAO post-process. Default value is 1.0.
  56693. */
  56694. totalStrength: number;
  56695. /**
  56696. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56697. */
  56698. radius: number;
  56699. /**
  56700. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56701. * Must not be equal to fallOff and superior to fallOff.
  56702. * Default value is 0.0075
  56703. */
  56704. area: number;
  56705. /**
  56706. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56707. * Must not be equal to area and inferior to area.
  56708. * Default value is 0.000001
  56709. */
  56710. fallOff: 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. private _scene;
  56717. private _depthTexture;
  56718. private _randomTexture;
  56719. private _originalColorPostProcess;
  56720. private _ssaoPostProcess;
  56721. private _blurHPostProcess;
  56722. private _blurVPostProcess;
  56723. private _ssaoCombinePostProcess;
  56724. private _firstUpdate;
  56725. /**
  56726. * Gets active scene
  56727. */
  56728. readonly scene: Scene;
  56729. /**
  56730. * @constructor
  56731. * @param name - The rendering pipeline name
  56732. * @param scene - The scene linked to this pipeline
  56733. * @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 }
  56734. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56735. */
  56736. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56737. /**
  56738. * Get the class name
  56739. * @returns "SSAORenderingPipeline"
  56740. */
  56741. getClassName(): string;
  56742. /**
  56743. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56744. */
  56745. dispose(disableDepthRender?: boolean): void;
  56746. private _createBlurPostProcess;
  56747. /** @hidden */
  56748. _rebuild(): void;
  56749. private _createSSAOPostProcess;
  56750. private _createSSAOCombinePostProcess;
  56751. private _createRandomTexture;
  56752. }
  56753. }
  56754. declare module "babylonjs/Shaders/standard.fragment" {
  56755. /** @hidden */
  56756. export var standardPixelShader: {
  56757. name: string;
  56758. shader: string;
  56759. };
  56760. }
  56761. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56762. import { Nullable } from "babylonjs/types";
  56763. import { IAnimatable } from "babylonjs/Misc/tools";
  56764. import { Camera } from "babylonjs/Cameras/camera";
  56765. import { Texture } from "babylonjs/Materials/Textures/texture";
  56766. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56767. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56768. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56769. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56770. import { IDisposable } from "babylonjs/scene";
  56771. import { SpotLight } from "babylonjs/Lights/spotLight";
  56772. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56773. import { Scene } from "babylonjs/scene";
  56774. import { Animation } from "babylonjs/Animations/animation";
  56775. import "babylonjs/Shaders/standard.fragment";
  56776. /**
  56777. * Standard rendering pipeline
  56778. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56779. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56780. */
  56781. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56782. /**
  56783. * Public members
  56784. */
  56785. /**
  56786. * Post-process which contains the original scene color before the pipeline applies all the effects
  56787. */
  56788. originalPostProcess: Nullable<PostProcess>;
  56789. /**
  56790. * Post-process used to down scale an image x4
  56791. */
  56792. downSampleX4PostProcess: Nullable<PostProcess>;
  56793. /**
  56794. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56795. */
  56796. brightPassPostProcess: Nullable<PostProcess>;
  56797. /**
  56798. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56799. */
  56800. blurHPostProcesses: PostProcess[];
  56801. /**
  56802. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56803. */
  56804. blurVPostProcesses: PostProcess[];
  56805. /**
  56806. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56807. */
  56808. textureAdderPostProcess: Nullable<PostProcess>;
  56809. /**
  56810. * Post-process used to create volumetric lighting effect
  56811. */
  56812. volumetricLightPostProcess: Nullable<PostProcess>;
  56813. /**
  56814. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56815. */
  56816. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56817. /**
  56818. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56819. */
  56820. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56821. /**
  56822. * Post-process used to merge the volumetric light effect and the real scene color
  56823. */
  56824. volumetricLightMergePostProces: Nullable<PostProcess>;
  56825. /**
  56826. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56827. */
  56828. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56829. /**
  56830. * Base post-process used to calculate the average luminance of the final image for HDR
  56831. */
  56832. luminancePostProcess: Nullable<PostProcess>;
  56833. /**
  56834. * Post-processes used to create down sample post-processes in order to get
  56835. * the average luminance of the final image for HDR
  56836. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56837. */
  56838. luminanceDownSamplePostProcesses: PostProcess[];
  56839. /**
  56840. * Post-process used to create a HDR effect (light adaptation)
  56841. */
  56842. hdrPostProcess: Nullable<PostProcess>;
  56843. /**
  56844. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56845. */
  56846. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56847. /**
  56848. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56849. */
  56850. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56851. /**
  56852. * Post-process used to merge the final HDR post-process and the real scene color
  56853. */
  56854. hdrFinalPostProcess: Nullable<PostProcess>;
  56855. /**
  56856. * Post-process used to create a lens flare effect
  56857. */
  56858. lensFlarePostProcess: Nullable<PostProcess>;
  56859. /**
  56860. * Post-process that merges the result of the lens flare post-process and the real scene color
  56861. */
  56862. lensFlareComposePostProcess: Nullable<PostProcess>;
  56863. /**
  56864. * Post-process used to create a motion blur effect
  56865. */
  56866. motionBlurPostProcess: Nullable<PostProcess>;
  56867. /**
  56868. * Post-process used to create a depth of field effect
  56869. */
  56870. depthOfFieldPostProcess: Nullable<PostProcess>;
  56871. /**
  56872. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56873. */
  56874. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56875. /**
  56876. * Represents the brightness threshold in order to configure the illuminated surfaces
  56877. */
  56878. brightThreshold: number;
  56879. /**
  56880. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56881. */
  56882. blurWidth: number;
  56883. /**
  56884. * Sets if the blur for highlighted surfaces must be only horizontal
  56885. */
  56886. horizontalBlur: boolean;
  56887. /**
  56888. * Gets the overall exposure used by the pipeline
  56889. */
  56890. /**
  56891. * Sets the overall exposure used by the pipeline
  56892. */
  56893. exposure: number;
  56894. /**
  56895. * Texture used typically to simulate "dirty" on camera lens
  56896. */
  56897. lensTexture: Nullable<Texture>;
  56898. /**
  56899. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56900. */
  56901. volumetricLightCoefficient: number;
  56902. /**
  56903. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56904. */
  56905. volumetricLightPower: number;
  56906. /**
  56907. * Used the set the blur intensity to smooth the volumetric lights
  56908. */
  56909. volumetricLightBlurScale: number;
  56910. /**
  56911. * Light (spot or directional) used to generate the volumetric lights rays
  56912. * The source light must have a shadow generate so the pipeline can get its
  56913. * depth map
  56914. */
  56915. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56916. /**
  56917. * For eye adaptation, represents the minimum luminance the eye can see
  56918. */
  56919. hdrMinimumLuminance: number;
  56920. /**
  56921. * For eye adaptation, represents the decrease luminance speed
  56922. */
  56923. hdrDecreaseRate: number;
  56924. /**
  56925. * For eye adaptation, represents the increase luminance speed
  56926. */
  56927. hdrIncreaseRate: number;
  56928. /**
  56929. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56930. */
  56931. /**
  56932. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56933. */
  56934. hdrAutoExposure: boolean;
  56935. /**
  56936. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56937. */
  56938. lensColorTexture: Nullable<Texture>;
  56939. /**
  56940. * The overall strengh for the lens flare effect
  56941. */
  56942. lensFlareStrength: number;
  56943. /**
  56944. * Dispersion coefficient for lens flare ghosts
  56945. */
  56946. lensFlareGhostDispersal: number;
  56947. /**
  56948. * Main lens flare halo width
  56949. */
  56950. lensFlareHaloWidth: number;
  56951. /**
  56952. * Based on the lens distortion effect, defines how much the lens flare result
  56953. * is distorted
  56954. */
  56955. lensFlareDistortionStrength: number;
  56956. /**
  56957. * Lens star texture must be used to simulate rays on the flares and is available
  56958. * in the documentation
  56959. */
  56960. lensStarTexture: Nullable<Texture>;
  56961. /**
  56962. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56963. * flare effect by taking account of the dirt texture
  56964. */
  56965. lensFlareDirtTexture: Nullable<Texture>;
  56966. /**
  56967. * Represents the focal length for the depth of field effect
  56968. */
  56969. depthOfFieldDistance: number;
  56970. /**
  56971. * Represents the blur intensity for the blurred part of the depth of field effect
  56972. */
  56973. depthOfFieldBlurWidth: number;
  56974. /**
  56975. * For motion blur, defines how much the image is blurred by the movement
  56976. */
  56977. motionStrength: number;
  56978. /**
  56979. * List of animations for the pipeline (IAnimatable implementation)
  56980. */
  56981. animations: Animation[];
  56982. /**
  56983. * Private members
  56984. */
  56985. private _scene;
  56986. private _currentDepthOfFieldSource;
  56987. private _basePostProcess;
  56988. private _fixedExposure;
  56989. private _currentExposure;
  56990. private _hdrAutoExposure;
  56991. private _hdrCurrentLuminance;
  56992. private _floatTextureType;
  56993. private _ratio;
  56994. private _bloomEnabled;
  56995. private _depthOfFieldEnabled;
  56996. private _vlsEnabled;
  56997. private _lensFlareEnabled;
  56998. private _hdrEnabled;
  56999. private _motionBlurEnabled;
  57000. private _fxaaEnabled;
  57001. private _motionBlurSamples;
  57002. private _volumetricLightStepsCount;
  57003. private _samples;
  57004. /**
  57005. * @ignore
  57006. * Specifies if the bloom pipeline is enabled
  57007. */
  57008. BloomEnabled: boolean;
  57009. /**
  57010. * @ignore
  57011. * Specifies if the depth of field pipeline is enabed
  57012. */
  57013. DepthOfFieldEnabled: boolean;
  57014. /**
  57015. * @ignore
  57016. * Specifies if the lens flare pipeline is enabed
  57017. */
  57018. LensFlareEnabled: boolean;
  57019. /**
  57020. * @ignore
  57021. * Specifies if the HDR pipeline is enabled
  57022. */
  57023. HDREnabled: boolean;
  57024. /**
  57025. * @ignore
  57026. * Specifies if the volumetric lights scattering effect is enabled
  57027. */
  57028. VLSEnabled: boolean;
  57029. /**
  57030. * @ignore
  57031. * Specifies if the motion blur effect is enabled
  57032. */
  57033. MotionBlurEnabled: boolean;
  57034. /**
  57035. * Specifies if anti-aliasing is enabled
  57036. */
  57037. fxaaEnabled: boolean;
  57038. /**
  57039. * Specifies the number of steps used to calculate the volumetric lights
  57040. * Typically in interval [50, 200]
  57041. */
  57042. volumetricLightStepsCount: number;
  57043. /**
  57044. * Specifies the number of samples used for the motion blur effect
  57045. * Typically in interval [16, 64]
  57046. */
  57047. motionBlurSamples: number;
  57048. /**
  57049. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57050. */
  57051. samples: number;
  57052. /**
  57053. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57054. * @constructor
  57055. * @param name The rendering pipeline name
  57056. * @param scene The scene linked to this pipeline
  57057. * @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)
  57058. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57059. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57060. */
  57061. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57062. private _buildPipeline;
  57063. private _createDownSampleX4PostProcess;
  57064. private _createBrightPassPostProcess;
  57065. private _createBlurPostProcesses;
  57066. private _createTextureAdderPostProcess;
  57067. private _createVolumetricLightPostProcess;
  57068. private _createLuminancePostProcesses;
  57069. private _createHdrPostProcess;
  57070. private _createLensFlarePostProcess;
  57071. private _createDepthOfFieldPostProcess;
  57072. private _createMotionBlurPostProcess;
  57073. private _getDepthTexture;
  57074. private _disposePostProcesses;
  57075. /**
  57076. * Dispose of the pipeline and stop all post processes
  57077. */
  57078. dispose(): void;
  57079. /**
  57080. * Serialize the rendering pipeline (Used when exporting)
  57081. * @returns the serialized object
  57082. */
  57083. serialize(): any;
  57084. /**
  57085. * Parse the serialized pipeline
  57086. * @param source Source pipeline.
  57087. * @param scene The scene to load the pipeline to.
  57088. * @param rootUrl The URL of the serialized pipeline.
  57089. * @returns An instantiated pipeline from the serialized object.
  57090. */
  57091. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57092. /**
  57093. * Luminance steps
  57094. */
  57095. static LuminanceSteps: number;
  57096. }
  57097. }
  57098. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57099. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57100. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57101. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57102. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57103. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57104. }
  57105. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57106. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57107. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57108. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57109. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57110. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57111. }
  57112. declare module "babylonjs/Shaders/tonemap.fragment" {
  57113. /** @hidden */
  57114. export var tonemapPixelShader: {
  57115. name: string;
  57116. shader: string;
  57117. };
  57118. }
  57119. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57120. import { Camera } from "babylonjs/Cameras/camera";
  57121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57122. import "babylonjs/Shaders/tonemap.fragment";
  57123. import { Engine } from "babylonjs/Engines/engine";
  57124. /** Defines operator used for tonemapping */
  57125. export enum TonemappingOperator {
  57126. /** Hable */
  57127. Hable = 0,
  57128. /** Reinhard */
  57129. Reinhard = 1,
  57130. /** HejiDawson */
  57131. HejiDawson = 2,
  57132. /** Photographic */
  57133. Photographic = 3
  57134. }
  57135. /**
  57136. * Defines a post process to apply tone mapping
  57137. */
  57138. export class TonemapPostProcess extends PostProcess {
  57139. private _operator;
  57140. /** Defines the required exposure adjustement */
  57141. exposureAdjustment: number;
  57142. /**
  57143. * Creates a new TonemapPostProcess
  57144. * @param name defines the name of the postprocess
  57145. * @param _operator defines the operator to use
  57146. * @param exposureAdjustment defines the required exposure adjustement
  57147. * @param camera defines the camera to use (can be null)
  57148. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57149. * @param engine defines the hosting engine (can be ignore if camera is set)
  57150. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57151. */
  57152. constructor(name: string, _operator: TonemappingOperator,
  57153. /** Defines the required exposure adjustement */
  57154. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57155. }
  57156. }
  57157. declare module "babylonjs/Shaders/depth.vertex" {
  57158. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57159. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57162. /** @hidden */
  57163. export var depthVertexShader: {
  57164. name: string;
  57165. shader: string;
  57166. };
  57167. }
  57168. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57169. /** @hidden */
  57170. export var volumetricLightScatteringPixelShader: {
  57171. name: string;
  57172. shader: string;
  57173. };
  57174. }
  57175. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57176. /** @hidden */
  57177. export var volumetricLightScatteringPassPixelShader: {
  57178. name: string;
  57179. shader: string;
  57180. };
  57181. }
  57182. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57183. import { Vector3 } from "babylonjs/Maths/math";
  57184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57185. import { Mesh } from "babylonjs/Meshes/mesh";
  57186. import { Camera } from "babylonjs/Cameras/camera";
  57187. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57189. import { Scene } from "babylonjs/scene";
  57190. import "babylonjs/Meshes/Builders/planeBuilder";
  57191. import "babylonjs/Shaders/depth.vertex";
  57192. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57193. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57194. import { Engine } from "babylonjs/Engines/engine";
  57195. /**
  57196. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57197. */
  57198. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57199. private _volumetricLightScatteringPass;
  57200. private _volumetricLightScatteringRTT;
  57201. private _viewPort;
  57202. private _screenCoordinates;
  57203. private _cachedDefines;
  57204. /**
  57205. * If not undefined, the mesh position is computed from the attached node position
  57206. */
  57207. attachedNode: {
  57208. position: Vector3;
  57209. };
  57210. /**
  57211. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57212. */
  57213. customMeshPosition: Vector3;
  57214. /**
  57215. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57216. */
  57217. useCustomMeshPosition: boolean;
  57218. /**
  57219. * If the post-process should inverse the light scattering direction
  57220. */
  57221. invert: boolean;
  57222. /**
  57223. * The internal mesh used by the post-process
  57224. */
  57225. mesh: Mesh;
  57226. /**
  57227. * @hidden
  57228. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57229. */
  57230. useDiffuseColor: boolean;
  57231. /**
  57232. * Array containing the excluded meshes not rendered in the internal pass
  57233. */
  57234. excludedMeshes: AbstractMesh[];
  57235. /**
  57236. * Controls the overall intensity of the post-process
  57237. */
  57238. exposure: number;
  57239. /**
  57240. * Dissipates each sample's contribution in range [0, 1]
  57241. */
  57242. decay: number;
  57243. /**
  57244. * Controls the overall intensity of each sample
  57245. */
  57246. weight: number;
  57247. /**
  57248. * Controls the density of each sample
  57249. */
  57250. density: number;
  57251. /**
  57252. * @constructor
  57253. * @param name The post-process name
  57254. * @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)
  57255. * @param camera The camera that the post-process will be attached to
  57256. * @param mesh The mesh used to create the light scattering
  57257. * @param samples The post-process quality, default 100
  57258. * @param samplingModeThe post-process filtering mode
  57259. * @param engine The babylon engine
  57260. * @param reusable If the post-process is reusable
  57261. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57262. */
  57263. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57264. /**
  57265. * Returns the string "VolumetricLightScatteringPostProcess"
  57266. * @returns "VolumetricLightScatteringPostProcess"
  57267. */
  57268. getClassName(): string;
  57269. private _isReady;
  57270. /**
  57271. * Sets the new light position for light scattering effect
  57272. * @param position The new custom light position
  57273. */
  57274. setCustomMeshPosition(position: Vector3): void;
  57275. /**
  57276. * Returns the light position for light scattering effect
  57277. * @return Vector3 The custom light position
  57278. */
  57279. getCustomMeshPosition(): Vector3;
  57280. /**
  57281. * Disposes the internal assets and detaches the post-process from the camera
  57282. */
  57283. dispose(camera: Camera): void;
  57284. /**
  57285. * Returns the render target texture used by the post-process
  57286. * @return the render target texture used by the post-process
  57287. */
  57288. getPass(): RenderTargetTexture;
  57289. private _meshExcluded;
  57290. private _createPass;
  57291. private _updateMeshScreenCoordinates;
  57292. /**
  57293. * Creates a default mesh for the Volumeric Light Scattering post-process
  57294. * @param name The mesh name
  57295. * @param scene The scene where to create the mesh
  57296. * @return the default mesh
  57297. */
  57298. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57299. }
  57300. }
  57301. declare module "babylonjs/PostProcesses/index" {
  57302. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57303. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57304. export * from "babylonjs/PostProcesses/bloomEffect";
  57305. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57306. export * from "babylonjs/PostProcesses/blurPostProcess";
  57307. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57308. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57309. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57310. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57311. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57312. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57313. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57314. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57315. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57316. export * from "babylonjs/PostProcesses/filterPostProcess";
  57317. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57318. export * from "babylonjs/PostProcesses/grainPostProcess";
  57319. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57320. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57321. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57322. export * from "babylonjs/PostProcesses/passPostProcess";
  57323. export * from "babylonjs/PostProcesses/postProcess";
  57324. export * from "babylonjs/PostProcesses/postProcessManager";
  57325. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57326. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57327. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57328. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57329. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57330. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57331. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57332. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57333. }
  57334. declare module "babylonjs/Probes/index" {
  57335. export * from "babylonjs/Probes/reflectionProbe";
  57336. }
  57337. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57338. import { Scene } from "babylonjs/scene";
  57339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57340. import { Color3 } from "babylonjs/Maths/math";
  57341. import { SmartArray } from "babylonjs/Misc/smartArray";
  57342. import { ISceneComponent } from "babylonjs/sceneComponent";
  57343. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57344. import "babylonjs/Meshes/Builders/boxBuilder";
  57345. import "babylonjs/Shaders/color.fragment";
  57346. import "babylonjs/Shaders/color.vertex";
  57347. module "babylonjs/scene" {
  57348. interface Scene {
  57349. /** @hidden (Backing field) */
  57350. _boundingBoxRenderer: BoundingBoxRenderer;
  57351. /** @hidden (Backing field) */
  57352. _forceShowBoundingBoxes: boolean;
  57353. /**
  57354. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57355. */
  57356. forceShowBoundingBoxes: boolean;
  57357. /**
  57358. * Gets the bounding box renderer associated with the scene
  57359. * @returns a BoundingBoxRenderer
  57360. */
  57361. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57362. }
  57363. }
  57364. module "babylonjs/Meshes/abstractMesh" {
  57365. interface AbstractMesh {
  57366. /** @hidden (Backing field) */
  57367. _showBoundingBox: boolean;
  57368. /**
  57369. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57370. */
  57371. showBoundingBox: boolean;
  57372. }
  57373. }
  57374. /**
  57375. * Component responsible of rendering the bounding box of the meshes in a scene.
  57376. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57377. */
  57378. export class BoundingBoxRenderer implements ISceneComponent {
  57379. /**
  57380. * The component name helpfull to identify the component in the list of scene components.
  57381. */
  57382. readonly name: string;
  57383. /**
  57384. * The scene the component belongs to.
  57385. */
  57386. scene: Scene;
  57387. /**
  57388. * Color of the bounding box lines placed in front of an object
  57389. */
  57390. frontColor: Color3;
  57391. /**
  57392. * Color of the bounding box lines placed behind an object
  57393. */
  57394. backColor: Color3;
  57395. /**
  57396. * Defines if the renderer should show the back lines or not
  57397. */
  57398. showBackLines: boolean;
  57399. /**
  57400. * @hidden
  57401. */
  57402. renderList: SmartArray<BoundingBox>;
  57403. private _colorShader;
  57404. private _vertexBuffers;
  57405. private _indexBuffer;
  57406. /**
  57407. * Instantiates a new bounding box renderer in a scene.
  57408. * @param scene the scene the renderer renders in
  57409. */
  57410. constructor(scene: Scene);
  57411. /**
  57412. * Registers the component in a given scene
  57413. */
  57414. register(): void;
  57415. private _evaluateSubMesh;
  57416. private _activeMesh;
  57417. private _prepareRessources;
  57418. private _createIndexBuffer;
  57419. /**
  57420. * Rebuilds the elements related to this component in case of
  57421. * context lost for instance.
  57422. */
  57423. rebuild(): void;
  57424. /**
  57425. * @hidden
  57426. */
  57427. reset(): void;
  57428. /**
  57429. * Render the bounding boxes of a specific rendering group
  57430. * @param renderingGroupId defines the rendering group to render
  57431. */
  57432. render(renderingGroupId: number): void;
  57433. /**
  57434. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57435. * @param mesh Define the mesh to render the occlusion bounding box for
  57436. */
  57437. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57438. /**
  57439. * Dispose and release the resources attached to this renderer.
  57440. */
  57441. dispose(): void;
  57442. }
  57443. }
  57444. declare module "babylonjs/Shaders/depth.fragment" {
  57445. /** @hidden */
  57446. export var depthPixelShader: {
  57447. name: string;
  57448. shader: string;
  57449. };
  57450. }
  57451. declare module "babylonjs/Rendering/depthRenderer" {
  57452. import { Nullable } from "babylonjs/types";
  57453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57454. import { Scene } from "babylonjs/scene";
  57455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57456. import { Camera } from "babylonjs/Cameras/camera";
  57457. import "babylonjs/Shaders/depth.fragment";
  57458. import "babylonjs/Shaders/depth.vertex";
  57459. /**
  57460. * This represents a depth renderer in Babylon.
  57461. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57462. */
  57463. export class DepthRenderer {
  57464. private _scene;
  57465. private _depthMap;
  57466. private _effect;
  57467. private _cachedDefines;
  57468. private _camera;
  57469. /**
  57470. * Specifiess that the depth renderer will only be used within
  57471. * the camera it is created for.
  57472. * This can help forcing its rendering during the camera processing.
  57473. */
  57474. useOnlyInActiveCamera: boolean;
  57475. /** @hidden */
  57476. static _SceneComponentInitialization: (scene: Scene) => void;
  57477. /**
  57478. * Instantiates a depth renderer
  57479. * @param scene The scene the renderer belongs to
  57480. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57481. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57482. */
  57483. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57484. /**
  57485. * Creates the depth rendering effect and checks if the effect is ready.
  57486. * @param subMesh The submesh to be used to render the depth map of
  57487. * @param useInstances If multiple world instances should be used
  57488. * @returns if the depth renderer is ready to render the depth map
  57489. */
  57490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57491. /**
  57492. * Gets the texture which the depth map will be written to.
  57493. * @returns The depth map texture
  57494. */
  57495. getDepthMap(): RenderTargetTexture;
  57496. /**
  57497. * Disposes of the depth renderer.
  57498. */
  57499. dispose(): void;
  57500. }
  57501. }
  57502. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57503. import { Nullable } from "babylonjs/types";
  57504. import { Scene } from "babylonjs/scene";
  57505. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57506. import { Camera } from "babylonjs/Cameras/camera";
  57507. import { ISceneComponent } from "babylonjs/sceneComponent";
  57508. module "babylonjs/scene" {
  57509. interface Scene {
  57510. /** @hidden (Backing field) */
  57511. _depthRenderer: {
  57512. [id: string]: DepthRenderer;
  57513. };
  57514. /**
  57515. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57516. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57517. * @returns the created depth renderer
  57518. */
  57519. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57520. /**
  57521. * Disables a depth renderer for a given camera
  57522. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57523. */
  57524. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57525. }
  57526. }
  57527. /**
  57528. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57529. * in several rendering techniques.
  57530. */
  57531. export class DepthRendererSceneComponent implements ISceneComponent {
  57532. /**
  57533. * The component name helpfull to identify the component in the list of scene components.
  57534. */
  57535. readonly name: string;
  57536. /**
  57537. * The scene the component belongs to.
  57538. */
  57539. scene: Scene;
  57540. /**
  57541. * Creates a new instance of the component for the given scene
  57542. * @param scene Defines the scene to register the component in
  57543. */
  57544. constructor(scene: Scene);
  57545. /**
  57546. * Registers the component in a given scene
  57547. */
  57548. register(): void;
  57549. /**
  57550. * Rebuilds the elements related to this component in case of
  57551. * context lost for instance.
  57552. */
  57553. rebuild(): void;
  57554. /**
  57555. * Disposes the component and the associated ressources
  57556. */
  57557. dispose(): void;
  57558. private _gatherRenderTargets;
  57559. private _gatherActiveCameraRenderTargets;
  57560. }
  57561. }
  57562. declare module "babylonjs/Shaders/outline.fragment" {
  57563. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57564. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57565. /** @hidden */
  57566. export var outlinePixelShader: {
  57567. name: string;
  57568. shader: string;
  57569. };
  57570. }
  57571. declare module "babylonjs/Shaders/outline.vertex" {
  57572. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57573. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57574. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57575. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57576. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57577. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57578. /** @hidden */
  57579. export var outlineVertexShader: {
  57580. name: string;
  57581. shader: string;
  57582. };
  57583. }
  57584. declare module "babylonjs/Rendering/outlineRenderer" {
  57585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57586. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57587. import { Scene } from "babylonjs/scene";
  57588. import { ISceneComponent } from "babylonjs/sceneComponent";
  57589. import "babylonjs/Shaders/outline.fragment";
  57590. import "babylonjs/Shaders/outline.vertex";
  57591. module "babylonjs/scene" {
  57592. interface Scene {
  57593. /** @hidden */
  57594. _outlineRenderer: OutlineRenderer;
  57595. /**
  57596. * Gets the outline renderer associated with the scene
  57597. * @returns a OutlineRenderer
  57598. */
  57599. getOutlineRenderer(): OutlineRenderer;
  57600. }
  57601. }
  57602. module "babylonjs/Meshes/abstractMesh" {
  57603. interface AbstractMesh {
  57604. /** @hidden (Backing field) */
  57605. _renderOutline: boolean;
  57606. /**
  57607. * Gets or sets a boolean indicating if the outline must be rendered as well
  57608. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57609. */
  57610. renderOutline: boolean;
  57611. /** @hidden (Backing field) */
  57612. _renderOverlay: boolean;
  57613. /**
  57614. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57615. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57616. */
  57617. renderOverlay: boolean;
  57618. }
  57619. }
  57620. /**
  57621. * This class is responsible to draw bothe outline/overlay of meshes.
  57622. * It should not be used directly but through the available method on mesh.
  57623. */
  57624. export class OutlineRenderer implements ISceneComponent {
  57625. /**
  57626. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57627. */
  57628. private static _StencilReference;
  57629. /**
  57630. * The name of the component. Each component must have a unique name.
  57631. */
  57632. name: string;
  57633. /**
  57634. * The scene the component belongs to.
  57635. */
  57636. scene: Scene;
  57637. /**
  57638. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57639. */
  57640. zOffset: number;
  57641. private _engine;
  57642. private _effect;
  57643. private _cachedDefines;
  57644. private _savedDepthWrite;
  57645. /**
  57646. * Instantiates a new outline renderer. (There could be only one per scene).
  57647. * @param scene Defines the scene it belongs to
  57648. */
  57649. constructor(scene: Scene);
  57650. /**
  57651. * Register the component to one instance of a scene.
  57652. */
  57653. register(): void;
  57654. /**
  57655. * Rebuilds the elements related to this component in case of
  57656. * context lost for instance.
  57657. */
  57658. rebuild(): void;
  57659. /**
  57660. * Disposes the component and the associated ressources.
  57661. */
  57662. dispose(): void;
  57663. /**
  57664. * Renders the outline in the canvas.
  57665. * @param subMesh Defines the sumesh to render
  57666. * @param batch Defines the batch of meshes in case of instances
  57667. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57668. */
  57669. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57670. /**
  57671. * Returns whether or not the outline renderer is ready for a given submesh.
  57672. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57673. * @param subMesh Defines the submesh to check readyness for
  57674. * @param useInstances Defines wheter wee are trying to render instances or not
  57675. * @returns true if ready otherwise false
  57676. */
  57677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57678. private _beforeRenderingMesh;
  57679. private _afterRenderingMesh;
  57680. }
  57681. }
  57682. declare module "babylonjs/Rendering/index" {
  57683. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57684. export * from "babylonjs/Rendering/depthRenderer";
  57685. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57686. export * from "babylonjs/Rendering/edgesRenderer";
  57687. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57688. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57689. export * from "babylonjs/Rendering/outlineRenderer";
  57690. export * from "babylonjs/Rendering/renderingGroup";
  57691. export * from "babylonjs/Rendering/renderingManager";
  57692. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57693. }
  57694. declare module "babylonjs/Sprites/index" {
  57695. export * from "babylonjs/Sprites/sprite";
  57696. export * from "babylonjs/Sprites/spriteManager";
  57697. export * from "babylonjs/Sprites/spriteSceneComponent";
  57698. }
  57699. declare module "babylonjs/Misc/assetsManager" {
  57700. import { Scene } from "babylonjs/scene";
  57701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57703. import { Skeleton } from "babylonjs/Bones/skeleton";
  57704. import { Observable } from "babylonjs/Misc/observable";
  57705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57706. import { Texture } from "babylonjs/Materials/Textures/texture";
  57707. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57708. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57709. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57710. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57711. /**
  57712. * Defines the list of states available for a task inside a AssetsManager
  57713. */
  57714. export enum AssetTaskState {
  57715. /**
  57716. * Initialization
  57717. */
  57718. INIT = 0,
  57719. /**
  57720. * Running
  57721. */
  57722. RUNNING = 1,
  57723. /**
  57724. * Done
  57725. */
  57726. DONE = 2,
  57727. /**
  57728. * Error
  57729. */
  57730. ERROR = 3
  57731. }
  57732. /**
  57733. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57734. */
  57735. export abstract class AbstractAssetTask {
  57736. /**
  57737. * Task name
  57738. */ name: string;
  57739. /**
  57740. * Callback called when the task is successful
  57741. */
  57742. onSuccess: (task: any) => void;
  57743. /**
  57744. * Callback called when the task is not successful
  57745. */
  57746. onError: (task: any, message?: string, exception?: any) => void;
  57747. /**
  57748. * Creates a new AssetsManager
  57749. * @param name defines the name of the task
  57750. */
  57751. constructor(
  57752. /**
  57753. * Task name
  57754. */ name: string);
  57755. private _isCompleted;
  57756. private _taskState;
  57757. private _errorObject;
  57758. /**
  57759. * Get if the task is completed
  57760. */
  57761. readonly isCompleted: boolean;
  57762. /**
  57763. * Gets the current state of the task
  57764. */
  57765. readonly taskState: AssetTaskState;
  57766. /**
  57767. * Gets the current error object (if task is in error)
  57768. */
  57769. readonly errorObject: {
  57770. message?: string;
  57771. exception?: any;
  57772. };
  57773. /**
  57774. * Internal only
  57775. * @hidden
  57776. */
  57777. _setErrorObject(message?: string, exception?: any): void;
  57778. /**
  57779. * Execute the current task
  57780. * @param scene defines the scene where you want your assets to be loaded
  57781. * @param onSuccess is a callback called when the task is successfully executed
  57782. * @param onError is a callback called if an error occurs
  57783. */
  57784. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57785. /**
  57786. * Execute the current task
  57787. * @param scene defines the scene where you want your assets to be loaded
  57788. * @param onSuccess is a callback called when the task is successfully executed
  57789. * @param onError is a callback called if an error occurs
  57790. */
  57791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57792. /**
  57793. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57794. * This can be used with failed tasks that have the reason for failure fixed.
  57795. */
  57796. reset(): void;
  57797. private onErrorCallback;
  57798. private onDoneCallback;
  57799. }
  57800. /**
  57801. * Define the interface used by progress events raised during assets loading
  57802. */
  57803. export interface IAssetsProgressEvent {
  57804. /**
  57805. * Defines the number of remaining tasks to process
  57806. */
  57807. remainingCount: number;
  57808. /**
  57809. * Defines the total number of tasks
  57810. */
  57811. totalCount: number;
  57812. /**
  57813. * Defines the task that was just processed
  57814. */
  57815. task: AbstractAssetTask;
  57816. }
  57817. /**
  57818. * Class used to share progress information about assets loading
  57819. */
  57820. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57821. /**
  57822. * Defines the number of remaining tasks to process
  57823. */
  57824. remainingCount: number;
  57825. /**
  57826. * Defines the total number of tasks
  57827. */
  57828. totalCount: number;
  57829. /**
  57830. * Defines the task that was just processed
  57831. */
  57832. task: AbstractAssetTask;
  57833. /**
  57834. * Creates a AssetsProgressEvent
  57835. * @param remainingCount defines the number of remaining tasks to process
  57836. * @param totalCount defines the total number of tasks
  57837. * @param task defines the task that was just processed
  57838. */
  57839. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57840. }
  57841. /**
  57842. * Define a task used by AssetsManager to load meshes
  57843. */
  57844. export class MeshAssetTask extends AbstractAssetTask {
  57845. /**
  57846. * Defines the name of the task
  57847. */
  57848. name: string;
  57849. /**
  57850. * Defines the list of mesh's names you want to load
  57851. */
  57852. meshesNames: any;
  57853. /**
  57854. * Defines the root url to use as a base to load your meshes and associated resources
  57855. */
  57856. rootUrl: string;
  57857. /**
  57858. * Defines the filename of the scene to load from
  57859. */
  57860. sceneFilename: string;
  57861. /**
  57862. * Gets the list of loaded meshes
  57863. */
  57864. loadedMeshes: Array<AbstractMesh>;
  57865. /**
  57866. * Gets the list of loaded particle systems
  57867. */
  57868. loadedParticleSystems: Array<IParticleSystem>;
  57869. /**
  57870. * Gets the list of loaded skeletons
  57871. */
  57872. loadedSkeletons: Array<Skeleton>;
  57873. /**
  57874. * Gets the list of loaded animation groups
  57875. */
  57876. loadedAnimationGroups: Array<AnimationGroup>;
  57877. /**
  57878. * Callback called when the task is successful
  57879. */
  57880. onSuccess: (task: MeshAssetTask) => void;
  57881. /**
  57882. * Callback called when the task is successful
  57883. */
  57884. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57885. /**
  57886. * Creates a new MeshAssetTask
  57887. * @param name defines the name of the task
  57888. * @param meshesNames defines the list of mesh's names you want to load
  57889. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57890. * @param sceneFilename defines the filename of the scene to load from
  57891. */
  57892. constructor(
  57893. /**
  57894. * Defines the name of the task
  57895. */
  57896. name: string,
  57897. /**
  57898. * Defines the list of mesh's names you want to load
  57899. */
  57900. meshesNames: any,
  57901. /**
  57902. * Defines the root url to use as a base to load your meshes and associated resources
  57903. */
  57904. rootUrl: string,
  57905. /**
  57906. * Defines the filename of the scene to load from
  57907. */
  57908. sceneFilename: string);
  57909. /**
  57910. * Execute the current task
  57911. * @param scene defines the scene where you want your assets to be loaded
  57912. * @param onSuccess is a callback called when the task is successfully executed
  57913. * @param onError is a callback called if an error occurs
  57914. */
  57915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57916. }
  57917. /**
  57918. * Define a task used by AssetsManager to load text content
  57919. */
  57920. export class TextFileAssetTask extends AbstractAssetTask {
  57921. /**
  57922. * Defines the name of the task
  57923. */
  57924. name: string;
  57925. /**
  57926. * Defines the location of the file to load
  57927. */
  57928. url: string;
  57929. /**
  57930. * Gets the loaded text string
  57931. */
  57932. text: string;
  57933. /**
  57934. * Callback called when the task is successful
  57935. */
  57936. onSuccess: (task: TextFileAssetTask) => void;
  57937. /**
  57938. * Callback called when the task is successful
  57939. */
  57940. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57941. /**
  57942. * Creates a new TextFileAssetTask object
  57943. * @param name defines the name of the task
  57944. * @param url defines the location of the file to load
  57945. */
  57946. constructor(
  57947. /**
  57948. * Defines the name of the task
  57949. */
  57950. name: string,
  57951. /**
  57952. * Defines the location of the file to load
  57953. */
  57954. url: string);
  57955. /**
  57956. * Execute the current task
  57957. * @param scene defines the scene where you want your assets to be loaded
  57958. * @param onSuccess is a callback called when the task is successfully executed
  57959. * @param onError is a callback called if an error occurs
  57960. */
  57961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57962. }
  57963. /**
  57964. * Define a task used by AssetsManager to load binary data
  57965. */
  57966. export class BinaryFileAssetTask extends AbstractAssetTask {
  57967. /**
  57968. * Defines the name of the task
  57969. */
  57970. name: string;
  57971. /**
  57972. * Defines the location of the file to load
  57973. */
  57974. url: string;
  57975. /**
  57976. * Gets the lodaded data (as an array buffer)
  57977. */
  57978. data: ArrayBuffer;
  57979. /**
  57980. * Callback called when the task is successful
  57981. */
  57982. onSuccess: (task: BinaryFileAssetTask) => void;
  57983. /**
  57984. * Callback called when the task is successful
  57985. */
  57986. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57987. /**
  57988. * Creates a new BinaryFileAssetTask object
  57989. * @param name defines the name of the new task
  57990. * @param url defines the location of the file to load
  57991. */
  57992. constructor(
  57993. /**
  57994. * Defines the name of the task
  57995. */
  57996. name: string,
  57997. /**
  57998. * Defines the location of the file to load
  57999. */
  58000. url: string);
  58001. /**
  58002. * Execute the current task
  58003. * @param scene defines the scene where you want your assets to be loaded
  58004. * @param onSuccess is a callback called when the task is successfully executed
  58005. * @param onError is a callback called if an error occurs
  58006. */
  58007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58008. }
  58009. /**
  58010. * Define a task used by AssetsManager to load images
  58011. */
  58012. export class ImageAssetTask extends AbstractAssetTask {
  58013. /**
  58014. * Defines the name of the task
  58015. */
  58016. name: string;
  58017. /**
  58018. * Defines the location of the image to load
  58019. */
  58020. url: string;
  58021. /**
  58022. * Gets the loaded images
  58023. */
  58024. image: HTMLImageElement;
  58025. /**
  58026. * Callback called when the task is successful
  58027. */
  58028. onSuccess: (task: ImageAssetTask) => void;
  58029. /**
  58030. * Callback called when the task is successful
  58031. */
  58032. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58033. /**
  58034. * Creates a new ImageAssetTask
  58035. * @param name defines the name of the task
  58036. * @param url defines the location of the image to load
  58037. */
  58038. constructor(
  58039. /**
  58040. * Defines the name of the task
  58041. */
  58042. name: string,
  58043. /**
  58044. * Defines the location of the image to load
  58045. */
  58046. url: string);
  58047. /**
  58048. * Execute the current task
  58049. * @param scene defines the scene where you want your assets to be loaded
  58050. * @param onSuccess is a callback called when the task is successfully executed
  58051. * @param onError is a callback called if an error occurs
  58052. */
  58053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58054. }
  58055. /**
  58056. * Defines the interface used by texture loading tasks
  58057. */
  58058. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58059. /**
  58060. * Gets the loaded texture
  58061. */
  58062. texture: TEX;
  58063. }
  58064. /**
  58065. * Define a task used by AssetsManager to load 2D textures
  58066. */
  58067. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58068. /**
  58069. * Defines the name of the task
  58070. */
  58071. name: string;
  58072. /**
  58073. * Defines the location of the file to load
  58074. */
  58075. url: string;
  58076. /**
  58077. * Defines if mipmap should not be generated (default is false)
  58078. */
  58079. noMipmap?: boolean | undefined;
  58080. /**
  58081. * Defines if texture must be inverted on Y axis (default is false)
  58082. */
  58083. invertY?: boolean | undefined;
  58084. /**
  58085. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58086. */
  58087. samplingMode: number;
  58088. /**
  58089. * Gets the loaded texture
  58090. */
  58091. texture: Texture;
  58092. /**
  58093. * Callback called when the task is successful
  58094. */
  58095. onSuccess: (task: TextureAssetTask) => void;
  58096. /**
  58097. * Callback called when the task is successful
  58098. */
  58099. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58100. /**
  58101. * Creates a new TextureAssetTask object
  58102. * @param name defines the name of the task
  58103. * @param url defines the location of the file to load
  58104. * @param noMipmap defines if mipmap should not be generated (default is false)
  58105. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58106. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58107. */
  58108. constructor(
  58109. /**
  58110. * Defines the name of the task
  58111. */
  58112. name: string,
  58113. /**
  58114. * Defines the location of the file to load
  58115. */
  58116. url: string,
  58117. /**
  58118. * Defines if mipmap should not be generated (default is false)
  58119. */
  58120. noMipmap?: boolean | undefined,
  58121. /**
  58122. * Defines if texture must be inverted on Y axis (default is false)
  58123. */
  58124. invertY?: boolean | undefined,
  58125. /**
  58126. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58127. */
  58128. samplingMode?: number);
  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 cube textures
  58139. */
  58140. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58141. /**
  58142. * Defines the name of the task
  58143. */
  58144. name: string;
  58145. /**
  58146. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58147. */
  58148. url: string;
  58149. /**
  58150. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58151. */
  58152. extensions?: string[] | undefined;
  58153. /**
  58154. * Defines if mipmaps should not be generated (default is false)
  58155. */
  58156. noMipmap?: boolean | undefined;
  58157. /**
  58158. * Defines the explicit list of files (undefined by default)
  58159. */
  58160. files?: string[] | undefined;
  58161. /**
  58162. * Gets the loaded texture
  58163. */
  58164. texture: CubeTexture;
  58165. /**
  58166. * Callback called when the task is successful
  58167. */
  58168. onSuccess: (task: CubeTextureAssetTask) => void;
  58169. /**
  58170. * Callback called when the task is successful
  58171. */
  58172. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58173. /**
  58174. * Creates a new CubeTextureAssetTask
  58175. * @param name defines the name of the task
  58176. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58177. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58178. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58179. * @param files defines the explicit list of files (undefined by default)
  58180. */
  58181. constructor(
  58182. /**
  58183. * Defines the name of the task
  58184. */
  58185. name: string,
  58186. /**
  58187. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58188. */
  58189. url: string,
  58190. /**
  58191. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58192. */
  58193. extensions?: string[] | undefined,
  58194. /**
  58195. * Defines if mipmaps should not be generated (default is false)
  58196. */
  58197. noMipmap?: boolean | undefined,
  58198. /**
  58199. * Defines the explicit list of files (undefined by default)
  58200. */
  58201. files?: string[] | undefined);
  58202. /**
  58203. * Execute the current task
  58204. * @param scene defines the scene where you want your assets to be loaded
  58205. * @param onSuccess is a callback called when the task is successfully executed
  58206. * @param onError is a callback called if an error occurs
  58207. */
  58208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58209. }
  58210. /**
  58211. * Define a task used by AssetsManager to load HDR cube textures
  58212. */
  58213. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58214. /**
  58215. * Defines the name of the task
  58216. */
  58217. name: string;
  58218. /**
  58219. * Defines the location of the file to load
  58220. */
  58221. url: string;
  58222. /**
  58223. * Defines the desired size (the more it increases the longer the generation will be)
  58224. */
  58225. size: number;
  58226. /**
  58227. * Defines if mipmaps should not be generated (default is false)
  58228. */
  58229. noMipmap: boolean;
  58230. /**
  58231. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58232. */
  58233. generateHarmonics: boolean;
  58234. /**
  58235. * 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)
  58236. */
  58237. gammaSpace: boolean;
  58238. /**
  58239. * Internal Use Only
  58240. */
  58241. reserved: boolean;
  58242. /**
  58243. * Gets the loaded texture
  58244. */
  58245. texture: HDRCubeTexture;
  58246. /**
  58247. * Callback called when the task is successful
  58248. */
  58249. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58250. /**
  58251. * Callback called when the task is successful
  58252. */
  58253. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58254. /**
  58255. * Creates a new HDRCubeTextureAssetTask object
  58256. * @param name defines the name of the task
  58257. * @param url defines the location of the file to load
  58258. * @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.
  58259. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58260. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58261. * @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)
  58262. * @param reserved Internal use only
  58263. */
  58264. constructor(
  58265. /**
  58266. * Defines the name of the task
  58267. */
  58268. name: string,
  58269. /**
  58270. * Defines the location of the file to load
  58271. */
  58272. url: string,
  58273. /**
  58274. * Defines the desired size (the more it increases the longer the generation will be)
  58275. */
  58276. size: number,
  58277. /**
  58278. * Defines if mipmaps should not be generated (default is false)
  58279. */
  58280. noMipmap?: boolean,
  58281. /**
  58282. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58283. */
  58284. generateHarmonics?: boolean,
  58285. /**
  58286. * 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)
  58287. */
  58288. gammaSpace?: boolean,
  58289. /**
  58290. * Internal Use Only
  58291. */
  58292. reserved?: boolean);
  58293. /**
  58294. * Execute the current task
  58295. * @param scene defines the scene where you want your assets to be loaded
  58296. * @param onSuccess is a callback called when the task is successfully executed
  58297. * @param onError is a callback called if an error occurs
  58298. */
  58299. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58300. }
  58301. /**
  58302. * Define a task used by AssetsManager to load Equirectangular cube textures
  58303. */
  58304. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58305. /**
  58306. * Defines the name of the task
  58307. */
  58308. name: string;
  58309. /**
  58310. * Defines the location of the file to load
  58311. */
  58312. url: string;
  58313. /**
  58314. * Defines the desired size (the more it increases the longer the generation will be)
  58315. */
  58316. size: number;
  58317. /**
  58318. * Defines if mipmaps should not be generated (default is false)
  58319. */
  58320. noMipmap: boolean;
  58321. /**
  58322. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58323. * but the standard material would require them in Gamma space) (default is true)
  58324. */
  58325. gammaSpace: boolean;
  58326. /**
  58327. * Gets the loaded texture
  58328. */
  58329. texture: EquiRectangularCubeTexture;
  58330. /**
  58331. * Callback called when the task is successful
  58332. */
  58333. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58334. /**
  58335. * Callback called when the task is successful
  58336. */
  58337. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58338. /**
  58339. * Creates a new EquiRectangularCubeTextureAssetTask object
  58340. * @param name defines the name of the task
  58341. * @param url defines the location of the file to load
  58342. * @param size defines the desired size (the more it increases the longer the generation will be)
  58343. * If the size is omitted this implies you are using a preprocessed cubemap.
  58344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58345. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58346. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58347. * (default is true)
  58348. */
  58349. constructor(
  58350. /**
  58351. * Defines the name of the task
  58352. */
  58353. name: string,
  58354. /**
  58355. * Defines the location of the file to load
  58356. */
  58357. url: string,
  58358. /**
  58359. * Defines the desired size (the more it increases the longer the generation will be)
  58360. */
  58361. size: number,
  58362. /**
  58363. * Defines if mipmaps should not be generated (default is false)
  58364. */
  58365. noMipmap?: boolean,
  58366. /**
  58367. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58368. * but the standard material would require them in Gamma space) (default is true)
  58369. */
  58370. gammaSpace?: boolean);
  58371. /**
  58372. * Execute the current task
  58373. * @param scene defines the scene where you want your assets to be loaded
  58374. * @param onSuccess is a callback called when the task is successfully executed
  58375. * @param onError is a callback called if an error occurs
  58376. */
  58377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58378. }
  58379. /**
  58380. * This class can be used to easily import assets into a scene
  58381. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58382. */
  58383. export class AssetsManager {
  58384. private _scene;
  58385. private _isLoading;
  58386. protected _tasks: AbstractAssetTask[];
  58387. protected _waitingTasksCount: number;
  58388. protected _totalTasksCount: number;
  58389. /**
  58390. * Callback called when all tasks are processed
  58391. */
  58392. onFinish: (tasks: AbstractAssetTask[]) => void;
  58393. /**
  58394. * Callback called when a task is successful
  58395. */
  58396. onTaskSuccess: (task: AbstractAssetTask) => void;
  58397. /**
  58398. * Callback called when a task had an error
  58399. */
  58400. onTaskError: (task: AbstractAssetTask) => void;
  58401. /**
  58402. * Callback called when a task is done (whatever the result is)
  58403. */
  58404. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58405. /**
  58406. * Observable called when all tasks are processed
  58407. */
  58408. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58409. /**
  58410. * Observable called when a task had an error
  58411. */
  58412. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58413. /**
  58414. * Observable called when all tasks were executed
  58415. */
  58416. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58417. /**
  58418. * Observable called when a task is done (whatever the result is)
  58419. */
  58420. onProgressObservable: Observable<IAssetsProgressEvent>;
  58421. /**
  58422. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58423. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58424. */
  58425. useDefaultLoadingScreen: boolean;
  58426. /**
  58427. * Creates a new AssetsManager
  58428. * @param scene defines the scene to work on
  58429. */
  58430. constructor(scene: Scene);
  58431. /**
  58432. * Add a MeshAssetTask to the list of active tasks
  58433. * @param taskName defines the name of the new task
  58434. * @param meshesNames defines the name of meshes to load
  58435. * @param rootUrl defines the root url to use to locate files
  58436. * @param sceneFilename defines the filename of the scene file
  58437. * @returns a new MeshAssetTask object
  58438. */
  58439. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58440. /**
  58441. * Add a TextFileAssetTask to the list of active tasks
  58442. * @param taskName defines the name of the new task
  58443. * @param url defines the url of the file to load
  58444. * @returns a new TextFileAssetTask object
  58445. */
  58446. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58447. /**
  58448. * Add a BinaryFileAssetTask to the list of active tasks
  58449. * @param taskName defines the name of the new task
  58450. * @param url defines the url of the file to load
  58451. * @returns a new BinaryFileAssetTask object
  58452. */
  58453. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58454. /**
  58455. * Add a ImageAssetTask to the list of active tasks
  58456. * @param taskName defines the name of the new task
  58457. * @param url defines the url of the file to load
  58458. * @returns a new ImageAssetTask object
  58459. */
  58460. addImageTask(taskName: string, url: string): ImageAssetTask;
  58461. /**
  58462. * Add a TextureAssetTask to the list of active tasks
  58463. * @param taskName defines the name of the new task
  58464. * @param url defines the url of the file to load
  58465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58466. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58467. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58468. * @returns a new TextureAssetTask object
  58469. */
  58470. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58471. /**
  58472. * Add a CubeTextureAssetTask to the list of active tasks
  58473. * @param taskName defines the name of the new task
  58474. * @param url defines the url of the file to load
  58475. * @param extensions defines the extension to use to load the cube map (can be null)
  58476. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58477. * @param files defines the list of files to load (can be null)
  58478. * @returns a new CubeTextureAssetTask object
  58479. */
  58480. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58481. /**
  58482. *
  58483. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58484. * @param taskName defines the name of the new task
  58485. * @param url defines the url of the file to load
  58486. * @param size defines the size you want for the cubemap (can be null)
  58487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58488. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58489. * @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)
  58490. * @param reserved Internal use only
  58491. * @returns a new HDRCubeTextureAssetTask object
  58492. */
  58493. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58494. /**
  58495. *
  58496. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58497. * @param taskName defines the name of the new task
  58498. * @param url defines the url of the file to load
  58499. * @param size defines the size you want for the cubemap (can be null)
  58500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58501. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58502. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58503. * @returns a new EquiRectangularCubeTextureAssetTask object
  58504. */
  58505. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58506. /**
  58507. * Remove a task from the assets manager.
  58508. * @param task the task to remove
  58509. */
  58510. removeTask(task: AbstractAssetTask): void;
  58511. private _decreaseWaitingTasksCount;
  58512. private _runTask;
  58513. /**
  58514. * Reset the AssetsManager and remove all tasks
  58515. * @return the current instance of the AssetsManager
  58516. */
  58517. reset(): AssetsManager;
  58518. /**
  58519. * Start the loading process
  58520. * @return the current instance of the AssetsManager
  58521. */
  58522. load(): AssetsManager;
  58523. /**
  58524. * Start the loading process as an async operation
  58525. * @return a promise returning the list of failed tasks
  58526. */
  58527. loadAsync(): Promise<void>;
  58528. }
  58529. }
  58530. declare module "babylonjs/Misc/deferred" {
  58531. /**
  58532. * Wrapper class for promise with external resolve and reject.
  58533. */
  58534. export class Deferred<T> {
  58535. /**
  58536. * The promise associated with this deferred object.
  58537. */
  58538. readonly promise: Promise<T>;
  58539. private _resolve;
  58540. private _reject;
  58541. /**
  58542. * The resolve method of the promise associated with this deferred object.
  58543. */
  58544. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58545. /**
  58546. * The reject method of the promise associated with this deferred object.
  58547. */
  58548. readonly reject: (reason?: any) => void;
  58549. /**
  58550. * Constructor for this deferred object.
  58551. */
  58552. constructor();
  58553. }
  58554. }
  58555. declare module "babylonjs/Misc/meshExploder" {
  58556. import { Mesh } from "babylonjs/Meshes/mesh";
  58557. /**
  58558. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58559. */
  58560. export class MeshExploder {
  58561. private _centerMesh;
  58562. private _meshes;
  58563. private _meshesOrigins;
  58564. private _toCenterVectors;
  58565. private _scaledDirection;
  58566. private _newPosition;
  58567. private _centerPosition;
  58568. /**
  58569. * Explodes meshes from a center mesh.
  58570. * @param meshes The meshes to explode.
  58571. * @param centerMesh The mesh to be center of explosion.
  58572. */
  58573. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58574. private _setCenterMesh;
  58575. /**
  58576. * Get class name
  58577. * @returns "MeshExploder"
  58578. */
  58579. getClassName(): string;
  58580. /**
  58581. * "Exploded meshes"
  58582. * @returns Array of meshes with the centerMesh at index 0.
  58583. */
  58584. getMeshes(): Array<Mesh>;
  58585. /**
  58586. * Explodes meshes giving a specific direction
  58587. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58588. */
  58589. explode(direction?: number): void;
  58590. }
  58591. }
  58592. declare module "babylonjs/Misc/filesInput" {
  58593. import { Engine } from "babylonjs/Engines/engine";
  58594. import { Scene } from "babylonjs/scene";
  58595. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58596. /**
  58597. * Class used to help managing file picking and drag'n'drop
  58598. */
  58599. export class FilesInput {
  58600. /**
  58601. * List of files ready to be loaded
  58602. */
  58603. static readonly FilesToLoad: {
  58604. [key: string]: File;
  58605. };
  58606. /**
  58607. * Callback called when a file is processed
  58608. */
  58609. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58610. private _engine;
  58611. private _currentScene;
  58612. private _sceneLoadedCallback;
  58613. private _progressCallback;
  58614. private _additionalRenderLoopLogicCallback;
  58615. private _textureLoadingCallback;
  58616. private _startingProcessingFilesCallback;
  58617. private _onReloadCallback;
  58618. private _errorCallback;
  58619. private _elementToMonitor;
  58620. private _sceneFileToLoad;
  58621. private _filesToLoad;
  58622. /**
  58623. * Creates a new FilesInput
  58624. * @param engine defines the rendering engine
  58625. * @param scene defines the hosting scene
  58626. * @param sceneLoadedCallback callback called when scene is loaded
  58627. * @param progressCallback callback called to track progress
  58628. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58629. * @param textureLoadingCallback callback called when a texture is loading
  58630. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58631. * @param onReloadCallback callback called when a reload is requested
  58632. * @param errorCallback callback call if an error occurs
  58633. */
  58634. 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);
  58635. private _dragEnterHandler;
  58636. private _dragOverHandler;
  58637. private _dropHandler;
  58638. /**
  58639. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58640. * @param elementToMonitor defines the DOM element to track
  58641. */
  58642. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58643. /**
  58644. * Release all associated resources
  58645. */
  58646. dispose(): void;
  58647. private renderFunction;
  58648. private drag;
  58649. private drop;
  58650. private _traverseFolder;
  58651. private _processFiles;
  58652. /**
  58653. * Load files from a drop event
  58654. * @param event defines the drop event to use as source
  58655. */
  58656. loadFiles(event: any): void;
  58657. private _processReload;
  58658. /**
  58659. * Reload the current scene from the loaded files
  58660. */
  58661. reload(): void;
  58662. }
  58663. }
  58664. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58665. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58666. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58667. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58668. }
  58669. declare module "babylonjs/Misc/sceneOptimizer" {
  58670. import { Scene, IDisposable } from "babylonjs/scene";
  58671. import { Observable } from "babylonjs/Misc/observable";
  58672. /**
  58673. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58675. */
  58676. export class SceneOptimization {
  58677. /**
  58678. * Defines the priority of this optimization (0 by default which means first in the list)
  58679. */
  58680. priority: number;
  58681. /**
  58682. * Gets a string describing the action executed by the current optimization
  58683. * @returns description string
  58684. */
  58685. getDescription(): string;
  58686. /**
  58687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58688. * @param scene defines the current scene where to apply this optimization
  58689. * @param optimizer defines the current optimizer
  58690. * @returns true if everything that can be done was applied
  58691. */
  58692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58693. /**
  58694. * Creates the SceneOptimization object
  58695. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58696. * @param desc defines the description associated with the optimization
  58697. */
  58698. constructor(
  58699. /**
  58700. * Defines the priority of this optimization (0 by default which means first in the list)
  58701. */
  58702. priority?: number);
  58703. }
  58704. /**
  58705. * Defines an optimization used to reduce the size of render target textures
  58706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58707. */
  58708. export class TextureOptimization extends SceneOptimization {
  58709. /**
  58710. * Defines the priority of this optimization (0 by default which means first in the list)
  58711. */
  58712. priority: number;
  58713. /**
  58714. * 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
  58715. */
  58716. maximumSize: number;
  58717. /**
  58718. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58719. */
  58720. step: number;
  58721. /**
  58722. * Gets a string describing the action executed by the current optimization
  58723. * @returns description string
  58724. */
  58725. getDescription(): string;
  58726. /**
  58727. * Creates the TextureOptimization object
  58728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58729. * @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
  58730. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58731. */
  58732. constructor(
  58733. /**
  58734. * Defines the priority of this optimization (0 by default which means first in the list)
  58735. */
  58736. priority?: number,
  58737. /**
  58738. * 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
  58739. */
  58740. maximumSize?: number,
  58741. /**
  58742. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58743. */
  58744. step?: number);
  58745. /**
  58746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58747. * @param scene defines the current scene where to apply this optimization
  58748. * @param optimizer defines the current optimizer
  58749. * @returns true if everything that can be done was applied
  58750. */
  58751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58752. }
  58753. /**
  58754. * Defines an optimization used to increase or decrease the rendering resolution
  58755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58756. */
  58757. export class HardwareScalingOptimization extends SceneOptimization {
  58758. /**
  58759. * Defines the priority of this optimization (0 by default which means first in the list)
  58760. */
  58761. priority: number;
  58762. /**
  58763. * Defines the maximum scale to use (2 by default)
  58764. */
  58765. maximumScale: number;
  58766. /**
  58767. * Defines the step to use between two passes (0.5 by default)
  58768. */
  58769. step: number;
  58770. private _currentScale;
  58771. private _directionOffset;
  58772. /**
  58773. * Gets a string describing the action executed by the current optimization
  58774. * @return description string
  58775. */
  58776. getDescription(): string;
  58777. /**
  58778. * Creates the HardwareScalingOptimization object
  58779. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58780. * @param maximumScale defines the maximum scale to use (2 by default)
  58781. * @param step defines the step to use between two passes (0.5 by default)
  58782. */
  58783. constructor(
  58784. /**
  58785. * Defines the priority of this optimization (0 by default which means first in the list)
  58786. */
  58787. priority?: number,
  58788. /**
  58789. * Defines the maximum scale to use (2 by default)
  58790. */
  58791. maximumScale?: number,
  58792. /**
  58793. * Defines the step to use between two passes (0.5 by default)
  58794. */
  58795. step?: number);
  58796. /**
  58797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58798. * @param scene defines the current scene where to apply this optimization
  58799. * @param optimizer defines the current optimizer
  58800. * @returns true if everything that can be done was applied
  58801. */
  58802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58803. }
  58804. /**
  58805. * Defines an optimization used to remove shadows
  58806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58807. */
  58808. export class ShadowsOptimization extends SceneOptimization {
  58809. /**
  58810. * Gets a string describing the action executed by the current optimization
  58811. * @return 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. /**
  58823. * Defines an optimization used to turn post-processes off
  58824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58825. */
  58826. export class PostProcessesOptimization extends SceneOptimization {
  58827. /**
  58828. * Gets a string describing the action executed by the current optimization
  58829. * @return description string
  58830. */
  58831. getDescription(): string;
  58832. /**
  58833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58834. * @param scene defines the current scene where to apply this optimization
  58835. * @param optimizer defines the current optimizer
  58836. * @returns true if everything that can be done was applied
  58837. */
  58838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58839. }
  58840. /**
  58841. * Defines an optimization used to turn lens flares off
  58842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58843. */
  58844. export class LensFlaresOptimization extends SceneOptimization {
  58845. /**
  58846. * Gets a string describing the action executed by the current optimization
  58847. * @return description string
  58848. */
  58849. getDescription(): string;
  58850. /**
  58851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58852. * @param scene defines the current scene where to apply this optimization
  58853. * @param optimizer defines the current optimizer
  58854. * @returns true if everything that can be done was applied
  58855. */
  58856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58857. }
  58858. /**
  58859. * Defines an optimization based on user defined callback.
  58860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58861. */
  58862. export class CustomOptimization extends SceneOptimization {
  58863. /**
  58864. * Callback called to apply the custom optimization.
  58865. */
  58866. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58867. /**
  58868. * Callback called to get custom description
  58869. */
  58870. onGetDescription: () => string;
  58871. /**
  58872. * Gets a string describing the action executed by the current optimization
  58873. * @returns description string
  58874. */
  58875. getDescription(): string;
  58876. /**
  58877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58878. * @param scene defines the current scene where to apply this optimization
  58879. * @param optimizer defines the current optimizer
  58880. * @returns true if everything that can be done was applied
  58881. */
  58882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58883. }
  58884. /**
  58885. * Defines an optimization used to turn particles off
  58886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58887. */
  58888. export class ParticlesOptimization extends SceneOptimization {
  58889. /**
  58890. * Gets a string describing the action executed by the current optimization
  58891. * @return description string
  58892. */
  58893. getDescription(): string;
  58894. /**
  58895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58896. * @param scene defines the current scene where to apply this optimization
  58897. * @param optimizer defines the current optimizer
  58898. * @returns true if everything that can be done was applied
  58899. */
  58900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58901. }
  58902. /**
  58903. * Defines an optimization used to turn render targets off
  58904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58905. */
  58906. export class RenderTargetsOptimization extends SceneOptimization {
  58907. /**
  58908. * Gets a string describing the action executed by the current optimization
  58909. * @return description string
  58910. */
  58911. getDescription(): string;
  58912. /**
  58913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58914. * @param scene defines the current scene where to apply this optimization
  58915. * @param optimizer defines the current optimizer
  58916. * @returns true if everything that can be done was applied
  58917. */
  58918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58919. }
  58920. /**
  58921. * Defines an optimization used to merge meshes with compatible materials
  58922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58923. */
  58924. export class MergeMeshesOptimization extends SceneOptimization {
  58925. private static _UpdateSelectionTree;
  58926. /**
  58927. * Gets or sets a boolean which defines if optimization octree has to be updated
  58928. */
  58929. /**
  58930. * Gets or sets a boolean which defines if optimization octree has to be updated
  58931. */
  58932. static UpdateSelectionTree: boolean;
  58933. /**
  58934. * Gets a string describing the action executed by the current optimization
  58935. * @return description string
  58936. */
  58937. getDescription(): string;
  58938. private _canBeMerged;
  58939. /**
  58940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58941. * @param scene defines the current scene where to apply this optimization
  58942. * @param optimizer defines the current optimizer
  58943. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58944. * @returns true if everything that can be done was applied
  58945. */
  58946. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58947. }
  58948. /**
  58949. * Defines a list of options used by SceneOptimizer
  58950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58951. */
  58952. export class SceneOptimizerOptions {
  58953. /**
  58954. * Defines the target frame rate to reach (60 by default)
  58955. */
  58956. targetFrameRate: number;
  58957. /**
  58958. * Defines the interval between two checkes (2000ms by default)
  58959. */
  58960. trackerDuration: number;
  58961. /**
  58962. * Gets the list of optimizations to apply
  58963. */
  58964. optimizations: SceneOptimization[];
  58965. /**
  58966. * Creates a new list of options used by SceneOptimizer
  58967. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58968. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58969. */
  58970. constructor(
  58971. /**
  58972. * Defines the target frame rate to reach (60 by default)
  58973. */
  58974. targetFrameRate?: number,
  58975. /**
  58976. * Defines the interval between two checkes (2000ms by default)
  58977. */
  58978. trackerDuration?: number);
  58979. /**
  58980. * Add a new optimization
  58981. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58982. * @returns the current SceneOptimizerOptions
  58983. */
  58984. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58985. /**
  58986. * Add a new custom optimization
  58987. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58988. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58990. * @returns the current SceneOptimizerOptions
  58991. */
  58992. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58993. /**
  58994. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58995. * @param targetFrameRate defines the target frame rate (60 by default)
  58996. * @returns a SceneOptimizerOptions object
  58997. */
  58998. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58999. /**
  59000. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59001. * @param targetFrameRate defines the target frame rate (60 by default)
  59002. * @returns a SceneOptimizerOptions object
  59003. */
  59004. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59005. /**
  59006. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59007. * @param targetFrameRate defines the target frame rate (60 by default)
  59008. * @returns a SceneOptimizerOptions object
  59009. */
  59010. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59011. }
  59012. /**
  59013. * Class used to run optimizations in order to reach a target frame rate
  59014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59015. */
  59016. export class SceneOptimizer implements IDisposable {
  59017. private _isRunning;
  59018. private _options;
  59019. private _scene;
  59020. private _currentPriorityLevel;
  59021. private _targetFrameRate;
  59022. private _trackerDuration;
  59023. private _currentFrameRate;
  59024. private _sceneDisposeObserver;
  59025. private _improvementMode;
  59026. /**
  59027. * Defines an observable called when the optimizer reaches the target frame rate
  59028. */
  59029. onSuccessObservable: Observable<SceneOptimizer>;
  59030. /**
  59031. * Defines an observable called when the optimizer enables an optimization
  59032. */
  59033. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59034. /**
  59035. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59036. */
  59037. onFailureObservable: Observable<SceneOptimizer>;
  59038. /**
  59039. * Gets a boolean indicating if the optimizer is in improvement mode
  59040. */
  59041. readonly isInImprovementMode: boolean;
  59042. /**
  59043. * Gets the current priority level (0 at start)
  59044. */
  59045. readonly currentPriorityLevel: number;
  59046. /**
  59047. * Gets the current frame rate checked by the SceneOptimizer
  59048. */
  59049. readonly currentFrameRate: number;
  59050. /**
  59051. * Gets or sets the current target frame rate (60 by default)
  59052. */
  59053. /**
  59054. * Gets or sets the current target frame rate (60 by default)
  59055. */
  59056. targetFrameRate: number;
  59057. /**
  59058. * Gets or sets the current interval between two checks (every 2000ms by default)
  59059. */
  59060. /**
  59061. * Gets or sets the current interval between two checks (every 2000ms by default)
  59062. */
  59063. trackerDuration: number;
  59064. /**
  59065. * Gets the list of active optimizations
  59066. */
  59067. readonly optimizations: SceneOptimization[];
  59068. /**
  59069. * Creates a new SceneOptimizer
  59070. * @param scene defines the scene to work on
  59071. * @param options defines the options to use with the SceneOptimizer
  59072. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59073. * @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)
  59074. */
  59075. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59076. /**
  59077. * Stops the current optimizer
  59078. */
  59079. stop(): void;
  59080. /**
  59081. * Reset the optimizer to initial step (current priority level = 0)
  59082. */
  59083. reset(): void;
  59084. /**
  59085. * Start the optimizer. By default it will try to reach a specific framerate
  59086. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59087. */
  59088. start(): void;
  59089. private _checkCurrentState;
  59090. /**
  59091. * Release all resources
  59092. */
  59093. dispose(): void;
  59094. /**
  59095. * Helper function to create a SceneOptimizer with one single line of code
  59096. * @param scene defines the scene to work on
  59097. * @param options defines the options to use with the SceneOptimizer
  59098. * @param onSuccess defines a callback to call on success
  59099. * @param onFailure defines a callback to call on failure
  59100. * @returns the new SceneOptimizer object
  59101. */
  59102. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59103. }
  59104. }
  59105. declare module "babylonjs/Misc/sceneSerializer" {
  59106. import { Scene } from "babylonjs/scene";
  59107. /**
  59108. * Class used to serialize a scene into a string
  59109. */
  59110. export class SceneSerializer {
  59111. /**
  59112. * Clear cache used by a previous serialization
  59113. */
  59114. static ClearCache(): void;
  59115. /**
  59116. * Serialize a scene into a JSON compatible object
  59117. * @param scene defines the scene to serialize
  59118. * @returns a JSON compatible object
  59119. */
  59120. static Serialize(scene: Scene): any;
  59121. /**
  59122. * Serialize a mesh into a JSON compatible object
  59123. * @param toSerialize defines the mesh to serialize
  59124. * @param withParents defines if parents must be serialized as well
  59125. * @param withChildren defines if children must be serialized as well
  59126. * @returns a JSON compatible object
  59127. */
  59128. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59129. }
  59130. }
  59131. declare module "babylonjs/Misc/textureTools" {
  59132. import { Texture } from "babylonjs/Materials/Textures/texture";
  59133. /**
  59134. * Class used to host texture specific utilities
  59135. */
  59136. export class TextureTools {
  59137. /**
  59138. * Uses the GPU to create a copy texture rescaled at a given size
  59139. * @param texture Texture to copy from
  59140. * @param width defines the desired width
  59141. * @param height defines the desired height
  59142. * @param useBilinearMode defines if bilinear mode has to be used
  59143. * @return the generated texture
  59144. */
  59145. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59146. }
  59147. }
  59148. declare module "babylonjs/Misc/videoRecorder" {
  59149. import { Nullable } from "babylonjs/types";
  59150. import { Engine } from "babylonjs/Engines/engine";
  59151. /**
  59152. * This represents the different options avilable for the video capture.
  59153. */
  59154. export interface VideoRecorderOptions {
  59155. /** Defines the mime type of the video */
  59156. mimeType: string;
  59157. /** Defines the video the video should be recorded at */
  59158. fps: number;
  59159. /** Defines the chunk size for the recording data */
  59160. recordChunckSize: number;
  59161. /** The audio tracks to attach to the record */
  59162. audioTracks?: MediaStreamTrack[];
  59163. }
  59164. /**
  59165. * This can helps recording videos from BabylonJS.
  59166. * This is based on the available WebRTC functionalities of the browser.
  59167. *
  59168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59169. */
  59170. export class VideoRecorder {
  59171. private static readonly _defaultOptions;
  59172. /**
  59173. * Returns wehther or not the VideoRecorder is available in your browser.
  59174. * @param engine Defines the Babylon Engine to check the support for
  59175. * @returns true if supported otherwise false
  59176. */
  59177. static IsSupported(engine: Engine): boolean;
  59178. private readonly _options;
  59179. private _canvas;
  59180. private _mediaRecorder;
  59181. private _recordedChunks;
  59182. private _fileName;
  59183. private _resolve;
  59184. private _reject;
  59185. /**
  59186. * True wether a recording is already in progress.
  59187. */
  59188. readonly isRecording: boolean;
  59189. /**
  59190. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59191. * a video file.
  59192. * @param engine Defines the BabylonJS Engine you wish to record
  59193. * @param options Defines options that can be used to customized the capture
  59194. */
  59195. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59196. /**
  59197. * Stops the current recording before the default capture timeout passed in the startRecording
  59198. * functions.
  59199. */
  59200. stopRecording(): void;
  59201. /**
  59202. * Starts recording the canvas for a max duration specified in parameters.
  59203. * @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.
  59204. * @param maxDuration Defines the maximum recording time in seconds.
  59205. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59206. * @return a promise callback at the end of the recording with the video data in Blob.
  59207. */
  59208. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59209. /**
  59210. * Releases internal resources used during the recording.
  59211. */
  59212. dispose(): void;
  59213. private _handleDataAvailable;
  59214. private _handleError;
  59215. private _handleStop;
  59216. }
  59217. }
  59218. declare module "babylonjs/Misc/screenshotTools" {
  59219. import { Camera } from "babylonjs/Cameras/camera";
  59220. import { Engine } from "babylonjs/Engines/engine";
  59221. /**
  59222. * Class containing a set of static utilities functions for screenshots
  59223. */
  59224. export class ScreenshotTools {
  59225. /**
  59226. * Captures a screenshot of the current rendering
  59227. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59228. * @param engine defines the rendering engine
  59229. * @param camera defines the source camera
  59230. * @param size This parameter can be set to a single number or to an object with the
  59231. * following (optional) properties: precision, width, height. If a single number is passed,
  59232. * it will be used for both width and height. If an object is passed, the screenshot size
  59233. * will be derived from the parameters. The precision property is a multiplier allowing
  59234. * rendering at a higher or lower resolution
  59235. * @param successCallback defines the callback receives a single parameter which contains the
  59236. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59237. * src parameter of an <img> to display it
  59238. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59239. * Check your browser for supported MIME types
  59240. */
  59241. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59242. /**
  59243. * Generates an image screenshot from the specified camera.
  59244. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59245. * @param engine The engine to use for rendering
  59246. * @param camera The camera to use for rendering
  59247. * @param size This parameter can be set to a single number or to an object with the
  59248. * following (optional) properties: precision, width, height. If a single number is passed,
  59249. * it will be used for both width and height. If an object is passed, the screenshot size
  59250. * will be derived from the parameters. The precision property is a multiplier allowing
  59251. * rendering at a higher or lower resolution
  59252. * @param successCallback The callback receives a single parameter which contains the
  59253. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59254. * src parameter of an <img> to display it
  59255. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59256. * Check your browser for supported MIME types
  59257. * @param samples Texture samples (default: 1)
  59258. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59259. * @param fileName A name for for the downloaded file.
  59260. */
  59261. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59262. }
  59263. }
  59264. declare module "babylonjs/Misc/index" {
  59265. export * from "babylonjs/Misc/andOrNotEvaluator";
  59266. export * from "babylonjs/Misc/assetsManager";
  59267. export * from "babylonjs/Misc/dds";
  59268. export * from "babylonjs/Misc/decorators";
  59269. export * from "babylonjs/Misc/deferred";
  59270. export * from "babylonjs/Misc/environmentTextureTools";
  59271. export * from "babylonjs/Misc/meshExploder";
  59272. export * from "babylonjs/Misc/filesInput";
  59273. export * from "babylonjs/Misc/HighDynamicRange/index";
  59274. export * from "babylonjs/Misc/khronosTextureContainer";
  59275. export * from "babylonjs/Misc/observable";
  59276. export * from "babylonjs/Misc/performanceMonitor";
  59277. export * from "babylonjs/Misc/promise";
  59278. export * from "babylonjs/Misc/sceneOptimizer";
  59279. export * from "babylonjs/Misc/sceneSerializer";
  59280. export * from "babylonjs/Misc/smartArray";
  59281. export * from "babylonjs/Misc/stringDictionary";
  59282. export * from "babylonjs/Misc/tags";
  59283. export * from "babylonjs/Misc/textureTools";
  59284. export * from "babylonjs/Misc/tga";
  59285. export * from "babylonjs/Misc/tools";
  59286. export * from "babylonjs/Misc/videoRecorder";
  59287. export * from "babylonjs/Misc/virtualJoystick";
  59288. export * from "babylonjs/Misc/workerPool";
  59289. export * from "babylonjs/Misc/logger";
  59290. export * from "babylonjs/Misc/typeStore";
  59291. export * from "babylonjs/Misc/filesInputStore";
  59292. export * from "babylonjs/Misc/deepCopier";
  59293. export * from "babylonjs/Misc/pivotTools";
  59294. export * from "babylonjs/Misc/precisionDate";
  59295. export * from "babylonjs/Misc/screenshotTools";
  59296. export * from "babylonjs/Misc/typeStore";
  59297. export * from "babylonjs/Misc/webRequest";
  59298. export * from "babylonjs/Misc/iInspectable";
  59299. }
  59300. declare module "babylonjs/index" {
  59301. export * from "babylonjs/abstractScene";
  59302. export * from "babylonjs/Actions/index";
  59303. export * from "babylonjs/Animations/index";
  59304. export * from "babylonjs/assetContainer";
  59305. export * from "babylonjs/Audio/index";
  59306. export * from "babylonjs/Behaviors/index";
  59307. export * from "babylonjs/Bones/index";
  59308. export * from "babylonjs/Cameras/index";
  59309. export * from "babylonjs/Collisions/index";
  59310. export * from "babylonjs/Culling/index";
  59311. export * from "babylonjs/Debug/index";
  59312. export * from "babylonjs/Engines/index";
  59313. export * from "babylonjs/Events/index";
  59314. export * from "babylonjs/Gamepads/index";
  59315. export * from "babylonjs/Gizmos/index";
  59316. export * from "babylonjs/Helpers/index";
  59317. export * from "babylonjs/Instrumentation/index";
  59318. export * from "babylonjs/Layers/index";
  59319. export * from "babylonjs/LensFlares/index";
  59320. export * from "babylonjs/Lights/index";
  59321. export * from "babylonjs/Loading/index";
  59322. export * from "babylonjs/Materials/index";
  59323. export * from "babylonjs/Maths/index";
  59324. export * from "babylonjs/Meshes/index";
  59325. export * from "babylonjs/Morph/index";
  59326. export * from "babylonjs/node";
  59327. export * from "babylonjs/Offline/index";
  59328. export * from "babylonjs/Particles/index";
  59329. export * from "babylonjs/Physics/index";
  59330. export * from "babylonjs/PostProcesses/index";
  59331. export * from "babylonjs/Probes/index";
  59332. export * from "babylonjs/Rendering/index";
  59333. export * from "babylonjs/scene";
  59334. export * from "babylonjs/sceneComponent";
  59335. export * from "babylonjs/Sprites/index";
  59336. export * from "babylonjs/States/index";
  59337. export * from "babylonjs/Misc/index";
  59338. export * from "babylonjs/types";
  59339. }
  59340. declare module "babylonjs/Animations/pathCursor" {
  59341. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59342. /**
  59343. * A cursor which tracks a point on a path
  59344. */
  59345. export class PathCursor {
  59346. private path;
  59347. /**
  59348. * Stores path cursor callbacks for when an onchange event is triggered
  59349. */
  59350. private _onchange;
  59351. /**
  59352. * The value of the path cursor
  59353. */
  59354. value: number;
  59355. /**
  59356. * The animation array of the path cursor
  59357. */
  59358. animations: Animation[];
  59359. /**
  59360. * Initializes the path cursor
  59361. * @param path The path to track
  59362. */
  59363. constructor(path: Path2);
  59364. /**
  59365. * Gets the cursor point on the path
  59366. * @returns A point on the path cursor at the cursor location
  59367. */
  59368. getPoint(): Vector3;
  59369. /**
  59370. * Moves the cursor ahead by the step amount
  59371. * @param step The amount to move the cursor forward
  59372. * @returns This path cursor
  59373. */
  59374. moveAhead(step?: number): PathCursor;
  59375. /**
  59376. * Moves the cursor behind by the step amount
  59377. * @param step The amount to move the cursor back
  59378. * @returns This path cursor
  59379. */
  59380. moveBack(step?: number): PathCursor;
  59381. /**
  59382. * Moves the cursor by the step amount
  59383. * If the step amount is greater than one, an exception is thrown
  59384. * @param step The amount to move the cursor
  59385. * @returns This path cursor
  59386. */
  59387. move(step: number): PathCursor;
  59388. /**
  59389. * Ensures that the value is limited between zero and one
  59390. * @returns This path cursor
  59391. */
  59392. private ensureLimits;
  59393. /**
  59394. * Runs onchange callbacks on change (used by the animation engine)
  59395. * @returns This path cursor
  59396. */
  59397. private raiseOnChange;
  59398. /**
  59399. * Executes a function on change
  59400. * @param f A path cursor onchange callback
  59401. * @returns This path cursor
  59402. */
  59403. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59404. }
  59405. }
  59406. declare module "babylonjs/Legacy/legacy" {
  59407. import * as Babylon from "babylonjs/index";
  59408. export * from "babylonjs/index";
  59409. }
  59410. declare module "babylonjs/Shaders/blur.fragment" {
  59411. /** @hidden */
  59412. export var blurPixelShader: {
  59413. name: string;
  59414. shader: string;
  59415. };
  59416. }
  59417. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59418. /** @hidden */
  59419. export var bones300Declaration: {
  59420. name: string;
  59421. shader: string;
  59422. };
  59423. }
  59424. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59425. /** @hidden */
  59426. export var instances300Declaration: {
  59427. name: string;
  59428. shader: string;
  59429. };
  59430. }
  59431. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59432. /** @hidden */
  59433. export var pointCloudVertexDeclaration: {
  59434. name: string;
  59435. shader: string;
  59436. };
  59437. }
  59438. // Mixins
  59439. interface Window {
  59440. mozIndexedDB: IDBFactory;
  59441. webkitIndexedDB: IDBFactory;
  59442. msIndexedDB: IDBFactory;
  59443. webkitURL: typeof URL;
  59444. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59445. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59446. WebGLRenderingContext: WebGLRenderingContext;
  59447. MSGesture: MSGesture;
  59448. CANNON: any;
  59449. AudioContext: AudioContext;
  59450. webkitAudioContext: AudioContext;
  59451. PointerEvent: any;
  59452. Math: Math;
  59453. Uint8Array: Uint8ArrayConstructor;
  59454. Float32Array: Float32ArrayConstructor;
  59455. mozURL: typeof URL;
  59456. msURL: typeof URL;
  59457. VRFrameData: any; // WebVR, from specs 1.1
  59458. DracoDecoderModule: any;
  59459. setImmediate(handler: (...args: any[]) => void): number;
  59460. }
  59461. interface HTMLCanvasElement {
  59462. requestPointerLock(): void;
  59463. msRequestPointerLock?(): void;
  59464. mozRequestPointerLock?(): void;
  59465. webkitRequestPointerLock?(): void;
  59466. /** Track wether a record is in progress */
  59467. isRecording: boolean;
  59468. /** Capture Stream method defined by some browsers */
  59469. captureStream(fps?: number): MediaStream;
  59470. }
  59471. interface CanvasRenderingContext2D {
  59472. msImageSmoothingEnabled: boolean;
  59473. }
  59474. interface MouseEvent {
  59475. mozMovementX: number;
  59476. mozMovementY: number;
  59477. webkitMovementX: number;
  59478. webkitMovementY: number;
  59479. msMovementX: number;
  59480. msMovementY: number;
  59481. }
  59482. interface Navigator {
  59483. mozGetVRDevices: (any: any) => any;
  59484. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59485. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59486. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59487. webkitGetGamepads(): Gamepad[];
  59488. msGetGamepads(): Gamepad[];
  59489. webkitGamepads(): Gamepad[];
  59490. }
  59491. interface HTMLVideoElement {
  59492. mozSrcObject: any;
  59493. }
  59494. interface Math {
  59495. fround(x: number): number;
  59496. imul(a: number, b: number): number;
  59497. }
  59498. interface WebGLRenderingContext {
  59499. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59500. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59501. vertexAttribDivisor(index: number, divisor: number): void;
  59502. createVertexArray(): any;
  59503. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59504. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59505. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59506. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59507. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59508. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59509. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59510. // Queries
  59511. createQuery(): WebGLQuery;
  59512. deleteQuery(query: WebGLQuery): void;
  59513. beginQuery(target: number, query: WebGLQuery): void;
  59514. endQuery(target: number): void;
  59515. getQueryParameter(query: WebGLQuery, pname: number): any;
  59516. getQuery(target: number, pname: number): any;
  59517. MAX_SAMPLES: number;
  59518. RGBA8: number;
  59519. READ_FRAMEBUFFER: number;
  59520. DRAW_FRAMEBUFFER: number;
  59521. UNIFORM_BUFFER: number;
  59522. HALF_FLOAT_OES: number;
  59523. RGBA16F: number;
  59524. RGBA32F: number;
  59525. R32F: number;
  59526. RG32F: number;
  59527. RGB32F: number;
  59528. R16F: number;
  59529. RG16F: number;
  59530. RGB16F: number;
  59531. RED: number;
  59532. RG: number;
  59533. R8: number;
  59534. RG8: number;
  59535. UNSIGNED_INT_24_8: number;
  59536. DEPTH24_STENCIL8: number;
  59537. /* Multiple Render Targets */
  59538. drawBuffers(buffers: number[]): void;
  59539. readBuffer(src: number): void;
  59540. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59541. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59542. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59543. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59544. // Occlusion Query
  59545. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59546. ANY_SAMPLES_PASSED: number;
  59547. QUERY_RESULT_AVAILABLE: number;
  59548. QUERY_RESULT: number;
  59549. }
  59550. interface WebGLProgram {
  59551. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59552. }
  59553. interface EXT_disjoint_timer_query {
  59554. QUERY_COUNTER_BITS_EXT: number;
  59555. TIME_ELAPSED_EXT: number;
  59556. TIMESTAMP_EXT: number;
  59557. GPU_DISJOINT_EXT: number;
  59558. QUERY_RESULT_EXT: number;
  59559. QUERY_RESULT_AVAILABLE_EXT: number;
  59560. queryCounterEXT(query: WebGLQuery, target: number): void;
  59561. createQueryEXT(): WebGLQuery;
  59562. beginQueryEXT(target: number, query: WebGLQuery): void;
  59563. endQueryEXT(target: number): void;
  59564. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59565. deleteQueryEXT(query: WebGLQuery): void;
  59566. }
  59567. interface WebGLUniformLocation {
  59568. _currentState: any;
  59569. }
  59570. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59571. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59572. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59573. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59574. interface WebGLRenderingContext {
  59575. readonly RASTERIZER_DISCARD: number;
  59576. readonly DEPTH_COMPONENT24: number;
  59577. readonly TEXTURE_3D: number;
  59578. readonly TEXTURE_2D_ARRAY: number;
  59579. readonly TEXTURE_COMPARE_FUNC: number;
  59580. readonly TEXTURE_COMPARE_MODE: number;
  59581. readonly COMPARE_REF_TO_TEXTURE: number;
  59582. readonly TEXTURE_WRAP_R: number;
  59583. readonly HALF_FLOAT: number;
  59584. readonly RGB8: number;
  59585. readonly RED_INTEGER: number;
  59586. readonly RG_INTEGER: number;
  59587. readonly RGB_INTEGER: number;
  59588. readonly RGBA_INTEGER: number;
  59589. readonly R8_SNORM: number;
  59590. readonly RG8_SNORM: number;
  59591. readonly RGB8_SNORM: number;
  59592. readonly RGBA8_SNORM: number;
  59593. readonly R8I: number;
  59594. readonly RG8I: number;
  59595. readonly RGB8I: number;
  59596. readonly RGBA8I: number;
  59597. readonly R8UI: number;
  59598. readonly RG8UI: number;
  59599. readonly RGB8UI: number;
  59600. readonly RGBA8UI: number;
  59601. readonly R16I: number;
  59602. readonly RG16I: number;
  59603. readonly RGB16I: number;
  59604. readonly RGBA16I: number;
  59605. readonly R16UI: number;
  59606. readonly RG16UI: number;
  59607. readonly RGB16UI: number;
  59608. readonly RGBA16UI: number;
  59609. readonly R32I: number;
  59610. readonly RG32I: number;
  59611. readonly RGB32I: number;
  59612. readonly RGBA32I: number;
  59613. readonly R32UI: number;
  59614. readonly RG32UI: number;
  59615. readonly RGB32UI: number;
  59616. readonly RGBA32UI: number;
  59617. readonly RGB10_A2UI: number;
  59618. readonly R11F_G11F_B10F: number;
  59619. readonly RGB9_E5: number;
  59620. readonly RGB10_A2: number;
  59621. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59622. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59623. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59624. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59625. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59626. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59627. 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;
  59628. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59629. readonly TRANSFORM_FEEDBACK: number;
  59630. readonly INTERLEAVED_ATTRIBS: number;
  59631. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59632. createTransformFeedback(): WebGLTransformFeedback;
  59633. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59634. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59635. beginTransformFeedback(primitiveMode: number): void;
  59636. endTransformFeedback(): void;
  59637. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59638. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59639. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59640. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59641. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59642. }
  59643. interface ImageBitmap {
  59644. readonly width: number;
  59645. readonly height: number;
  59646. close(): void;
  59647. }
  59648. interface WebGLQuery extends WebGLObject {
  59649. }
  59650. declare var WebGLQuery: {
  59651. prototype: WebGLQuery;
  59652. new(): WebGLQuery;
  59653. };
  59654. interface WebGLSampler extends WebGLObject {
  59655. }
  59656. declare var WebGLSampler: {
  59657. prototype: WebGLSampler;
  59658. new(): WebGLSampler;
  59659. };
  59660. interface WebGLSync extends WebGLObject {
  59661. }
  59662. declare var WebGLSync: {
  59663. prototype: WebGLSync;
  59664. new(): WebGLSync;
  59665. };
  59666. interface WebGLTransformFeedback extends WebGLObject {
  59667. }
  59668. declare var WebGLTransformFeedback: {
  59669. prototype: WebGLTransformFeedback;
  59670. new(): WebGLTransformFeedback;
  59671. };
  59672. interface WebGLVertexArrayObject extends WebGLObject {
  59673. }
  59674. declare var WebGLVertexArrayObject: {
  59675. prototype: WebGLVertexArrayObject;
  59676. new(): WebGLVertexArrayObject;
  59677. };
  59678. // Type definitions for WebVR API
  59679. // Project: https://w3c.github.io/webvr/
  59680. // Definitions by: six a <https://github.com/lostfictions>
  59681. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59682. interface VRDisplay extends EventTarget {
  59683. /**
  59684. * Dictionary of capabilities describing the VRDisplay.
  59685. */
  59686. readonly capabilities: VRDisplayCapabilities;
  59687. /**
  59688. * z-depth defining the far plane of the eye view frustum
  59689. * enables mapping of values in the render target depth
  59690. * attachment to scene coordinates. Initially set to 10000.0.
  59691. */
  59692. depthFar: number;
  59693. /**
  59694. * z-depth defining the near plane of the eye view frustum
  59695. * enables mapping of values in the render target depth
  59696. * attachment to scene coordinates. Initially set to 0.01.
  59697. */
  59698. depthNear: number;
  59699. /**
  59700. * An identifier for this distinct VRDisplay. Used as an
  59701. * association point in the Gamepad API.
  59702. */
  59703. readonly displayId: number;
  59704. /**
  59705. * A display name, a user-readable name identifying it.
  59706. */
  59707. readonly displayName: string;
  59708. readonly isConnected: boolean;
  59709. readonly isPresenting: boolean;
  59710. /**
  59711. * If this VRDisplay supports room-scale experiences, the optional
  59712. * stage attribute contains details on the room-scale parameters.
  59713. */
  59714. readonly stageParameters: VRStageParameters | null;
  59715. /**
  59716. * Passing the value returned by `requestAnimationFrame` to
  59717. * `cancelAnimationFrame` will unregister the callback.
  59718. * @param handle Define the hanle of the request to cancel
  59719. */
  59720. cancelAnimationFrame(handle: number): void;
  59721. /**
  59722. * Stops presenting to the VRDisplay.
  59723. * @returns a promise to know when it stopped
  59724. */
  59725. exitPresent(): Promise<void>;
  59726. /**
  59727. * Return the current VREyeParameters for the given eye.
  59728. * @param whichEye Define the eye we want the parameter for
  59729. * @returns the eye parameters
  59730. */
  59731. getEyeParameters(whichEye: string): VREyeParameters;
  59732. /**
  59733. * Populates the passed VRFrameData with the information required to render
  59734. * the current frame.
  59735. * @param frameData Define the data structure to populate
  59736. * @returns true if ok otherwise false
  59737. */
  59738. getFrameData(frameData: VRFrameData): boolean;
  59739. /**
  59740. * Get the layers currently being presented.
  59741. * @returns the list of VR layers
  59742. */
  59743. getLayers(): VRLayer[];
  59744. /**
  59745. * Return a VRPose containing the future predicted pose of the VRDisplay
  59746. * when the current frame will be presented. The value returned will not
  59747. * change until JavaScript has returned control to the browser.
  59748. *
  59749. * The VRPose will contain the position, orientation, velocity,
  59750. * and acceleration of each of these properties.
  59751. * @returns the pose object
  59752. */
  59753. getPose(): VRPose;
  59754. /**
  59755. * Return the current instantaneous pose of the VRDisplay, with no
  59756. * prediction applied.
  59757. * @returns the current instantaneous pose
  59758. */
  59759. getImmediatePose(): VRPose;
  59760. /**
  59761. * The callback passed to `requestAnimationFrame` will be called
  59762. * any time a new frame should be rendered. When the VRDisplay is
  59763. * presenting the callback will be called at the native refresh
  59764. * rate of the HMD. When not presenting this function acts
  59765. * identically to how window.requestAnimationFrame acts. Content should
  59766. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59767. * asynchronously from other displays and at differing refresh rates.
  59768. * @param callback Define the eaction to run next frame
  59769. * @returns the request handle it
  59770. */
  59771. requestAnimationFrame(callback: FrameRequestCallback): number;
  59772. /**
  59773. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59774. * Repeat calls while already presenting will update the VRLayers being displayed.
  59775. * @param layers Define the list of layer to present
  59776. * @returns a promise to know when the request has been fulfilled
  59777. */
  59778. requestPresent(layers: VRLayer[]): Promise<void>;
  59779. /**
  59780. * Reset the pose for this display, treating its current position and
  59781. * orientation as the "origin/zero" values. VRPose.position,
  59782. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59783. * updated when calling resetPose(). This should be called in only
  59784. * sitting-space experiences.
  59785. */
  59786. resetPose(): void;
  59787. /**
  59788. * The VRLayer provided to the VRDisplay will be captured and presented
  59789. * in the HMD. Calling this function has the same effect on the source
  59790. * canvas as any other operation that uses its source image, and canvases
  59791. * created without preserveDrawingBuffer set to true will be cleared.
  59792. * @param pose Define the pose to submit
  59793. */
  59794. submitFrame(pose?: VRPose): void;
  59795. }
  59796. declare var VRDisplay: {
  59797. prototype: VRDisplay;
  59798. new(): VRDisplay;
  59799. };
  59800. interface VRLayer {
  59801. leftBounds?: number[] | Float32Array | null;
  59802. rightBounds?: number[] | Float32Array | null;
  59803. source?: HTMLCanvasElement | null;
  59804. }
  59805. interface VRDisplayCapabilities {
  59806. readonly canPresent: boolean;
  59807. readonly hasExternalDisplay: boolean;
  59808. readonly hasOrientation: boolean;
  59809. readonly hasPosition: boolean;
  59810. readonly maxLayers: number;
  59811. }
  59812. interface VREyeParameters {
  59813. /** @deprecated */
  59814. readonly fieldOfView: VRFieldOfView;
  59815. readonly offset: Float32Array;
  59816. readonly renderHeight: number;
  59817. readonly renderWidth: number;
  59818. }
  59819. interface VRFieldOfView {
  59820. readonly downDegrees: number;
  59821. readonly leftDegrees: number;
  59822. readonly rightDegrees: number;
  59823. readonly upDegrees: number;
  59824. }
  59825. interface VRFrameData {
  59826. readonly leftProjectionMatrix: Float32Array;
  59827. readonly leftViewMatrix: Float32Array;
  59828. readonly pose: VRPose;
  59829. readonly rightProjectionMatrix: Float32Array;
  59830. readonly rightViewMatrix: Float32Array;
  59831. readonly timestamp: number;
  59832. }
  59833. interface VRPose {
  59834. readonly angularAcceleration: Float32Array | null;
  59835. readonly angularVelocity: Float32Array | null;
  59836. readonly linearAcceleration: Float32Array | null;
  59837. readonly linearVelocity: Float32Array | null;
  59838. readonly orientation: Float32Array | null;
  59839. readonly position: Float32Array | null;
  59840. readonly timestamp: number;
  59841. }
  59842. interface VRStageParameters {
  59843. sittingToStandingTransform?: Float32Array;
  59844. sizeX?: number;
  59845. sizeY?: number;
  59846. }
  59847. interface Navigator {
  59848. getVRDisplays(): Promise<VRDisplay[]>;
  59849. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59850. }
  59851. interface Window {
  59852. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59853. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59854. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59855. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59856. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59857. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59858. }
  59859. interface Gamepad {
  59860. readonly displayId: number;
  59861. }
  59862. interface XRDevice {
  59863. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59864. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59865. }
  59866. interface XRSession {
  59867. getInputSources(): Array<any>;
  59868. baseLayer: XRWebGLLayer;
  59869. requestFrameOfReference(type: string): Promise<void>;
  59870. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59871. end(): Promise<void>;
  59872. requestAnimationFrame: Function;
  59873. addEventListener: Function;
  59874. }
  59875. interface XRSessionCreationOptions {
  59876. outputContext?: WebGLRenderingContext | null;
  59877. immersive?: boolean;
  59878. environmentIntegration?: boolean;
  59879. }
  59880. interface XRLayer {
  59881. getViewport: Function;
  59882. framebufferWidth: number;
  59883. framebufferHeight: number;
  59884. }
  59885. interface XRView {
  59886. projectionMatrix: Float32Array;
  59887. }
  59888. interface XRFrame {
  59889. getDevicePose: Function;
  59890. getInputPose: Function;
  59891. views: Array<XRView>;
  59892. baseLayer: XRLayer;
  59893. }
  59894. interface XRFrameOfReference {
  59895. }
  59896. interface XRWebGLLayer extends XRLayer {
  59897. framebuffer: WebGLFramebuffer;
  59898. }
  59899. declare var XRWebGLLayer: {
  59900. prototype: XRWebGLLayer;
  59901. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59902. };
  59903. declare module "babylonjs" {
  59904. export * from "babylonjs/Legacy/legacy";
  59905. }
  59906. declare module BABYLON {
  59907. /** Alias type for value that can be null */
  59908. export type Nullable<T> = T | null;
  59909. /**
  59910. * Alias type for number that are floats
  59911. * @ignorenaming
  59912. */
  59913. export type float = number;
  59914. /**
  59915. * Alias type for number that are doubles.
  59916. * @ignorenaming
  59917. */
  59918. export type double = number;
  59919. /**
  59920. * Alias type for number that are integer
  59921. * @ignorenaming
  59922. */
  59923. export type int = number;
  59924. /** Alias type for number array or Float32Array */
  59925. export type FloatArray = number[] | Float32Array;
  59926. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59927. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59928. /**
  59929. * Alias for types that can be used by a Buffer or VertexBuffer.
  59930. */
  59931. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59932. /**
  59933. * Alias type for primitive types
  59934. * @ignorenaming
  59935. */
  59936. type Primitive = undefined | null | boolean | string | number | Function;
  59937. /**
  59938. * Type modifier to make all the properties of an object Readonly
  59939. */
  59940. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59941. /**
  59942. * Type modifier to make all the properties of an object Readonly recursively
  59943. */
  59944. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59945. /** @hidden */
  59946. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59947. }
  59948. /** @hidden */
  59949. /** @hidden */
  59950. type DeepImmutableObject<T> = {
  59951. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59952. };
  59953. }
  59954. declare module BABYLON {
  59955. /**
  59956. * Class containing a set of static utilities functions for arrays.
  59957. */
  59958. export class ArrayTools {
  59959. /**
  59960. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59961. * @param size the number of element to construct and put in the array
  59962. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59963. * @returns a new array filled with new objects
  59964. */
  59965. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59966. }
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * Scalar computation library
  59971. */
  59972. export class Scalar {
  59973. /**
  59974. * Two pi constants convenient for computation.
  59975. */
  59976. static TwoPi: number;
  59977. /**
  59978. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59979. * @param a number
  59980. * @param b number
  59981. * @param epsilon (default = 1.401298E-45)
  59982. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59983. */
  59984. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59985. /**
  59986. * Returns a string : the upper case translation of the number i to hexadecimal.
  59987. * @param i number
  59988. * @returns the upper case translation of the number i to hexadecimal.
  59989. */
  59990. static ToHex(i: number): string;
  59991. /**
  59992. * Returns -1 if value is negative and +1 is value is positive.
  59993. * @param value the value
  59994. * @returns the value itself if it's equal to zero.
  59995. */
  59996. static Sign(value: number): number;
  59997. /**
  59998. * Returns the value itself if it's between min and max.
  59999. * Returns min if the value is lower than min.
  60000. * Returns max if the value is greater than max.
  60001. * @param value the value to clmap
  60002. * @param min the min value to clamp to (default: 0)
  60003. * @param max the max value to clamp to (default: 1)
  60004. * @returns the clamped value
  60005. */
  60006. static Clamp(value: number, min?: number, max?: number): number;
  60007. /**
  60008. * the log2 of value.
  60009. * @param value the value to compute log2 of
  60010. * @returns the log2 of value.
  60011. */
  60012. static Log2(value: number): number;
  60013. /**
  60014. * Loops the value, so that it is never larger than length and never smaller than 0.
  60015. *
  60016. * This is similar to the modulo operator but it works with floating point numbers.
  60017. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60018. * With t = 5 and length = 2.5, the result would be 0.0.
  60019. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60020. * @param value the value
  60021. * @param length the length
  60022. * @returns the looped value
  60023. */
  60024. static Repeat(value: number, length: number): number;
  60025. /**
  60026. * Normalize the value between 0.0 and 1.0 using min and max values
  60027. * @param value value to normalize
  60028. * @param min max to normalize between
  60029. * @param max min to normalize between
  60030. * @returns the normalized value
  60031. */
  60032. static Normalize(value: number, min: number, max: number): number;
  60033. /**
  60034. * Denormalize the value from 0.0 and 1.0 using min and max values
  60035. * @param normalized value to denormalize
  60036. * @param min max to denormalize between
  60037. * @param max min to denormalize between
  60038. * @returns the denormalized value
  60039. */
  60040. static Denormalize(normalized: number, min: number, max: number): number;
  60041. /**
  60042. * Calculates the shortest difference between two given angles given in degrees.
  60043. * @param current current angle in degrees
  60044. * @param target target angle in degrees
  60045. * @returns the delta
  60046. */
  60047. static DeltaAngle(current: number, target: number): number;
  60048. /**
  60049. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60050. * @param tx value
  60051. * @param length length
  60052. * @returns The returned value will move back and forth between 0 and length
  60053. */
  60054. static PingPong(tx: number, length: number): number;
  60055. /**
  60056. * Interpolates between min and max with smoothing at the limits.
  60057. *
  60058. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60059. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60060. * @param from from
  60061. * @param to to
  60062. * @param tx value
  60063. * @returns the smooth stepped value
  60064. */
  60065. static SmoothStep(from: number, to: number, tx: number): number;
  60066. /**
  60067. * Moves a value current towards target.
  60068. *
  60069. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60070. * Negative values of maxDelta pushes the value away from target.
  60071. * @param current current value
  60072. * @param target target value
  60073. * @param maxDelta max distance to move
  60074. * @returns resulting value
  60075. */
  60076. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60077. /**
  60078. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60079. *
  60080. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60081. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60082. * @param current current value
  60083. * @param target target value
  60084. * @param maxDelta max distance to move
  60085. * @returns resulting angle
  60086. */
  60087. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60088. /**
  60089. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60090. * @param start start value
  60091. * @param end target value
  60092. * @param amount amount to lerp between
  60093. * @returns the lerped value
  60094. */
  60095. static Lerp(start: number, end: number, amount: number): number;
  60096. /**
  60097. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60098. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60099. * @param start start value
  60100. * @param end target value
  60101. * @param amount amount to lerp between
  60102. * @returns the lerped value
  60103. */
  60104. static LerpAngle(start: number, end: number, amount: number): number;
  60105. /**
  60106. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60107. * @param a start value
  60108. * @param b target value
  60109. * @param value value between a and b
  60110. * @returns the inverseLerp value
  60111. */
  60112. static InverseLerp(a: number, b: number, value: number): number;
  60113. /**
  60114. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60115. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60116. * @param value1 spline value
  60117. * @param tangent1 spline value
  60118. * @param value2 spline value
  60119. * @param tangent2 spline value
  60120. * @param amount input value
  60121. * @returns hermite result
  60122. */
  60123. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60124. /**
  60125. * Returns a random float number between and min and max values
  60126. * @param min min value of random
  60127. * @param max max value of random
  60128. * @returns random value
  60129. */
  60130. static RandomRange(min: number, max: number): number;
  60131. /**
  60132. * This function returns percentage of a number in a given range.
  60133. *
  60134. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60135. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60136. * @param number to convert to percentage
  60137. * @param min min range
  60138. * @param max max range
  60139. * @returns the percentage
  60140. */
  60141. static RangeToPercent(number: number, min: number, max: number): number;
  60142. /**
  60143. * This function returns number that corresponds to the percentage in a given range.
  60144. *
  60145. * PercentToRange(0.34,0,100) will return 34.
  60146. * @param percent to convert to number
  60147. * @param min min range
  60148. * @param max max range
  60149. * @returns the number
  60150. */
  60151. static PercentToRange(percent: number, min: number, max: number): number;
  60152. /**
  60153. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60154. * @param angle The angle to normalize in radian.
  60155. * @return The converted angle.
  60156. */
  60157. static NormalizeRadians(angle: number): number;
  60158. }
  60159. }
  60160. declare module BABYLON {
  60161. /**
  60162. * Constant used to convert a value to gamma space
  60163. * @ignorenaming
  60164. */
  60165. export const ToGammaSpace: number;
  60166. /**
  60167. * Constant used to convert a value to linear space
  60168. * @ignorenaming
  60169. */
  60170. export const ToLinearSpace = 2.2;
  60171. /**
  60172. * Constant used to define the minimal number value in Babylon.js
  60173. * @ignorenaming
  60174. */
  60175. let Epsilon: number;
  60176. /**
  60177. * Class used to hold a RBG color
  60178. */
  60179. export class Color3 {
  60180. /**
  60181. * Defines the red component (between 0 and 1, default is 0)
  60182. */
  60183. r: number;
  60184. /**
  60185. * Defines the green component (between 0 and 1, default is 0)
  60186. */
  60187. g: number;
  60188. /**
  60189. * Defines the blue component (between 0 and 1, default is 0)
  60190. */
  60191. b: number;
  60192. /**
  60193. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60194. * @param r defines the red component (between 0 and 1, default is 0)
  60195. * @param g defines the green component (between 0 and 1, default is 0)
  60196. * @param b defines the blue component (between 0 and 1, default is 0)
  60197. */
  60198. constructor(
  60199. /**
  60200. * Defines the red component (between 0 and 1, default is 0)
  60201. */
  60202. r?: number,
  60203. /**
  60204. * Defines the green component (between 0 and 1, default is 0)
  60205. */
  60206. g?: number,
  60207. /**
  60208. * Defines the blue component (between 0 and 1, default is 0)
  60209. */
  60210. b?: number);
  60211. /**
  60212. * Creates a string with the Color3 current values
  60213. * @returns the string representation of the Color3 object
  60214. */
  60215. toString(): string;
  60216. /**
  60217. * Returns the string "Color3"
  60218. * @returns "Color3"
  60219. */
  60220. getClassName(): string;
  60221. /**
  60222. * Compute the Color3 hash code
  60223. * @returns an unique number that can be used to hash Color3 objects
  60224. */
  60225. getHashCode(): number;
  60226. /**
  60227. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60228. * @param array defines the array where to store the r,g,b components
  60229. * @param index defines an optional index in the target array to define where to start storing values
  60230. * @returns the current Color3 object
  60231. */
  60232. toArray(array: FloatArray, index?: number): Color3;
  60233. /**
  60234. * Returns a new Color4 object from the current Color3 and the given alpha
  60235. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60236. * @returns a new Color4 object
  60237. */
  60238. toColor4(alpha?: number): Color4;
  60239. /**
  60240. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60241. * @returns the new array
  60242. */
  60243. asArray(): number[];
  60244. /**
  60245. * Returns the luminance value
  60246. * @returns a float value
  60247. */
  60248. toLuminance(): number;
  60249. /**
  60250. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60251. * @param otherColor defines the second operand
  60252. * @returns the new Color3 object
  60253. */
  60254. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60255. /**
  60256. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60257. * @param otherColor defines the second operand
  60258. * @param result defines the Color3 object where to store the result
  60259. * @returns the current Color3
  60260. */
  60261. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60262. /**
  60263. * Determines equality between Color3 objects
  60264. * @param otherColor defines the second operand
  60265. * @returns true if the rgb values are equal to the given ones
  60266. */
  60267. equals(otherColor: DeepImmutable<Color3>): boolean;
  60268. /**
  60269. * Determines equality between the current Color3 object and a set of r,b,g values
  60270. * @param r defines the red component to check
  60271. * @param g defines the green component to check
  60272. * @param b defines the blue component to check
  60273. * @returns true if the rgb values are equal to the given ones
  60274. */
  60275. equalsFloats(r: number, g: number, b: number): boolean;
  60276. /**
  60277. * Multiplies in place each rgb value by scale
  60278. * @param scale defines the scaling factor
  60279. * @returns the updated Color3
  60280. */
  60281. scale(scale: number): Color3;
  60282. /**
  60283. * Multiplies the rgb values by scale and stores the result into "result"
  60284. * @param scale defines the scaling factor
  60285. * @param result defines the Color3 object where to store the result
  60286. * @returns the unmodified current Color3
  60287. */
  60288. scaleToRef(scale: number, result: Color3): Color3;
  60289. /**
  60290. * Scale the current Color3 values by a factor and add the result to a given Color3
  60291. * @param scale defines the scale factor
  60292. * @param result defines color to store the result into
  60293. * @returns the unmodified current Color3
  60294. */
  60295. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60296. /**
  60297. * Clamps the rgb values by the min and max values and stores the result into "result"
  60298. * @param min defines minimum clamping value (default is 0)
  60299. * @param max defines maximum clamping value (default is 1)
  60300. * @param result defines color to store the result into
  60301. * @returns the original Color3
  60302. */
  60303. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60304. /**
  60305. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60306. * @param otherColor defines the second operand
  60307. * @returns the new Color3
  60308. */
  60309. add(otherColor: DeepImmutable<Color3>): Color3;
  60310. /**
  60311. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60312. * @param otherColor defines the second operand
  60313. * @param result defines Color3 object to store the result into
  60314. * @returns the unmodified current Color3
  60315. */
  60316. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60317. /**
  60318. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60319. * @param otherColor defines the second operand
  60320. * @returns the new Color3
  60321. */
  60322. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60323. /**
  60324. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60325. * @param otherColor defines the second operand
  60326. * @param result defines Color3 object to store the result into
  60327. * @returns the unmodified current Color3
  60328. */
  60329. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60330. /**
  60331. * Copy the current object
  60332. * @returns a new Color3 copied the current one
  60333. */
  60334. clone(): Color3;
  60335. /**
  60336. * Copies the rgb values from the source in the current Color3
  60337. * @param source defines the source Color3 object
  60338. * @returns the updated Color3 object
  60339. */
  60340. copyFrom(source: DeepImmutable<Color3>): Color3;
  60341. /**
  60342. * Updates the Color3 rgb values from the given floats
  60343. * @param r defines the red component to read from
  60344. * @param g defines the green component to read from
  60345. * @param b defines the blue component to read from
  60346. * @returns the current Color3 object
  60347. */
  60348. copyFromFloats(r: number, g: number, b: number): Color3;
  60349. /**
  60350. * Updates the Color3 rgb values from the given floats
  60351. * @param r defines the red component to read from
  60352. * @param g defines the green component to read from
  60353. * @param b defines the blue component to read from
  60354. * @returns the current Color3 object
  60355. */
  60356. set(r: number, g: number, b: number): Color3;
  60357. /**
  60358. * Compute the Color3 hexadecimal code as a string
  60359. * @returns a string containing the hexadecimal representation of the Color3 object
  60360. */
  60361. toHexString(): string;
  60362. /**
  60363. * Computes a new Color3 converted from the current one to linear space
  60364. * @returns a new Color3 object
  60365. */
  60366. toLinearSpace(): Color3;
  60367. /**
  60368. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60369. * @param convertedColor defines the Color3 object where to store the linear space version
  60370. * @returns the unmodified Color3
  60371. */
  60372. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60373. /**
  60374. * Computes a new Color3 converted from the current one to gamma space
  60375. * @returns a new Color3 object
  60376. */
  60377. toGammaSpace(): Color3;
  60378. /**
  60379. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60380. * @param convertedColor defines the Color3 object where to store the gamma space version
  60381. * @returns the unmodified Color3
  60382. */
  60383. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60384. private static _BlackReadOnly;
  60385. /**
  60386. * Creates a new Color3 from the string containing valid hexadecimal values
  60387. * @param hex defines a string containing valid hexadecimal values
  60388. * @returns a new Color3 object
  60389. */
  60390. static FromHexString(hex: string): Color3;
  60391. /**
  60392. * Creates a new Color3 from the starting index of the given array
  60393. * @param array defines the source array
  60394. * @param offset defines an offset in the source array
  60395. * @returns a new Color3 object
  60396. */
  60397. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60398. /**
  60399. * Creates a new Color3 from integer values (< 256)
  60400. * @param r defines the red component to read from (value between 0 and 255)
  60401. * @param g defines the green component to read from (value between 0 and 255)
  60402. * @param b defines the blue component to read from (value between 0 and 255)
  60403. * @returns a new Color3 object
  60404. */
  60405. static FromInts(r: number, g: number, b: number): Color3;
  60406. /**
  60407. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60408. * @param start defines the start Color3 value
  60409. * @param end defines the end Color3 value
  60410. * @param amount defines the gradient value between start and end
  60411. * @returns a new Color3 object
  60412. */
  60413. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60414. /**
  60415. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60416. * @param left defines the start value
  60417. * @param right defines the end value
  60418. * @param amount defines the gradient factor
  60419. * @param result defines the Color3 object where to store the result
  60420. */
  60421. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60422. /**
  60423. * Returns a Color3 value containing a red color
  60424. * @returns a new Color3 object
  60425. */
  60426. static Red(): Color3;
  60427. /**
  60428. * Returns a Color3 value containing a green color
  60429. * @returns a new Color3 object
  60430. */
  60431. static Green(): Color3;
  60432. /**
  60433. * Returns a Color3 value containing a blue color
  60434. * @returns a new Color3 object
  60435. */
  60436. static Blue(): Color3;
  60437. /**
  60438. * Returns a Color3 value containing a black color
  60439. * @returns a new Color3 object
  60440. */
  60441. static Black(): Color3;
  60442. /**
  60443. * Gets a Color3 value containing a black color that must not be updated
  60444. */
  60445. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60446. /**
  60447. * Returns a Color3 value containing a white color
  60448. * @returns a new Color3 object
  60449. */
  60450. static White(): Color3;
  60451. /**
  60452. * Returns a Color3 value containing a purple color
  60453. * @returns a new Color3 object
  60454. */
  60455. static Purple(): Color3;
  60456. /**
  60457. * Returns a Color3 value containing a magenta color
  60458. * @returns a new Color3 object
  60459. */
  60460. static Magenta(): Color3;
  60461. /**
  60462. * Returns a Color3 value containing a yellow color
  60463. * @returns a new Color3 object
  60464. */
  60465. static Yellow(): Color3;
  60466. /**
  60467. * Returns a Color3 value containing a gray color
  60468. * @returns a new Color3 object
  60469. */
  60470. static Gray(): Color3;
  60471. /**
  60472. * Returns a Color3 value containing a teal color
  60473. * @returns a new Color3 object
  60474. */
  60475. static Teal(): Color3;
  60476. /**
  60477. * Returns a Color3 value containing a random color
  60478. * @returns a new Color3 object
  60479. */
  60480. static Random(): Color3;
  60481. }
  60482. /**
  60483. * Class used to hold a RBGA color
  60484. */
  60485. export class Color4 {
  60486. /**
  60487. * Defines the red component (between 0 and 1, default is 0)
  60488. */
  60489. r: number;
  60490. /**
  60491. * Defines the green component (between 0 and 1, default is 0)
  60492. */
  60493. g: number;
  60494. /**
  60495. * Defines the blue component (between 0 and 1, default is 0)
  60496. */
  60497. b: number;
  60498. /**
  60499. * Defines the alpha component (between 0 and 1, default is 1)
  60500. */
  60501. a: number;
  60502. /**
  60503. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60504. * @param r defines the red component (between 0 and 1, default is 0)
  60505. * @param g defines the green component (between 0 and 1, default is 0)
  60506. * @param b defines the blue component (between 0 and 1, default is 0)
  60507. * @param a defines the alpha component (between 0 and 1, default is 1)
  60508. */
  60509. constructor(
  60510. /**
  60511. * Defines the red component (between 0 and 1, default is 0)
  60512. */
  60513. r?: number,
  60514. /**
  60515. * Defines the green component (between 0 and 1, default is 0)
  60516. */
  60517. g?: number,
  60518. /**
  60519. * Defines the blue component (between 0 and 1, default is 0)
  60520. */
  60521. b?: number,
  60522. /**
  60523. * Defines the alpha component (between 0 and 1, default is 1)
  60524. */
  60525. a?: number);
  60526. /**
  60527. * Adds in place the given Color4 values to the current Color4 object
  60528. * @param right defines the second operand
  60529. * @returns the current updated Color4 object
  60530. */
  60531. addInPlace(right: DeepImmutable<Color4>): Color4;
  60532. /**
  60533. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60534. * @returns the new array
  60535. */
  60536. asArray(): number[];
  60537. /**
  60538. * Stores from the starting index in the given array the Color4 successive values
  60539. * @param array defines the array where to store the r,g,b components
  60540. * @param index defines an optional index in the target array to define where to start storing values
  60541. * @returns the current Color4 object
  60542. */
  60543. toArray(array: number[], index?: number): Color4;
  60544. /**
  60545. * Determines equality between Color4 objects
  60546. * @param otherColor defines the second operand
  60547. * @returns true if the rgba values are equal to the given ones
  60548. */
  60549. equals(otherColor: DeepImmutable<Color4>): boolean;
  60550. /**
  60551. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60552. * @param right defines the second operand
  60553. * @returns a new Color4 object
  60554. */
  60555. add(right: DeepImmutable<Color4>): Color4;
  60556. /**
  60557. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60558. * @param right defines the second operand
  60559. * @returns a new Color4 object
  60560. */
  60561. subtract(right: DeepImmutable<Color4>): Color4;
  60562. /**
  60563. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60564. * @param right defines the second operand
  60565. * @param result defines the Color4 object where to store the result
  60566. * @returns the current Color4 object
  60567. */
  60568. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60569. /**
  60570. * Creates a new Color4 with the current Color4 values multiplied by scale
  60571. * @param scale defines the scaling factor to apply
  60572. * @returns a new Color4 object
  60573. */
  60574. scale(scale: number): Color4;
  60575. /**
  60576. * Multiplies the current Color4 values by scale and stores the result in "result"
  60577. * @param scale defines the scaling factor to apply
  60578. * @param result defines the Color4 object where to store the result
  60579. * @returns the current unmodified Color4
  60580. */
  60581. scaleToRef(scale: number, result: Color4): Color4;
  60582. /**
  60583. * Scale the current Color4 values by a factor and add the result to a given Color4
  60584. * @param scale defines the scale factor
  60585. * @param result defines the Color4 object where to store the result
  60586. * @returns the unmodified current Color4
  60587. */
  60588. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60589. /**
  60590. * Clamps the rgb values by the min and max values and stores the result into "result"
  60591. * @param min defines minimum clamping value (default is 0)
  60592. * @param max defines maximum clamping value (default is 1)
  60593. * @param result defines color to store the result into.
  60594. * @returns the cuurent Color4
  60595. */
  60596. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60597. /**
  60598. * Multipy an Color4 value by another and return a new Color4 object
  60599. * @param color defines the Color4 value to multiply by
  60600. * @returns a new Color4 object
  60601. */
  60602. multiply(color: Color4): Color4;
  60603. /**
  60604. * Multipy a Color4 value by another and push the result in a reference value
  60605. * @param color defines the Color4 value to multiply by
  60606. * @param result defines the Color4 to fill the result in
  60607. * @returns the result Color4
  60608. */
  60609. multiplyToRef(color: Color4, result: Color4): Color4;
  60610. /**
  60611. * Creates a string with the Color4 current values
  60612. * @returns the string representation of the Color4 object
  60613. */
  60614. toString(): string;
  60615. /**
  60616. * Returns the string "Color4"
  60617. * @returns "Color4"
  60618. */
  60619. getClassName(): string;
  60620. /**
  60621. * Compute the Color4 hash code
  60622. * @returns an unique number that can be used to hash Color4 objects
  60623. */
  60624. getHashCode(): number;
  60625. /**
  60626. * Creates a new Color4 copied from the current one
  60627. * @returns a new Color4 object
  60628. */
  60629. clone(): Color4;
  60630. /**
  60631. * Copies the given Color4 values into the current one
  60632. * @param source defines the source Color4 object
  60633. * @returns the current updated Color4 object
  60634. */
  60635. copyFrom(source: Color4): Color4;
  60636. /**
  60637. * Copies the given float values into the current one
  60638. * @param r defines the red component to read from
  60639. * @param g defines the green component to read from
  60640. * @param b defines the blue component to read from
  60641. * @param a defines the alpha component to read from
  60642. * @returns the current updated Color4 object
  60643. */
  60644. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60645. /**
  60646. * Copies the given float values into the current one
  60647. * @param r defines the red component to read from
  60648. * @param g defines the green component to read from
  60649. * @param b defines the blue component to read from
  60650. * @param a defines the alpha component to read from
  60651. * @returns the current updated Color4 object
  60652. */
  60653. set(r: number, g: number, b: number, a: number): Color4;
  60654. /**
  60655. * Compute the Color4 hexadecimal code as a string
  60656. * @returns a string containing the hexadecimal representation of the Color4 object
  60657. */
  60658. toHexString(): string;
  60659. /**
  60660. * Computes a new Color4 converted from the current one to linear space
  60661. * @returns a new Color4 object
  60662. */
  60663. toLinearSpace(): Color4;
  60664. /**
  60665. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60666. * @param convertedColor defines the Color4 object where to store the linear space version
  60667. * @returns the unmodified Color4
  60668. */
  60669. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60670. /**
  60671. * Computes a new Color4 converted from the current one to gamma space
  60672. * @returns a new Color4 object
  60673. */
  60674. toGammaSpace(): Color4;
  60675. /**
  60676. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60677. * @param convertedColor defines the Color4 object where to store the gamma space version
  60678. * @returns the unmodified Color4
  60679. */
  60680. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60681. /**
  60682. * Creates a new Color4 from the string containing valid hexadecimal values
  60683. * @param hex defines a string containing valid hexadecimal values
  60684. * @returns a new Color4 object
  60685. */
  60686. static FromHexString(hex: string): Color4;
  60687. /**
  60688. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60689. * @param left defines the start value
  60690. * @param right defines the end value
  60691. * @param amount defines the gradient factor
  60692. * @returns a new Color4 object
  60693. */
  60694. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60695. /**
  60696. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60697. * @param left defines the start value
  60698. * @param right defines the end value
  60699. * @param amount defines the gradient factor
  60700. * @param result defines the Color4 object where to store data
  60701. */
  60702. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60703. /**
  60704. * Creates a new Color4 from a Color3 and an alpha value
  60705. * @param color3 defines the source Color3 to read from
  60706. * @param alpha defines the alpha component (1.0 by default)
  60707. * @returns a new Color4 object
  60708. */
  60709. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60710. /**
  60711. * Creates a new Color4 from the starting index element of the given array
  60712. * @param array defines the source array to read from
  60713. * @param offset defines the offset in the source array
  60714. * @returns a new Color4 object
  60715. */
  60716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60717. /**
  60718. * Creates a new Color3 from integer values (< 256)
  60719. * @param r defines the red component to read from (value between 0 and 255)
  60720. * @param g defines the green component to read from (value between 0 and 255)
  60721. * @param b defines the blue component to read from (value between 0 and 255)
  60722. * @param a defines the alpha component to read from (value between 0 and 255)
  60723. * @returns a new Color3 object
  60724. */
  60725. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60726. /**
  60727. * Check the content of a given array and convert it to an array containing RGBA data
  60728. * If the original array was already containing count * 4 values then it is returned directly
  60729. * @param colors defines the array to check
  60730. * @param count defines the number of RGBA data to expect
  60731. * @returns an array containing count * 4 values (RGBA)
  60732. */
  60733. static CheckColors4(colors: number[], count: number): number[];
  60734. }
  60735. /**
  60736. * Class representing a vector containing 2 coordinates
  60737. */
  60738. export class Vector2 {
  60739. /** defines the first coordinate */
  60740. x: number;
  60741. /** defines the second coordinate */
  60742. y: number;
  60743. /**
  60744. * Creates a new Vector2 from the given x and y coordinates
  60745. * @param x defines the first coordinate
  60746. * @param y defines the second coordinate
  60747. */
  60748. constructor(
  60749. /** defines the first coordinate */
  60750. x?: number,
  60751. /** defines the second coordinate */
  60752. y?: number);
  60753. /**
  60754. * Gets a string with the Vector2 coordinates
  60755. * @returns a string with the Vector2 coordinates
  60756. */
  60757. toString(): string;
  60758. /**
  60759. * Gets class name
  60760. * @returns the string "Vector2"
  60761. */
  60762. getClassName(): string;
  60763. /**
  60764. * Gets current vector hash code
  60765. * @returns the Vector2 hash code as a number
  60766. */
  60767. getHashCode(): number;
  60768. /**
  60769. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60770. * @param array defines the source array
  60771. * @param index defines the offset in source array
  60772. * @returns the current Vector2
  60773. */
  60774. toArray(array: FloatArray, index?: number): Vector2;
  60775. /**
  60776. * Copy the current vector to an array
  60777. * @returns a new array with 2 elements: the Vector2 coordinates.
  60778. */
  60779. asArray(): number[];
  60780. /**
  60781. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60782. * @param source defines the source Vector2
  60783. * @returns the current updated Vector2
  60784. */
  60785. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60786. /**
  60787. * Sets the Vector2 coordinates with the given floats
  60788. * @param x defines the first coordinate
  60789. * @param y defines the second coordinate
  60790. * @returns the current updated Vector2
  60791. */
  60792. copyFromFloats(x: number, y: number): Vector2;
  60793. /**
  60794. * Sets the Vector2 coordinates with the given floats
  60795. * @param x defines the first coordinate
  60796. * @param y defines the second coordinate
  60797. * @returns the current updated Vector2
  60798. */
  60799. set(x: number, y: number): Vector2;
  60800. /**
  60801. * Add another vector with the current one
  60802. * @param otherVector defines the other vector
  60803. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60804. */
  60805. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60806. /**
  60807. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60808. * @param otherVector defines the other vector
  60809. * @param result defines the target vector
  60810. * @returns the unmodified current Vector2
  60811. */
  60812. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60813. /**
  60814. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60815. * @param otherVector defines the other vector
  60816. * @returns the current updated Vector2
  60817. */
  60818. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60819. /**
  60820. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60821. * @param otherVector defines the other vector
  60822. * @returns a new Vector2
  60823. */
  60824. addVector3(otherVector: Vector3): Vector2;
  60825. /**
  60826. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60827. * @param otherVector defines the other vector
  60828. * @returns a new Vector2
  60829. */
  60830. subtract(otherVector: Vector2): Vector2;
  60831. /**
  60832. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60833. * @param otherVector defines the other vector
  60834. * @param result defines the target vector
  60835. * @returns the unmodified current Vector2
  60836. */
  60837. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60838. /**
  60839. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60840. * @param otherVector defines the other vector
  60841. * @returns the current updated Vector2
  60842. */
  60843. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60844. /**
  60845. * Multiplies in place the current Vector2 coordinates by the given ones
  60846. * @param otherVector defines the other vector
  60847. * @returns the current updated Vector2
  60848. */
  60849. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60850. /**
  60851. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60852. * @param otherVector defines the other vector
  60853. * @returns a new Vector2
  60854. */
  60855. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60856. /**
  60857. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60858. * @param otherVector defines the other vector
  60859. * @param result defines the target vector
  60860. * @returns the unmodified current Vector2
  60861. */
  60862. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60863. /**
  60864. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60865. * @param x defines the first coordinate
  60866. * @param y defines the second coordinate
  60867. * @returns a new Vector2
  60868. */
  60869. multiplyByFloats(x: number, y: number): Vector2;
  60870. /**
  60871. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60872. * @param otherVector defines the other vector
  60873. * @returns a new Vector2
  60874. */
  60875. divide(otherVector: Vector2): Vector2;
  60876. /**
  60877. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60878. * @param otherVector defines the other vector
  60879. * @param result defines the target vector
  60880. * @returns the unmodified current Vector2
  60881. */
  60882. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60883. /**
  60884. * Divides the current Vector2 coordinates by the given ones
  60885. * @param otherVector defines the other vector
  60886. * @returns the current updated Vector2
  60887. */
  60888. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60889. /**
  60890. * Gets a new Vector2 with current Vector2 negated coordinates
  60891. * @returns a new Vector2
  60892. */
  60893. negate(): Vector2;
  60894. /**
  60895. * Multiply the Vector2 coordinates by scale
  60896. * @param scale defines the scaling factor
  60897. * @returns the current updated Vector2
  60898. */
  60899. scaleInPlace(scale: number): Vector2;
  60900. /**
  60901. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60902. * @param scale defines the scaling factor
  60903. * @returns a new Vector2
  60904. */
  60905. scale(scale: number): Vector2;
  60906. /**
  60907. * Scale the current Vector2 values by a factor to a given Vector2
  60908. * @param scale defines the scale factor
  60909. * @param result defines the Vector2 object where to store the result
  60910. * @returns the unmodified current Vector2
  60911. */
  60912. scaleToRef(scale: number, result: Vector2): Vector2;
  60913. /**
  60914. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60915. * @param scale defines the scale factor
  60916. * @param result defines the Vector2 object where to store the result
  60917. * @returns the unmodified current Vector2
  60918. */
  60919. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60920. /**
  60921. * Gets a boolean if two vectors are equals
  60922. * @param otherVector defines the other vector
  60923. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60924. */
  60925. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60926. /**
  60927. * Gets a boolean if two vectors are equals (using an epsilon value)
  60928. * @param otherVector defines the other vector
  60929. * @param epsilon defines the minimal distance to consider equality
  60930. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60931. */
  60932. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60933. /**
  60934. * Gets a new Vector2 from current Vector2 floored values
  60935. * @returns a new Vector2
  60936. */
  60937. floor(): Vector2;
  60938. /**
  60939. * Gets a new Vector2 from current Vector2 floored values
  60940. * @returns a new Vector2
  60941. */
  60942. fract(): Vector2;
  60943. /**
  60944. * Gets the length of the vector
  60945. * @returns the vector length (float)
  60946. */
  60947. length(): number;
  60948. /**
  60949. * Gets the vector squared length
  60950. * @returns the vector squared length (float)
  60951. */
  60952. lengthSquared(): number;
  60953. /**
  60954. * Normalize the vector
  60955. * @returns the current updated Vector2
  60956. */
  60957. normalize(): Vector2;
  60958. /**
  60959. * Gets a new Vector2 copied from the Vector2
  60960. * @returns a new Vector2
  60961. */
  60962. clone(): Vector2;
  60963. /**
  60964. * Gets a new Vector2(0, 0)
  60965. * @returns a new Vector2
  60966. */
  60967. static Zero(): Vector2;
  60968. /**
  60969. * Gets a new Vector2(1, 1)
  60970. * @returns a new Vector2
  60971. */
  60972. static One(): Vector2;
  60973. /**
  60974. * Gets a new Vector2 set from the given index element of the given array
  60975. * @param array defines the data source
  60976. * @param offset defines the offset in the data source
  60977. * @returns a new Vector2
  60978. */
  60979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60980. /**
  60981. * Sets "result" from the given index element of the given array
  60982. * @param array defines the data source
  60983. * @param offset defines the offset in the data source
  60984. * @param result defines the target vector
  60985. */
  60986. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60987. /**
  60988. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60989. * @param value1 defines 1st point of control
  60990. * @param value2 defines 2nd point of control
  60991. * @param value3 defines 3rd point of control
  60992. * @param value4 defines 4th point of control
  60993. * @param amount defines the interpolation factor
  60994. * @returns a new Vector2
  60995. */
  60996. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60997. /**
  60998. * 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".
  60999. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61000. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61001. * @param value defines the value to clamp
  61002. * @param min defines the lower limit
  61003. * @param max defines the upper limit
  61004. * @returns a new Vector2
  61005. */
  61006. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61007. /**
  61008. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61009. * @param value1 defines the 1st control point
  61010. * @param tangent1 defines the outgoing tangent
  61011. * @param value2 defines the 2nd control point
  61012. * @param tangent2 defines the incoming tangent
  61013. * @param amount defines the interpolation factor
  61014. * @returns a new Vector2
  61015. */
  61016. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61017. /**
  61018. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61019. * @param start defines the start vector
  61020. * @param end defines the end vector
  61021. * @param amount defines the interpolation factor
  61022. * @returns a new Vector2
  61023. */
  61024. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61025. /**
  61026. * Gets the dot product of the vector "left" and the vector "right"
  61027. * @param left defines first vector
  61028. * @param right defines second vector
  61029. * @returns the dot product (float)
  61030. */
  61031. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61032. /**
  61033. * Returns a new Vector2 equal to the normalized given vector
  61034. * @param vector defines the vector to normalize
  61035. * @returns a new Vector2
  61036. */
  61037. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61038. /**
  61039. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61040. * @param left defines 1st vector
  61041. * @param right defines 2nd vector
  61042. * @returns a new Vector2
  61043. */
  61044. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61045. /**
  61046. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61047. * @param left defines 1st vector
  61048. * @param right defines 2nd vector
  61049. * @returns a new Vector2
  61050. */
  61051. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61052. /**
  61053. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61054. * @param vector defines the vector to transform
  61055. * @param transformation defines the matrix to apply
  61056. * @returns a new Vector2
  61057. */
  61058. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61059. /**
  61060. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61061. * @param vector defines the vector to transform
  61062. * @param transformation defines the matrix to apply
  61063. * @param result defines the target vector
  61064. */
  61065. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61066. /**
  61067. * Determines if a given vector is included in a triangle
  61068. * @param p defines the vector to test
  61069. * @param p0 defines 1st triangle point
  61070. * @param p1 defines 2nd triangle point
  61071. * @param p2 defines 3rd triangle point
  61072. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61073. */
  61074. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61075. /**
  61076. * Gets the distance between the vectors "value1" and "value2"
  61077. * @param value1 defines first vector
  61078. * @param value2 defines second vector
  61079. * @returns the distance between vectors
  61080. */
  61081. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61082. /**
  61083. * Returns the squared distance between the vectors "value1" and "value2"
  61084. * @param value1 defines first vector
  61085. * @param value2 defines second vector
  61086. * @returns the squared distance between vectors
  61087. */
  61088. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61089. /**
  61090. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61091. * @param value1 defines first vector
  61092. * @param value2 defines second vector
  61093. * @returns a new Vector2
  61094. */
  61095. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61096. /**
  61097. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61098. * @param p defines the middle point
  61099. * @param segA defines one point of the segment
  61100. * @param segB defines the other point of the segment
  61101. * @returns the shortest distance
  61102. */
  61103. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61104. }
  61105. /**
  61106. * Classed used to store (x,y,z) vector representation
  61107. * A Vector3 is the main object used in 3D geometry
  61108. * It can represent etiher the coordinates of a point the space, either a direction
  61109. * Reminder: js uses a left handed forward facing system
  61110. */
  61111. export class Vector3 {
  61112. /**
  61113. * Defines the first coordinates (on X axis)
  61114. */
  61115. x: number;
  61116. /**
  61117. * Defines the second coordinates (on Y axis)
  61118. */
  61119. y: number;
  61120. /**
  61121. * Defines the third coordinates (on Z axis)
  61122. */
  61123. z: number;
  61124. private static _UpReadOnly;
  61125. /**
  61126. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61127. * @param x defines the first coordinates (on X axis)
  61128. * @param y defines the second coordinates (on Y axis)
  61129. * @param z defines the third coordinates (on Z axis)
  61130. */
  61131. constructor(
  61132. /**
  61133. * Defines the first coordinates (on X axis)
  61134. */
  61135. x?: number,
  61136. /**
  61137. * Defines the second coordinates (on Y axis)
  61138. */
  61139. y?: number,
  61140. /**
  61141. * Defines the third coordinates (on Z axis)
  61142. */
  61143. z?: number);
  61144. /**
  61145. * Creates a string representation of the Vector3
  61146. * @returns a string with the Vector3 coordinates.
  61147. */
  61148. toString(): string;
  61149. /**
  61150. * Gets the class name
  61151. * @returns the string "Vector3"
  61152. */
  61153. getClassName(): string;
  61154. /**
  61155. * Creates the Vector3 hash code
  61156. * @returns a number which tends to be unique between Vector3 instances
  61157. */
  61158. getHashCode(): number;
  61159. /**
  61160. * Creates an array containing three elements : the coordinates of the Vector3
  61161. * @returns a new array of numbers
  61162. */
  61163. asArray(): number[];
  61164. /**
  61165. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61166. * @param array defines the destination array
  61167. * @param index defines the offset in the destination array
  61168. * @returns the current Vector3
  61169. */
  61170. toArray(array: FloatArray, index?: number): Vector3;
  61171. /**
  61172. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61173. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61174. */
  61175. toQuaternion(): Quaternion;
  61176. /**
  61177. * Adds the given vector to the current Vector3
  61178. * @param otherVector defines the second operand
  61179. * @returns the current updated Vector3
  61180. */
  61181. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61182. /**
  61183. * Adds the given coordinates to the current Vector3
  61184. * @param x defines the x coordinate of the operand
  61185. * @param y defines the y coordinate of the operand
  61186. * @param z defines the z coordinate of the operand
  61187. * @returns the current updated Vector3
  61188. */
  61189. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61190. /**
  61191. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61192. * @param otherVector defines the second operand
  61193. * @returns the resulting Vector3
  61194. */
  61195. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61196. /**
  61197. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61198. * @param otherVector defines the second operand
  61199. * @param result defines the Vector3 object where to store the result
  61200. * @returns the current Vector3
  61201. */
  61202. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61203. /**
  61204. * Subtract the given vector from the current Vector3
  61205. * @param otherVector defines the second operand
  61206. * @returns the current updated Vector3
  61207. */
  61208. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61209. /**
  61210. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61211. * @param otherVector defines the second operand
  61212. * @returns the resulting Vector3
  61213. */
  61214. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61215. /**
  61216. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61217. * @param otherVector defines the second operand
  61218. * @param result defines the Vector3 object where to store the result
  61219. * @returns the current Vector3
  61220. */
  61221. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61222. /**
  61223. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61224. * @param x defines the x coordinate of the operand
  61225. * @param y defines the y coordinate of the operand
  61226. * @param z defines the z coordinate of the operand
  61227. * @returns the resulting Vector3
  61228. */
  61229. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61230. /**
  61231. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61232. * @param x defines the x coordinate of the operand
  61233. * @param y defines the y coordinate of the operand
  61234. * @param z defines the z coordinate of the operand
  61235. * @param result defines the Vector3 object where to store the result
  61236. * @returns the current Vector3
  61237. */
  61238. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61239. /**
  61240. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61241. * @returns a new Vector3
  61242. */
  61243. negate(): Vector3;
  61244. /**
  61245. * Multiplies the Vector3 coordinates by the float "scale"
  61246. * @param scale defines the multiplier factor
  61247. * @returns the current updated Vector3
  61248. */
  61249. scaleInPlace(scale: number): Vector3;
  61250. /**
  61251. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61252. * @param scale defines the multiplier factor
  61253. * @returns a new Vector3
  61254. */
  61255. scale(scale: number): Vector3;
  61256. /**
  61257. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61258. * @param scale defines the multiplier factor
  61259. * @param result defines the Vector3 object where to store the result
  61260. * @returns the current Vector3
  61261. */
  61262. scaleToRef(scale: number, result: Vector3): Vector3;
  61263. /**
  61264. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61265. * @param scale defines the scale factor
  61266. * @param result defines the Vector3 object where to store the result
  61267. * @returns the unmodified current Vector3
  61268. */
  61269. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61270. /**
  61271. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61272. * @param otherVector defines the second operand
  61273. * @returns true if both vectors are equals
  61274. */
  61275. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61276. /**
  61277. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61278. * @param otherVector defines the second operand
  61279. * @param epsilon defines the minimal distance to define values as equals
  61280. * @returns true if both vectors are distant less than epsilon
  61281. */
  61282. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61283. /**
  61284. * Returns true if the current Vector3 coordinates equals the given floats
  61285. * @param x defines the x coordinate of the operand
  61286. * @param y defines the y coordinate of the operand
  61287. * @param z defines the z coordinate of the operand
  61288. * @returns true if both vectors are equals
  61289. */
  61290. equalsToFloats(x: number, y: number, z: number): boolean;
  61291. /**
  61292. * Multiplies the current Vector3 coordinates by the given ones
  61293. * @param otherVector defines the second operand
  61294. * @returns the current updated Vector3
  61295. */
  61296. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61297. /**
  61298. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61299. * @param otherVector defines the second operand
  61300. * @returns the new Vector3
  61301. */
  61302. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61303. /**
  61304. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61305. * @param otherVector defines the second operand
  61306. * @param result defines the Vector3 object where to store the result
  61307. * @returns the current Vector3
  61308. */
  61309. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61310. /**
  61311. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  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 new Vector3
  61316. */
  61317. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61318. /**
  61319. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61320. * @param otherVector defines the second operand
  61321. * @returns the new Vector3
  61322. */
  61323. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61324. /**
  61325. * Divides the current Vector3 coordinates by the given ones and stores the result in the given 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. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61331. /**
  61332. * Divides the current Vector3 coordinates by the given ones.
  61333. * @param otherVector defines the second operand
  61334. * @returns the current updated Vector3
  61335. */
  61336. divideInPlace(otherVector: Vector3): Vector3;
  61337. /**
  61338. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61339. * @param other defines the second operand
  61340. * @returns the current updated Vector3
  61341. */
  61342. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61343. /**
  61344. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61345. * @param other defines the second operand
  61346. * @returns the current updated Vector3
  61347. */
  61348. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61349. /**
  61350. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61351. * @param x defines the x coordinate of the operand
  61352. * @param y defines the y coordinate of the operand
  61353. * @param z defines the z coordinate of the operand
  61354. * @returns the current updated Vector3
  61355. */
  61356. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61357. /**
  61358. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61359. * @param x defines the x coordinate of the operand
  61360. * @param y defines the y coordinate of the operand
  61361. * @param z defines the z coordinate of the operand
  61362. * @returns the current updated Vector3
  61363. */
  61364. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61365. /**
  61366. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61367. * Check if is non uniform within a certain amount of decimal places to account for this
  61368. * @param epsilon the amount the values can differ
  61369. * @returns if the the vector is non uniform to a certain number of decimal places
  61370. */
  61371. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61372. /**
  61373. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61374. */
  61375. readonly isNonUniform: boolean;
  61376. /**
  61377. * Gets a new Vector3 from current Vector3 floored values
  61378. * @returns a new Vector3
  61379. */
  61380. floor(): Vector3;
  61381. /**
  61382. * Gets a new Vector3 from current Vector3 floored values
  61383. * @returns a new Vector3
  61384. */
  61385. fract(): Vector3;
  61386. /**
  61387. * Gets the length of the Vector3
  61388. * @returns the length of the Vecto3
  61389. */
  61390. length(): number;
  61391. /**
  61392. * Gets the squared length of the Vector3
  61393. * @returns squared length of the Vector3
  61394. */
  61395. lengthSquared(): number;
  61396. /**
  61397. * Normalize the current Vector3.
  61398. * Please note that this is an in place operation.
  61399. * @returns the current updated Vector3
  61400. */
  61401. normalize(): Vector3;
  61402. /**
  61403. * Reorders the x y z properties of the vector in place
  61404. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61405. * @returns the current updated vector
  61406. */
  61407. reorderInPlace(order: string): this;
  61408. /**
  61409. * Rotates the vector around 0,0,0 by a quaternion
  61410. * @param quaternion the rotation quaternion
  61411. * @param result vector to store the result
  61412. * @returns the resulting vector
  61413. */
  61414. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61415. /**
  61416. * Rotates a vector around a given point
  61417. * @param quaternion the rotation quaternion
  61418. * @param point the point to rotate around
  61419. * @param result vector to store the result
  61420. * @returns the resulting vector
  61421. */
  61422. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61423. /**
  61424. * Normalize the current Vector3 with the given input length.
  61425. * Please note that this is an in place operation.
  61426. * @param len the length of the vector
  61427. * @returns the current updated Vector3
  61428. */
  61429. normalizeFromLength(len: number): Vector3;
  61430. /**
  61431. * Normalize the current Vector3 to a new vector
  61432. * @returns the new Vector3
  61433. */
  61434. normalizeToNew(): Vector3;
  61435. /**
  61436. * Normalize the current Vector3 to the reference
  61437. * @param reference define the Vector3 to update
  61438. * @returns the updated Vector3
  61439. */
  61440. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61441. /**
  61442. * Creates a new Vector3 copied from the current Vector3
  61443. * @returns the new Vector3
  61444. */
  61445. clone(): Vector3;
  61446. /**
  61447. * Copies the given vector coordinates to the current Vector3 ones
  61448. * @param source defines the source Vector3
  61449. * @returns the current updated Vector3
  61450. */
  61451. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61452. /**
  61453. * Copies the given floats to the current Vector3 coordinates
  61454. * @param x defines the x coordinate of the operand
  61455. * @param y defines the y coordinate of the operand
  61456. * @param z defines the z coordinate of the operand
  61457. * @returns the current updated Vector3
  61458. */
  61459. copyFromFloats(x: number, y: number, z: number): Vector3;
  61460. /**
  61461. * Copies the given floats to the current Vector3 coordinates
  61462. * @param x defines the x coordinate of the operand
  61463. * @param y defines the y coordinate of the operand
  61464. * @param z defines the z coordinate of the operand
  61465. * @returns the current updated Vector3
  61466. */
  61467. set(x: number, y: number, z: number): Vector3;
  61468. /**
  61469. * Copies the given float to the current Vector3 coordinates
  61470. * @param v defines the x, y and z coordinates of the operand
  61471. * @returns the current updated Vector3
  61472. */
  61473. setAll(v: number): Vector3;
  61474. /**
  61475. * Get the clip factor between two vectors
  61476. * @param vector0 defines the first operand
  61477. * @param vector1 defines the second operand
  61478. * @param axis defines the axis to use
  61479. * @param size defines the size along the axis
  61480. * @returns the clip factor
  61481. */
  61482. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61483. /**
  61484. * Get angle between two vectors
  61485. * @param vector0 angle between vector0 and vector1
  61486. * @param vector1 angle between vector0 and vector1
  61487. * @param normal direction of the normal
  61488. * @return the angle between vector0 and vector1
  61489. */
  61490. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61491. /**
  61492. * Returns a new Vector3 set from the index "offset" of the given array
  61493. * @param array defines the source array
  61494. * @param offset defines the offset in the source array
  61495. * @returns the new Vector3
  61496. */
  61497. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61498. /**
  61499. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61500. * This function is deprecated. Use FromArray instead
  61501. * @param array defines the source array
  61502. * @param offset defines the offset in the source array
  61503. * @returns the new Vector3
  61504. */
  61505. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61506. /**
  61507. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61508. * @param array defines the source array
  61509. * @param offset defines the offset in the source array
  61510. * @param result defines the Vector3 where to store the result
  61511. */
  61512. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61513. /**
  61514. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61515. * This function is deprecated. Use FromArrayToRef instead.
  61516. * @param array defines the source array
  61517. * @param offset defines the offset in the source array
  61518. * @param result defines the Vector3 where to store the result
  61519. */
  61520. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61521. /**
  61522. * Sets the given vector "result" with the given floats.
  61523. * @param x defines the x coordinate of the source
  61524. * @param y defines the y coordinate of the source
  61525. * @param z defines the z coordinate of the source
  61526. * @param result defines the Vector3 where to store the result
  61527. */
  61528. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61529. /**
  61530. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61531. * @returns a new empty Vector3
  61532. */
  61533. static Zero(): Vector3;
  61534. /**
  61535. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61536. * @returns a new unit Vector3
  61537. */
  61538. static One(): Vector3;
  61539. /**
  61540. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61541. * @returns a new up Vector3
  61542. */
  61543. static Up(): Vector3;
  61544. /**
  61545. * Gets a up Vector3 that must not be updated
  61546. */
  61547. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61548. /**
  61549. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61550. * @returns a new down Vector3
  61551. */
  61552. static Down(): Vector3;
  61553. /**
  61554. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61555. * @returns a new forward Vector3
  61556. */
  61557. static Forward(): Vector3;
  61558. /**
  61559. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61560. * @returns a new forward Vector3
  61561. */
  61562. static Backward(): Vector3;
  61563. /**
  61564. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61565. * @returns a new right Vector3
  61566. */
  61567. static Right(): Vector3;
  61568. /**
  61569. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61570. * @returns a new left Vector3
  61571. */
  61572. static Left(): Vector3;
  61573. /**
  61574. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61575. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61576. * @param vector defines the Vector3 to transform
  61577. * @param transformation defines the transformation matrix
  61578. * @returns the transformed Vector3
  61579. */
  61580. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61581. /**
  61582. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61583. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61584. * @param vector defines the Vector3 to transform
  61585. * @param transformation defines the transformation matrix
  61586. * @param result defines the Vector3 where to store the result
  61587. */
  61588. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61589. /**
  61590. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61591. * This method computes tranformed coordinates only, not transformed direction vectors
  61592. * @param x define the x coordinate of the source vector
  61593. * @param y define the y coordinate of the source vector
  61594. * @param z define the z coordinate of the source vector
  61595. * @param transformation defines the transformation matrix
  61596. * @param result defines the Vector3 where to store the result
  61597. */
  61598. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61599. /**
  61600. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61601. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61602. * @param vector defines the Vector3 to transform
  61603. * @param transformation defines the transformation matrix
  61604. * @returns the new Vector3
  61605. */
  61606. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61607. /**
  61608. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61609. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61610. * @param vector defines the Vector3 to transform
  61611. * @param transformation defines the transformation matrix
  61612. * @param result defines the Vector3 where to store the result
  61613. */
  61614. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61615. /**
  61616. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61617. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61618. * @param x define the x coordinate of the source vector
  61619. * @param y define the y coordinate of the source vector
  61620. * @param z define the z coordinate of the source vector
  61621. * @param transformation defines the transformation matrix
  61622. * @param result defines the Vector3 where to store the result
  61623. */
  61624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61625. /**
  61626. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61627. * @param value1 defines the first control point
  61628. * @param value2 defines the second control point
  61629. * @param value3 defines the third control point
  61630. * @param value4 defines the fourth control point
  61631. * @param amount defines the amount on the spline to use
  61632. * @returns the new Vector3
  61633. */
  61634. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61635. /**
  61636. * 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"
  61637. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61638. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61639. * @param value defines the current value
  61640. * @param min defines the lower range value
  61641. * @param max defines the upper range value
  61642. * @returns the new Vector3
  61643. */
  61644. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61645. /**
  61646. * 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"
  61647. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61648. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61649. * @param value defines the current value
  61650. * @param min defines the lower range value
  61651. * @param max defines the upper range value
  61652. * @param result defines the Vector3 where to store the result
  61653. */
  61654. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61655. /**
  61656. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61657. * @param value1 defines the first control point
  61658. * @param tangent1 defines the first tangent vector
  61659. * @param value2 defines the second control point
  61660. * @param tangent2 defines the second tangent vector
  61661. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61662. * @returns the new Vector3
  61663. */
  61664. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61665. /**
  61666. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61667. * @param start defines the start value
  61668. * @param end defines the end value
  61669. * @param amount max defines amount between both (between 0 and 1)
  61670. * @returns the new Vector3
  61671. */
  61672. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61673. /**
  61674. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61675. * @param start defines the start value
  61676. * @param end defines the end value
  61677. * @param amount max defines amount between both (between 0 and 1)
  61678. * @param result defines the Vector3 where to store the result
  61679. */
  61680. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61681. /**
  61682. * Returns the dot product (float) between the vectors "left" and "right"
  61683. * @param left defines the left operand
  61684. * @param right defines the right operand
  61685. * @returns the dot product
  61686. */
  61687. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61688. /**
  61689. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61690. * The cross product is then orthogonal to both "left" and "right"
  61691. * @param left defines the left operand
  61692. * @param right defines the right operand
  61693. * @returns the cross product
  61694. */
  61695. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61696. /**
  61697. * Sets the given vector "result" with the cross product of "left" and "right"
  61698. * The cross product is then orthogonal to both "left" and "right"
  61699. * @param left defines the left operand
  61700. * @param right defines the right operand
  61701. * @param result defines the Vector3 where to store the result
  61702. */
  61703. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61704. /**
  61705. * Returns a new Vector3 as the normalization of the given vector
  61706. * @param vector defines the Vector3 to normalize
  61707. * @returns the new Vector3
  61708. */
  61709. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61710. /**
  61711. * Sets the given vector "result" with the normalization of the given first vector
  61712. * @param vector defines the Vector3 to normalize
  61713. * @param result defines the Vector3 where to store the result
  61714. */
  61715. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61716. /**
  61717. * Project a Vector3 onto screen space
  61718. * @param vector defines the Vector3 to project
  61719. * @param world defines the world matrix to use
  61720. * @param transform defines the transform (view x projection) matrix to use
  61721. * @param viewport defines the screen viewport to use
  61722. * @returns the new Vector3
  61723. */
  61724. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61725. /** @hidden */
  61726. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61727. /**
  61728. * Unproject from screen space to object space
  61729. * @param source defines the screen space Vector3 to use
  61730. * @param viewportWidth defines the current width of the viewport
  61731. * @param viewportHeight defines the current height of the viewport
  61732. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61733. * @param transform defines the transform (view x projection) matrix to use
  61734. * @returns the new Vector3
  61735. */
  61736. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61737. /**
  61738. * Unproject from screen space to object space
  61739. * @param source defines the screen space Vector3 to use
  61740. * @param viewportWidth defines the current width of the viewport
  61741. * @param viewportHeight defines the current height of the viewport
  61742. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61743. * @param view defines the view matrix to use
  61744. * @param projection defines the projection matrix to use
  61745. * @returns the new Vector3
  61746. */
  61747. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61748. /**
  61749. * Unproject from screen space to object space
  61750. * @param source defines the screen space Vector3 to use
  61751. * @param viewportWidth defines the current width of the viewport
  61752. * @param viewportHeight defines the current height of the viewport
  61753. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61754. * @param view defines the view matrix to use
  61755. * @param projection defines the projection matrix to use
  61756. * @param result defines the Vector3 where to store the result
  61757. */
  61758. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61759. /**
  61760. * Unproject from screen space to object space
  61761. * @param sourceX defines the screen space x coordinate to use
  61762. * @param sourceY defines the screen space y coordinate to use
  61763. * @param sourceZ defines the screen space z coordinate to use
  61764. * @param viewportWidth defines the current width of the viewport
  61765. * @param viewportHeight defines the current height of the viewport
  61766. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61767. * @param view defines the view matrix to use
  61768. * @param projection defines the projection matrix to use
  61769. * @param result defines the Vector3 where to store the result
  61770. */
  61771. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61772. /**
  61773. * Gets the minimal coordinate values between two Vector3
  61774. * @param left defines the first operand
  61775. * @param right defines the second operand
  61776. * @returns the new Vector3
  61777. */
  61778. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61779. /**
  61780. * Gets the maximal coordinate values between two Vector3
  61781. * @param left defines the first operand
  61782. * @param right defines the second operand
  61783. * @returns the new Vector3
  61784. */
  61785. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61786. /**
  61787. * Returns the distance between the vectors "value1" and "value2"
  61788. * @param value1 defines the first operand
  61789. * @param value2 defines the second operand
  61790. * @returns the distance
  61791. */
  61792. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61793. /**
  61794. * Returns the squared distance between the vectors "value1" and "value2"
  61795. * @param value1 defines the first operand
  61796. * @param value2 defines the second operand
  61797. * @returns the squared distance
  61798. */
  61799. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61800. /**
  61801. * Returns a new Vector3 located at the center between "value1" and "value2"
  61802. * @param value1 defines the first operand
  61803. * @param value2 defines the second operand
  61804. * @returns the new Vector3
  61805. */
  61806. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61807. /**
  61808. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61809. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61810. * to something in order to rotate it from its local system to the given target system
  61811. * Note: axis1, axis2 and axis3 are normalized during this operation
  61812. * @param axis1 defines the first axis
  61813. * @param axis2 defines the second axis
  61814. * @param axis3 defines the third axis
  61815. * @returns a new Vector3
  61816. */
  61817. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61818. /**
  61819. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61820. * @param axis1 defines the first axis
  61821. * @param axis2 defines the second axis
  61822. * @param axis3 defines the third axis
  61823. * @param ref defines the Vector3 where to store the result
  61824. */
  61825. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61826. }
  61827. /**
  61828. * Vector4 class created for EulerAngle class conversion to Quaternion
  61829. */
  61830. export class Vector4 {
  61831. /** x value of the vector */
  61832. x: number;
  61833. /** y value of the vector */
  61834. y: number;
  61835. /** z value of the vector */
  61836. z: number;
  61837. /** w value of the vector */
  61838. w: number;
  61839. /**
  61840. * Creates a Vector4 object from the given floats.
  61841. * @param x x value of the vector
  61842. * @param y y value of the vector
  61843. * @param z z value of the vector
  61844. * @param w w value of the vector
  61845. */
  61846. constructor(
  61847. /** x value of the vector */
  61848. x: number,
  61849. /** y value of the vector */
  61850. y: number,
  61851. /** z value of the vector */
  61852. z: number,
  61853. /** w value of the vector */
  61854. w: number);
  61855. /**
  61856. * Returns the string with the Vector4 coordinates.
  61857. * @returns a string containing all the vector values
  61858. */
  61859. toString(): string;
  61860. /**
  61861. * Returns the string "Vector4".
  61862. * @returns "Vector4"
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Returns the Vector4 hash code.
  61867. * @returns a unique hash code
  61868. */
  61869. getHashCode(): number;
  61870. /**
  61871. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61872. * @returns the resulting array
  61873. */
  61874. asArray(): number[];
  61875. /**
  61876. * Populates the given array from the given index with the Vector4 coordinates.
  61877. * @param array array to populate
  61878. * @param index index of the array to start at (default: 0)
  61879. * @returns the Vector4.
  61880. */
  61881. toArray(array: FloatArray, index?: number): Vector4;
  61882. /**
  61883. * Adds the given vector to the current Vector4.
  61884. * @param otherVector the vector to add
  61885. * @returns the updated Vector4.
  61886. */
  61887. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61888. /**
  61889. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61890. * @param otherVector the vector to add
  61891. * @returns the resulting vector
  61892. */
  61893. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61894. /**
  61895. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61896. * @param otherVector the vector to add
  61897. * @param result the vector to store the result
  61898. * @returns the current Vector4.
  61899. */
  61900. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61901. /**
  61902. * Subtract in place the given vector from the current Vector4.
  61903. * @param otherVector the vector to subtract
  61904. * @returns the updated Vector4.
  61905. */
  61906. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61907. /**
  61908. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61909. * @param otherVector the vector to add
  61910. * @returns the new vector with the result
  61911. */
  61912. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61913. /**
  61914. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61915. * @param otherVector the vector to subtract
  61916. * @param result the vector to store the result
  61917. * @returns the current Vector4.
  61918. */
  61919. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61920. /**
  61921. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61922. */
  61923. /**
  61924. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61925. * @param x value to subtract
  61926. * @param y value to subtract
  61927. * @param z value to subtract
  61928. * @param w value to subtract
  61929. * @returns new vector containing the result
  61930. */
  61931. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61932. /**
  61933. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61934. * @param x value to subtract
  61935. * @param y value to subtract
  61936. * @param z value to subtract
  61937. * @param w value to subtract
  61938. * @param result the vector to store the result in
  61939. * @returns the current Vector4.
  61940. */
  61941. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61942. /**
  61943. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61944. * @returns a new vector with the negated values
  61945. */
  61946. negate(): Vector4;
  61947. /**
  61948. * Multiplies the current Vector4 coordinates by scale (float).
  61949. * @param scale the number to scale with
  61950. * @returns the updated Vector4.
  61951. */
  61952. scaleInPlace(scale: number): Vector4;
  61953. /**
  61954. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61955. * @param scale the number to scale with
  61956. * @returns a new vector with the result
  61957. */
  61958. scale(scale: number): Vector4;
  61959. /**
  61960. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61961. * @param scale the number to scale with
  61962. * @param result a vector to store the result in
  61963. * @returns the current Vector4.
  61964. */
  61965. scaleToRef(scale: number, result: Vector4): Vector4;
  61966. /**
  61967. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61968. * @param scale defines the scale factor
  61969. * @param result defines the Vector4 object where to store the result
  61970. * @returns the unmodified current Vector4
  61971. */
  61972. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61973. /**
  61974. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61975. * @param otherVector the vector to compare against
  61976. * @returns true if they are equal
  61977. */
  61978. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61979. /**
  61980. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61981. * @param otherVector vector to compare against
  61982. * @param epsilon (Default: very small number)
  61983. * @returns true if they are equal
  61984. */
  61985. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61986. /**
  61987. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61988. * @param x x value to compare against
  61989. * @param y y value to compare against
  61990. * @param z z value to compare against
  61991. * @param w w value to compare against
  61992. * @returns true if equal
  61993. */
  61994. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61995. /**
  61996. * Multiplies in place the current Vector4 by the given one.
  61997. * @param otherVector vector to multiple with
  61998. * @returns the updated Vector4.
  61999. */
  62000. multiplyInPlace(otherVector: Vector4): Vector4;
  62001. /**
  62002. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62003. * @param otherVector vector to multiple with
  62004. * @returns resulting new vector
  62005. */
  62006. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62007. /**
  62008. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62009. * @param otherVector vector to multiple with
  62010. * @param result vector to store the result
  62011. * @returns the current Vector4.
  62012. */
  62013. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62014. /**
  62015. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62016. * @param x x value multiply with
  62017. * @param y y value multiply with
  62018. * @param z z value multiply with
  62019. * @param w w value multiply with
  62020. * @returns resulting new vector
  62021. */
  62022. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62023. /**
  62024. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62025. * @param otherVector vector to devide with
  62026. * @returns resulting new vector
  62027. */
  62028. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62029. /**
  62030. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62031. * @param otherVector vector to devide with
  62032. * @param result vector to store the result
  62033. * @returns the current Vector4.
  62034. */
  62035. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62036. /**
  62037. * Divides the current Vector3 coordinates by the given ones.
  62038. * @param otherVector vector to devide with
  62039. * @returns the updated Vector3.
  62040. */
  62041. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62042. /**
  62043. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62044. * @param other defines the second operand
  62045. * @returns the current updated Vector4
  62046. */
  62047. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62048. /**
  62049. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62050. * @param other defines the second operand
  62051. * @returns the current updated Vector4
  62052. */
  62053. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62054. /**
  62055. * Gets a new Vector4 from current Vector4 floored values
  62056. * @returns a new Vector4
  62057. */
  62058. floor(): Vector4;
  62059. /**
  62060. * Gets a new Vector4 from current Vector3 floored values
  62061. * @returns a new Vector4
  62062. */
  62063. fract(): Vector4;
  62064. /**
  62065. * Returns the Vector4 length (float).
  62066. * @returns the length
  62067. */
  62068. length(): number;
  62069. /**
  62070. * Returns the Vector4 squared length (float).
  62071. * @returns the length squared
  62072. */
  62073. lengthSquared(): number;
  62074. /**
  62075. * Normalizes in place the Vector4.
  62076. * @returns the updated Vector4.
  62077. */
  62078. normalize(): Vector4;
  62079. /**
  62080. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62081. * @returns this converted to a new vector3
  62082. */
  62083. toVector3(): Vector3;
  62084. /**
  62085. * Returns a new Vector4 copied from the current one.
  62086. * @returns the new cloned vector
  62087. */
  62088. clone(): Vector4;
  62089. /**
  62090. * Updates the current Vector4 with the given one coordinates.
  62091. * @param source the source vector to copy from
  62092. * @returns the updated Vector4.
  62093. */
  62094. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62095. /**
  62096. * Updates the current Vector4 coordinates with the given floats.
  62097. * @param x float to copy from
  62098. * @param y float to copy from
  62099. * @param z float to copy from
  62100. * @param w float to copy from
  62101. * @returns the updated Vector4.
  62102. */
  62103. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62104. /**
  62105. * Updates the current Vector4 coordinates with the given floats.
  62106. * @param x float to set from
  62107. * @param y float to set from
  62108. * @param z float to set from
  62109. * @param w float to set from
  62110. * @returns the updated Vector4.
  62111. */
  62112. set(x: number, y: number, z: number, w: number): Vector4;
  62113. /**
  62114. * Copies the given float to the current Vector3 coordinates
  62115. * @param v defines the x, y, z and w coordinates of the operand
  62116. * @returns the current updated Vector3
  62117. */
  62118. setAll(v: number): Vector4;
  62119. /**
  62120. * Returns a new Vector4 set from the starting index of the given array.
  62121. * @param array the array to pull values from
  62122. * @param offset the offset into the array to start at
  62123. * @returns the new vector
  62124. */
  62125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62126. /**
  62127. * Updates the given vector "result" from the starting index of the given array.
  62128. * @param array the array to pull values from
  62129. * @param offset the offset into the array to start at
  62130. * @param result the vector to store the result in
  62131. */
  62132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62133. /**
  62134. * Updates the given vector "result" from the starting index of the given Float32Array.
  62135. * @param array the array to pull values from
  62136. * @param offset the offset into the array to start at
  62137. * @param result the vector to store the result in
  62138. */
  62139. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62140. /**
  62141. * Updates the given vector "result" coordinates from the given floats.
  62142. * @param x float to set from
  62143. * @param y float to set from
  62144. * @param z float to set from
  62145. * @param w float to set from
  62146. * @param result the vector to the floats in
  62147. */
  62148. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62149. /**
  62150. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62151. * @returns the new vector
  62152. */
  62153. static Zero(): Vector4;
  62154. /**
  62155. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62156. * @returns the new vector
  62157. */
  62158. static One(): Vector4;
  62159. /**
  62160. * Returns a new normalized Vector4 from the given one.
  62161. * @param vector the vector to normalize
  62162. * @returns the vector
  62163. */
  62164. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62165. /**
  62166. * Updates the given vector "result" from the normalization of the given one.
  62167. * @param vector the vector to normalize
  62168. * @param result the vector to store the result in
  62169. */
  62170. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62171. /**
  62172. * Returns a vector with the minimum values from the left and right vectors
  62173. * @param left left vector to minimize
  62174. * @param right right vector to minimize
  62175. * @returns a new vector with the minimum of the left and right vector values
  62176. */
  62177. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62178. /**
  62179. * Returns a vector with the maximum values from the left and right vectors
  62180. * @param left left vector to maximize
  62181. * @param right right vector to maximize
  62182. * @returns a new vector with the maximum of the left and right vector values
  62183. */
  62184. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62185. /**
  62186. * Returns the distance (float) between the vectors "value1" and "value2".
  62187. * @param value1 value to calulate the distance between
  62188. * @param value2 value to calulate the distance between
  62189. * @return the distance between the two vectors
  62190. */
  62191. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62192. /**
  62193. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62194. * @param value1 value to calulate the distance between
  62195. * @param value2 value to calulate the distance between
  62196. * @return the distance between the two vectors squared
  62197. */
  62198. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62199. /**
  62200. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62201. * @param value1 value to calulate the center between
  62202. * @param value2 value to calulate the center between
  62203. * @return the center between the two vectors
  62204. */
  62205. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62206. /**
  62207. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62208. * This methods computes transformed normalized direction vectors only.
  62209. * @param vector the vector to transform
  62210. * @param transformation the transformation matrix to apply
  62211. * @returns the new vector
  62212. */
  62213. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62214. /**
  62215. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62216. * This methods computes transformed normalized direction vectors only.
  62217. * @param vector the vector to transform
  62218. * @param transformation the transformation matrix to apply
  62219. * @param result the vector to store the result in
  62220. */
  62221. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62222. /**
  62223. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62224. * This methods computes transformed normalized direction vectors only.
  62225. * @param x value to transform
  62226. * @param y value to transform
  62227. * @param z value to transform
  62228. * @param w value to transform
  62229. * @param transformation the transformation matrix to apply
  62230. * @param result the vector to store the results in
  62231. */
  62232. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62233. /**
  62234. * Creates a new Vector4 from a Vector3
  62235. * @param source defines the source data
  62236. * @param w defines the 4th component (default is 0)
  62237. * @returns a new Vector4
  62238. */
  62239. static FromVector3(source: Vector3, w?: number): Vector4;
  62240. }
  62241. /**
  62242. * Interface for the size containing width and height
  62243. */
  62244. export interface ISize {
  62245. /**
  62246. * Width
  62247. */
  62248. width: number;
  62249. /**
  62250. * Heighht
  62251. */
  62252. height: number;
  62253. }
  62254. /**
  62255. * Size containing widht and height
  62256. */
  62257. export class Size implements ISize {
  62258. /**
  62259. * Width
  62260. */
  62261. width: number;
  62262. /**
  62263. * Height
  62264. */
  62265. height: number;
  62266. /**
  62267. * Creates a Size object from the given width and height (floats).
  62268. * @param width width of the new size
  62269. * @param height height of the new size
  62270. */
  62271. constructor(width: number, height: number);
  62272. /**
  62273. * Returns a string with the Size width and height
  62274. * @returns a string with the Size width and height
  62275. */
  62276. toString(): string;
  62277. /**
  62278. * "Size"
  62279. * @returns the string "Size"
  62280. */
  62281. getClassName(): string;
  62282. /**
  62283. * Returns the Size hash code.
  62284. * @returns a hash code for a unique width and height
  62285. */
  62286. getHashCode(): number;
  62287. /**
  62288. * Updates the current size from the given one.
  62289. * @param src the given size
  62290. */
  62291. copyFrom(src: Size): void;
  62292. /**
  62293. * Updates in place the current Size from the given floats.
  62294. * @param width width of the new size
  62295. * @param height height of the new size
  62296. * @returns the updated Size.
  62297. */
  62298. copyFromFloats(width: number, height: number): Size;
  62299. /**
  62300. * Updates in place the current Size from the given floats.
  62301. * @param width width to set
  62302. * @param height height to set
  62303. * @returns the updated Size.
  62304. */
  62305. set(width: number, height: number): Size;
  62306. /**
  62307. * Multiplies the width and height by numbers
  62308. * @param w factor to multiple the width by
  62309. * @param h factor to multiple the height by
  62310. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62311. */
  62312. multiplyByFloats(w: number, h: number): Size;
  62313. /**
  62314. * Clones the size
  62315. * @returns a new Size copied from the given one.
  62316. */
  62317. clone(): Size;
  62318. /**
  62319. * True if the current Size and the given one width and height are strictly equal.
  62320. * @param other the other size to compare against
  62321. * @returns True if the current Size and the given one width and height are strictly equal.
  62322. */
  62323. equals(other: Size): boolean;
  62324. /**
  62325. * The surface of the Size : width * height (float).
  62326. */
  62327. readonly surface: number;
  62328. /**
  62329. * Create a new size of zero
  62330. * @returns a new Size set to (0.0, 0.0)
  62331. */
  62332. static Zero(): Size;
  62333. /**
  62334. * Sums the width and height of two sizes
  62335. * @param otherSize size to add to this size
  62336. * @returns a new Size set as the addition result of the current Size and the given one.
  62337. */
  62338. add(otherSize: Size): Size;
  62339. /**
  62340. * Subtracts the width and height of two
  62341. * @param otherSize size to subtract to this size
  62342. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62343. */
  62344. subtract(otherSize: Size): Size;
  62345. /**
  62346. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62347. * @param start starting size to lerp between
  62348. * @param end end size to lerp between
  62349. * @param amount amount to lerp between the start and end values
  62350. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62351. */
  62352. static Lerp(start: Size, end: Size, amount: number): Size;
  62353. }
  62354. /**
  62355. * Class used to store quaternion data
  62356. * @see https://en.wikipedia.org/wiki/Quaternion
  62357. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62358. */
  62359. export class Quaternion {
  62360. /** defines the first component (0 by default) */
  62361. x: number;
  62362. /** defines the second component (0 by default) */
  62363. y: number;
  62364. /** defines the third component (0 by default) */
  62365. z: number;
  62366. /** defines the fourth component (1.0 by default) */
  62367. w: number;
  62368. /**
  62369. * Creates a new Quaternion from the given floats
  62370. * @param x defines the first component (0 by default)
  62371. * @param y defines the second component (0 by default)
  62372. * @param z defines the third component (0 by default)
  62373. * @param w defines the fourth component (1.0 by default)
  62374. */
  62375. constructor(
  62376. /** defines the first component (0 by default) */
  62377. x?: number,
  62378. /** defines the second component (0 by default) */
  62379. y?: number,
  62380. /** defines the third component (0 by default) */
  62381. z?: number,
  62382. /** defines the fourth component (1.0 by default) */
  62383. w?: number);
  62384. /**
  62385. * Gets a string representation for the current quaternion
  62386. * @returns a string with the Quaternion coordinates
  62387. */
  62388. toString(): string;
  62389. /**
  62390. * Gets the class name of the quaternion
  62391. * @returns the string "Quaternion"
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets a hash code for this quaternion
  62396. * @returns the quaternion hash code
  62397. */
  62398. getHashCode(): number;
  62399. /**
  62400. * Copy the quaternion to an array
  62401. * @returns a new array populated with 4 elements from the quaternion coordinates
  62402. */
  62403. asArray(): number[];
  62404. /**
  62405. * Check if two quaternions are equals
  62406. * @param otherQuaternion defines the second operand
  62407. * @return true if the current quaternion and the given one coordinates are strictly equals
  62408. */
  62409. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62410. /**
  62411. * Clone the current quaternion
  62412. * @returns a new quaternion copied from the current one
  62413. */
  62414. clone(): Quaternion;
  62415. /**
  62416. * Copy a quaternion to the current one
  62417. * @param other defines the other quaternion
  62418. * @returns the updated current quaternion
  62419. */
  62420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62421. /**
  62422. * Updates the current quaternion with the given float coordinates
  62423. * @param x defines the x coordinate
  62424. * @param y defines the y coordinate
  62425. * @param z defines the z coordinate
  62426. * @param w defines the w coordinate
  62427. * @returns the updated current quaternion
  62428. */
  62429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62430. /**
  62431. * Updates the current quaternion from the given float coordinates
  62432. * @param x defines the x coordinate
  62433. * @param y defines the y coordinate
  62434. * @param z defines the z coordinate
  62435. * @param w defines the w coordinate
  62436. * @returns the updated current quaternion
  62437. */
  62438. set(x: number, y: number, z: number, w: number): Quaternion;
  62439. /**
  62440. * Adds two quaternions
  62441. * @param other defines the second operand
  62442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62443. */
  62444. add(other: DeepImmutable<Quaternion>): Quaternion;
  62445. /**
  62446. * Add a quaternion to the current one
  62447. * @param other defines the quaternion to add
  62448. * @returns the current quaternion
  62449. */
  62450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62451. /**
  62452. * Subtract two quaternions
  62453. * @param other defines the second operand
  62454. * @returns a new quaternion as the subtraction result of the given one from the current one
  62455. */
  62456. subtract(other: Quaternion): Quaternion;
  62457. /**
  62458. * Multiplies the current quaternion by a scale factor
  62459. * @param value defines the scale factor
  62460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62461. */
  62462. scale(value: number): Quaternion;
  62463. /**
  62464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62465. * @param scale defines the scale factor
  62466. * @param result defines the Quaternion object where to store the result
  62467. * @returns the unmodified current quaternion
  62468. */
  62469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62470. /**
  62471. * Multiplies in place the current quaternion by a scale factor
  62472. * @param value defines the scale factor
  62473. * @returns the current modified quaternion
  62474. */
  62475. scaleInPlace(value: number): Quaternion;
  62476. /**
  62477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62478. * @param scale defines the scale factor
  62479. * @param result defines the Quaternion object where to store the result
  62480. * @returns the unmodified current quaternion
  62481. */
  62482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62483. /**
  62484. * Multiplies two quaternions
  62485. * @param q1 defines the second operand
  62486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62487. */
  62488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62489. /**
  62490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62491. * @param q1 defines the second operand
  62492. * @param result defines the target quaternion
  62493. * @returns the current quaternion
  62494. */
  62495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62496. /**
  62497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62498. * @param q1 defines the second operand
  62499. * @returns the currentupdated quaternion
  62500. */
  62501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62502. /**
  62503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62504. * @param ref defines the target quaternion
  62505. * @returns the current quaternion
  62506. */
  62507. conjugateToRef(ref: Quaternion): Quaternion;
  62508. /**
  62509. * Conjugates in place (1-q) the current quaternion
  62510. * @returns the current updated quaternion
  62511. */
  62512. conjugateInPlace(): Quaternion;
  62513. /**
  62514. * Conjugates in place (1-q) the current quaternion
  62515. * @returns a new quaternion
  62516. */
  62517. conjugate(): Quaternion;
  62518. /**
  62519. * Gets length of current quaternion
  62520. * @returns the quaternion length (float)
  62521. */
  62522. length(): number;
  62523. /**
  62524. * Normalize in place the current quaternion
  62525. * @returns the current updated quaternion
  62526. */
  62527. normalize(): Quaternion;
  62528. /**
  62529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62530. * @param order is a reserved parameter and is ignore for now
  62531. * @returns a new Vector3 containing the Euler angles
  62532. */
  62533. toEulerAngles(order?: string): Vector3;
  62534. /**
  62535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62536. * @param result defines the vector which will be filled with the Euler angles
  62537. * @param order is a reserved parameter and is ignore for now
  62538. * @returns the current unchanged quaternion
  62539. */
  62540. toEulerAnglesToRef(result: Vector3): Quaternion;
  62541. /**
  62542. * Updates the given rotation matrix with the current quaternion values
  62543. * @param result defines the target matrix
  62544. * @returns the current unchanged quaternion
  62545. */
  62546. toRotationMatrix(result: Matrix): Quaternion;
  62547. /**
  62548. * Updates the current quaternion from the given rotation matrix values
  62549. * @param matrix defines the source matrix
  62550. * @returns the current updated quaternion
  62551. */
  62552. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62553. /**
  62554. * Creates a new quaternion from a rotation matrix
  62555. * @param matrix defines the source matrix
  62556. * @returns a new quaternion created from the given rotation matrix values
  62557. */
  62558. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62559. /**
  62560. * Updates the given quaternion with the given rotation matrix values
  62561. * @param matrix defines the source matrix
  62562. * @param result defines the target quaternion
  62563. */
  62564. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62565. /**
  62566. * Returns the dot product (float) between the quaternions "left" and "right"
  62567. * @param left defines the left operand
  62568. * @param right defines the right operand
  62569. * @returns the dot product
  62570. */
  62571. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62572. /**
  62573. * Checks if the two quaternions are close to each other
  62574. * @param quat0 defines the first quaternion to check
  62575. * @param quat1 defines the second quaternion to check
  62576. * @returns true if the two quaternions are close to each other
  62577. */
  62578. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62579. /**
  62580. * Creates an empty quaternion
  62581. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62582. */
  62583. static Zero(): Quaternion;
  62584. /**
  62585. * Inverse a given quaternion
  62586. * @param q defines the source quaternion
  62587. * @returns a new quaternion as the inverted current quaternion
  62588. */
  62589. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62590. /**
  62591. * Inverse a given quaternion
  62592. * @param q defines the source quaternion
  62593. * @param result the quaternion the result will be stored in
  62594. * @returns the result quaternion
  62595. */
  62596. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62597. /**
  62598. * Creates an identity quaternion
  62599. * @returns the identity quaternion
  62600. */
  62601. static Identity(): Quaternion;
  62602. /**
  62603. * Gets a boolean indicating if the given quaternion is identity
  62604. * @param quaternion defines the quaternion to check
  62605. * @returns true if the quaternion is identity
  62606. */
  62607. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62608. /**
  62609. * Creates a quaternion from a rotation around an axis
  62610. * @param axis defines the axis to use
  62611. * @param angle defines the angle to use
  62612. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62613. */
  62614. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62615. /**
  62616. * Creates a rotation around an axis and stores it into the given quaternion
  62617. * @param axis defines the axis to use
  62618. * @param angle defines the angle to use
  62619. * @param result defines the target quaternion
  62620. * @returns the target quaternion
  62621. */
  62622. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62623. /**
  62624. * Creates a new quaternion from data stored into an array
  62625. * @param array defines the data source
  62626. * @param offset defines the offset in the source array where the data starts
  62627. * @returns a new quaternion
  62628. */
  62629. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62630. /**
  62631. * Create a quaternion from Euler rotation angles
  62632. * @param x Pitch
  62633. * @param y Yaw
  62634. * @param z Roll
  62635. * @returns the new Quaternion
  62636. */
  62637. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62638. /**
  62639. * Updates a quaternion from Euler rotation angles
  62640. * @param x Pitch
  62641. * @param y Yaw
  62642. * @param z Roll
  62643. * @param result the quaternion to store the result
  62644. * @returns the updated quaternion
  62645. */
  62646. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62647. /**
  62648. * Create a quaternion from Euler rotation vector
  62649. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62650. * @returns the new Quaternion
  62651. */
  62652. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62653. /**
  62654. * Updates a quaternion from Euler rotation vector
  62655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62656. * @param result the quaternion to store the result
  62657. * @returns the updated quaternion
  62658. */
  62659. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62660. /**
  62661. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62662. * @param yaw defines the rotation around Y axis
  62663. * @param pitch defines the rotation around X axis
  62664. * @param roll defines the rotation around Z axis
  62665. * @returns the new quaternion
  62666. */
  62667. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62668. /**
  62669. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62670. * @param yaw defines the rotation around Y axis
  62671. * @param pitch defines the rotation around X axis
  62672. * @param roll defines the rotation around Z axis
  62673. * @param result defines the target quaternion
  62674. */
  62675. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62676. /**
  62677. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62678. * @param alpha defines the rotation around first axis
  62679. * @param beta defines the rotation around second axis
  62680. * @param gamma defines the rotation around third axis
  62681. * @returns the new quaternion
  62682. */
  62683. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62684. /**
  62685. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62686. * @param alpha defines the rotation around first axis
  62687. * @param beta defines the rotation around second axis
  62688. * @param gamma defines the rotation around third axis
  62689. * @param result defines the target quaternion
  62690. */
  62691. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62692. /**
  62693. * 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)
  62694. * @param axis1 defines the first axis
  62695. * @param axis2 defines the second axis
  62696. * @param axis3 defines the third axis
  62697. * @returns the new quaternion
  62698. */
  62699. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62700. /**
  62701. * 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
  62702. * @param axis1 defines the first axis
  62703. * @param axis2 defines the second axis
  62704. * @param axis3 defines the third axis
  62705. * @param ref defines the target quaternion
  62706. */
  62707. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62708. /**
  62709. * Interpolates between two quaternions
  62710. * @param left defines first quaternion
  62711. * @param right defines second quaternion
  62712. * @param amount defines the gradient to use
  62713. * @returns the new interpolated quaternion
  62714. */
  62715. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62716. /**
  62717. * Interpolates between two quaternions and stores it into a target quaternion
  62718. * @param left defines first quaternion
  62719. * @param right defines second quaternion
  62720. * @param amount defines the gradient to use
  62721. * @param result defines the target quaternion
  62722. */
  62723. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62724. /**
  62725. * Interpolate between two quaternions using Hermite interpolation
  62726. * @param value1 defines first quaternion
  62727. * @param tangent1 defines the incoming tangent
  62728. * @param value2 defines second quaternion
  62729. * @param tangent2 defines the outgoing tangent
  62730. * @param amount defines the target quaternion
  62731. * @returns the new interpolated quaternion
  62732. */
  62733. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62734. }
  62735. /**
  62736. * Class used to store matrix data (4x4)
  62737. */
  62738. export class Matrix {
  62739. private static _updateFlagSeed;
  62740. private static _identityReadOnly;
  62741. private _isIdentity;
  62742. private _isIdentityDirty;
  62743. private _isIdentity3x2;
  62744. private _isIdentity3x2Dirty;
  62745. /**
  62746. * Gets the update flag of the matrix which is an unique number for the matrix.
  62747. * It will be incremented every time the matrix data change.
  62748. * You can use it to speed the comparison between two versions of the same matrix.
  62749. */
  62750. updateFlag: number;
  62751. private readonly _m;
  62752. /**
  62753. * Gets the internal data of the matrix
  62754. */
  62755. readonly m: DeepImmutable<Float32Array>;
  62756. /** @hidden */
  62757. _markAsUpdated(): void;
  62758. /** @hidden */
  62759. private _updateIdentityStatus;
  62760. /**
  62761. * Creates an empty matrix (filled with zeros)
  62762. */
  62763. constructor();
  62764. /**
  62765. * Check if the current matrix is identity
  62766. * @returns true is the matrix is the identity matrix
  62767. */
  62768. isIdentity(): boolean;
  62769. /**
  62770. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62771. * @returns true is the matrix is the identity matrix
  62772. */
  62773. isIdentityAs3x2(): boolean;
  62774. /**
  62775. * Gets the determinant of the matrix
  62776. * @returns the matrix determinant
  62777. */
  62778. determinant(): number;
  62779. /**
  62780. * Returns the matrix as a Float32Array
  62781. * @returns the matrix underlying array
  62782. */
  62783. toArray(): DeepImmutable<Float32Array>;
  62784. /**
  62785. * Returns the matrix as a Float32Array
  62786. * @returns the matrix underlying array.
  62787. */
  62788. asArray(): DeepImmutable<Float32Array>;
  62789. /**
  62790. * Inverts the current matrix in place
  62791. * @returns the current inverted matrix
  62792. */
  62793. invert(): Matrix;
  62794. /**
  62795. * Sets all the matrix elements to zero
  62796. * @returns the current matrix
  62797. */
  62798. reset(): Matrix;
  62799. /**
  62800. * Adds the current matrix with a second one
  62801. * @param other defines the matrix to add
  62802. * @returns a new matrix as the addition of the current matrix and the given one
  62803. */
  62804. add(other: DeepImmutable<Matrix>): Matrix;
  62805. /**
  62806. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62807. * @param other defines the matrix to add
  62808. * @param result defines the target matrix
  62809. * @returns the current matrix
  62810. */
  62811. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62812. /**
  62813. * Adds in place the given matrix to the current matrix
  62814. * @param other defines the second operand
  62815. * @returns the current updated matrix
  62816. */
  62817. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62818. /**
  62819. * Sets the given matrix to the current inverted Matrix
  62820. * @param other defines the target matrix
  62821. * @returns the unmodified current matrix
  62822. */
  62823. invertToRef(other: Matrix): Matrix;
  62824. /**
  62825. * add a value at the specified position in the current Matrix
  62826. * @param index the index of the value within the matrix. between 0 and 15.
  62827. * @param value the value to be added
  62828. * @returns the current updated matrix
  62829. */
  62830. addAtIndex(index: number, value: number): Matrix;
  62831. /**
  62832. * mutiply the specified position in the current Matrix by a value
  62833. * @param index the index of the value within the matrix. between 0 and 15.
  62834. * @param value the value to be added
  62835. * @returns the current updated matrix
  62836. */
  62837. multiplyAtIndex(index: number, value: number): Matrix;
  62838. /**
  62839. * Inserts the translation vector (using 3 floats) in the current matrix
  62840. * @param x defines the 1st component of the translation
  62841. * @param y defines the 2nd component of the translation
  62842. * @param z defines the 3rd component of the translation
  62843. * @returns the current updated matrix
  62844. */
  62845. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62846. /**
  62847. * Adds the translation vector (using 3 floats) in the current matrix
  62848. * @param x defines the 1st component of the translation
  62849. * @param y defines the 2nd component of the translation
  62850. * @param z defines the 3rd component of the translation
  62851. * @returns the current updated matrix
  62852. */
  62853. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62854. /**
  62855. * Inserts the translation vector in the current matrix
  62856. * @param vector3 defines the translation to insert
  62857. * @returns the current updated matrix
  62858. */
  62859. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62860. /**
  62861. * Gets the translation value of the current matrix
  62862. * @returns a new Vector3 as the extracted translation from the matrix
  62863. */
  62864. getTranslation(): Vector3;
  62865. /**
  62866. * Fill a Vector3 with the extracted translation from the matrix
  62867. * @param result defines the Vector3 where to store the translation
  62868. * @returns the current matrix
  62869. */
  62870. getTranslationToRef(result: Vector3): Matrix;
  62871. /**
  62872. * Remove rotation and scaling part from the matrix
  62873. * @returns the updated matrix
  62874. */
  62875. removeRotationAndScaling(): Matrix;
  62876. /**
  62877. * Multiply two matrices
  62878. * @param other defines the second operand
  62879. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62880. */
  62881. multiply(other: DeepImmutable<Matrix>): Matrix;
  62882. /**
  62883. * Copy the current matrix from the given one
  62884. * @param other defines the source matrix
  62885. * @returns the current updated matrix
  62886. */
  62887. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62888. /**
  62889. * Populates the given array from the starting index with the current matrix values
  62890. * @param array defines the target array
  62891. * @param offset defines the offset in the target array where to start storing values
  62892. * @returns the current matrix
  62893. */
  62894. copyToArray(array: Float32Array, offset?: number): Matrix;
  62895. /**
  62896. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62897. * @param other defines the second operand
  62898. * @param result defines the matrix where to store the multiplication
  62899. * @returns the current matrix
  62900. */
  62901. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62902. /**
  62903. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62904. * @param other defines the second operand
  62905. * @param result defines the array where to store the multiplication
  62906. * @param offset defines the offset in the target array where to start storing values
  62907. * @returns the current matrix
  62908. */
  62909. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62910. /**
  62911. * Check equality between this matrix and a second one
  62912. * @param value defines the second matrix to compare
  62913. * @returns true is the current matrix and the given one values are strictly equal
  62914. */
  62915. equals(value: DeepImmutable<Matrix>): boolean;
  62916. /**
  62917. * Clone the current matrix
  62918. * @returns a new matrix from the current matrix
  62919. */
  62920. clone(): Matrix;
  62921. /**
  62922. * Returns the name of the current matrix class
  62923. * @returns the string "Matrix"
  62924. */
  62925. getClassName(): string;
  62926. /**
  62927. * Gets the hash code of the current matrix
  62928. * @returns the hash code
  62929. */
  62930. getHashCode(): number;
  62931. /**
  62932. * Decomposes the current Matrix into a translation, rotation and scaling components
  62933. * @param scale defines the scale vector3 given as a reference to update
  62934. * @param rotation defines the rotation quaternion given as a reference to update
  62935. * @param translation defines the translation vector3 given as a reference to update
  62936. * @returns true if operation was successful
  62937. */
  62938. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62939. /**
  62940. * Gets specific row of the matrix
  62941. * @param index defines the number of the row to get
  62942. * @returns the index-th row of the current matrix as a new Vector4
  62943. */
  62944. getRow(index: number): Nullable<Vector4>;
  62945. /**
  62946. * Sets the index-th row of the current matrix to the vector4 values
  62947. * @param index defines the number of the row to set
  62948. * @param row defines the target vector4
  62949. * @returns the updated current matrix
  62950. */
  62951. setRow(index: number, row: Vector4): Matrix;
  62952. /**
  62953. * Compute the transpose of the matrix
  62954. * @returns the new transposed matrix
  62955. */
  62956. transpose(): Matrix;
  62957. /**
  62958. * Compute the transpose of the matrix and store it in a given matrix
  62959. * @param result defines the target matrix
  62960. * @returns the current matrix
  62961. */
  62962. transposeToRef(result: Matrix): Matrix;
  62963. /**
  62964. * Sets the index-th row of the current matrix with the given 4 x float values
  62965. * @param index defines the row index
  62966. * @param x defines the x component to set
  62967. * @param y defines the y component to set
  62968. * @param z defines the z component to set
  62969. * @param w defines the w component to set
  62970. * @returns the updated current matrix
  62971. */
  62972. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62973. /**
  62974. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62975. * @param scale defines the scale factor
  62976. * @returns a new matrix
  62977. */
  62978. scale(scale: number): Matrix;
  62979. /**
  62980. * Scale the current matrix values by a factor to a given result matrix
  62981. * @param scale defines the scale factor
  62982. * @param result defines the matrix to store the result
  62983. * @returns the current matrix
  62984. */
  62985. scaleToRef(scale: number, result: Matrix): Matrix;
  62986. /**
  62987. * Scale the current matrix values by a factor and add the result to a given matrix
  62988. * @param scale defines the scale factor
  62989. * @param result defines the Matrix to store the result
  62990. * @returns the current matrix
  62991. */
  62992. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62993. /**
  62994. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62995. * @param ref matrix to store the result
  62996. */
  62997. toNormalMatrix(ref: Matrix): void;
  62998. /**
  62999. * Gets only rotation part of the current matrix
  63000. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63001. */
  63002. getRotationMatrix(): Matrix;
  63003. /**
  63004. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63005. * @param result defines the target matrix to store data to
  63006. * @returns the current matrix
  63007. */
  63008. getRotationMatrixToRef(result: Matrix): Matrix;
  63009. /**
  63010. * Toggles model matrix from being right handed to left handed in place and vice versa
  63011. */
  63012. toggleModelMatrixHandInPlace(): void;
  63013. /**
  63014. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63015. */
  63016. toggleProjectionMatrixHandInPlace(): void;
  63017. /**
  63018. * Creates a matrix from an array
  63019. * @param array defines the source array
  63020. * @param offset defines an offset in the source array
  63021. * @returns a new Matrix set from the starting index of the given array
  63022. */
  63023. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63024. /**
  63025. * Copy the content of an array into a given matrix
  63026. * @param array defines the source array
  63027. * @param offset defines an offset in the source array
  63028. * @param result defines the target matrix
  63029. */
  63030. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63031. /**
  63032. * Stores an array into a matrix after having multiplied each component by a given factor
  63033. * @param array defines the source array
  63034. * @param offset defines the offset in the source array
  63035. * @param scale defines the scaling factor
  63036. * @param result defines the target matrix
  63037. */
  63038. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63039. /**
  63040. * Gets an identity matrix that must not be updated
  63041. */
  63042. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63043. /**
  63044. * Stores a list of values (16) inside a given matrix
  63045. * @param initialM11 defines 1st value of 1st row
  63046. * @param initialM12 defines 2nd value of 1st row
  63047. * @param initialM13 defines 3rd value of 1st row
  63048. * @param initialM14 defines 4th value of 1st row
  63049. * @param initialM21 defines 1st value of 2nd row
  63050. * @param initialM22 defines 2nd value of 2nd row
  63051. * @param initialM23 defines 3rd value of 2nd row
  63052. * @param initialM24 defines 4th value of 2nd row
  63053. * @param initialM31 defines 1st value of 3rd row
  63054. * @param initialM32 defines 2nd value of 3rd row
  63055. * @param initialM33 defines 3rd value of 3rd row
  63056. * @param initialM34 defines 4th value of 3rd row
  63057. * @param initialM41 defines 1st value of 4th row
  63058. * @param initialM42 defines 2nd value of 4th row
  63059. * @param initialM43 defines 3rd value of 4th row
  63060. * @param initialM44 defines 4th value of 4th row
  63061. * @param result defines the target matrix
  63062. */
  63063. 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;
  63064. /**
  63065. * Creates new matrix from a list of values (16)
  63066. * @param initialM11 defines 1st value of 1st row
  63067. * @param initialM12 defines 2nd value of 1st row
  63068. * @param initialM13 defines 3rd value of 1st row
  63069. * @param initialM14 defines 4th value of 1st row
  63070. * @param initialM21 defines 1st value of 2nd row
  63071. * @param initialM22 defines 2nd value of 2nd row
  63072. * @param initialM23 defines 3rd value of 2nd row
  63073. * @param initialM24 defines 4th value of 2nd row
  63074. * @param initialM31 defines 1st value of 3rd row
  63075. * @param initialM32 defines 2nd value of 3rd row
  63076. * @param initialM33 defines 3rd value of 3rd row
  63077. * @param initialM34 defines 4th value of 3rd row
  63078. * @param initialM41 defines 1st value of 4th row
  63079. * @param initialM42 defines 2nd value of 4th row
  63080. * @param initialM43 defines 3rd value of 4th row
  63081. * @param initialM44 defines 4th value of 4th row
  63082. * @returns the new matrix
  63083. */
  63084. 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;
  63085. /**
  63086. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63087. * @param scale defines the scale vector3
  63088. * @param rotation defines the rotation quaternion
  63089. * @param translation defines the translation vector3
  63090. * @returns a new matrix
  63091. */
  63092. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63093. /**
  63094. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63095. * @param scale defines the scale vector3
  63096. * @param rotation defines the rotation quaternion
  63097. * @param translation defines the translation vector3
  63098. * @param result defines the target matrix
  63099. */
  63100. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63101. /**
  63102. * Creates a new identity matrix
  63103. * @returns a new identity matrix
  63104. */
  63105. static Identity(): Matrix;
  63106. /**
  63107. * Creates a new identity matrix and stores the result in a given matrix
  63108. * @param result defines the target matrix
  63109. */
  63110. static IdentityToRef(result: Matrix): void;
  63111. /**
  63112. * Creates a new zero matrix
  63113. * @returns a new zero matrix
  63114. */
  63115. static Zero(): Matrix;
  63116. /**
  63117. * Creates a new rotation matrix for "angle" radians around the X axis
  63118. * @param angle defines the angle (in radians) to use
  63119. * @return the new matrix
  63120. */
  63121. static RotationX(angle: number): Matrix;
  63122. /**
  63123. * Creates a new matrix as the invert of a given matrix
  63124. * @param source defines the source matrix
  63125. * @returns the new matrix
  63126. */
  63127. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63128. /**
  63129. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63130. * @param angle defines the angle (in radians) to use
  63131. * @param result defines the target matrix
  63132. */
  63133. static RotationXToRef(angle: number, result: Matrix): void;
  63134. /**
  63135. * Creates a new rotation matrix for "angle" radians around the Y axis
  63136. * @param angle defines the angle (in radians) to use
  63137. * @return the new matrix
  63138. */
  63139. static RotationY(angle: number): Matrix;
  63140. /**
  63141. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63142. * @param angle defines the angle (in radians) to use
  63143. * @param result defines the target matrix
  63144. */
  63145. static RotationYToRef(angle: number, result: Matrix): void;
  63146. /**
  63147. * Creates a new rotation matrix for "angle" radians around the Z axis
  63148. * @param angle defines the angle (in radians) to use
  63149. * @return the new matrix
  63150. */
  63151. static RotationZ(angle: number): Matrix;
  63152. /**
  63153. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63154. * @param angle defines the angle (in radians) to use
  63155. * @param result defines the target matrix
  63156. */
  63157. static RotationZToRef(angle: number, result: Matrix): void;
  63158. /**
  63159. * Creates a new rotation matrix for "angle" radians around the given axis
  63160. * @param axis defines the axis to use
  63161. * @param angle defines the angle (in radians) to use
  63162. * @return the new matrix
  63163. */
  63164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63165. /**
  63166. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63167. * @param axis defines the axis to use
  63168. * @param angle defines the angle (in radians) to use
  63169. * @param result defines the target matrix
  63170. */
  63171. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63172. /**
  63173. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63174. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63175. * @param from defines the vector to align
  63176. * @param to defines the vector to align to
  63177. * @param result defines the target matrix
  63178. */
  63179. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63180. /**
  63181. * Creates a rotation matrix
  63182. * @param yaw defines the yaw angle in radians (Y axis)
  63183. * @param pitch defines the pitch angle in radians (X axis)
  63184. * @param roll defines the roll angle in radians (X axis)
  63185. * @returns the new rotation matrix
  63186. */
  63187. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63188. /**
  63189. * Creates a rotation matrix and stores it in a given matrix
  63190. * @param yaw defines the yaw angle in radians (Y axis)
  63191. * @param pitch defines the pitch angle in radians (X axis)
  63192. * @param roll defines the roll angle in radians (X axis)
  63193. * @param result defines the target matrix
  63194. */
  63195. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63196. /**
  63197. * Creates a scaling matrix
  63198. * @param x defines the scale factor on X axis
  63199. * @param y defines the scale factor on Y axis
  63200. * @param z defines the scale factor on Z axis
  63201. * @returns the new matrix
  63202. */
  63203. static Scaling(x: number, y: number, z: number): Matrix;
  63204. /**
  63205. * Creates a scaling matrix and stores it in a given matrix
  63206. * @param x defines the scale factor on X axis
  63207. * @param y defines the scale factor on Y axis
  63208. * @param z defines the scale factor on Z axis
  63209. * @param result defines the target matrix
  63210. */
  63211. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63212. /**
  63213. * Creates a translation matrix
  63214. * @param x defines the translation on X axis
  63215. * @param y defines the translation on Y axis
  63216. * @param z defines the translationon Z axis
  63217. * @returns the new matrix
  63218. */
  63219. static Translation(x: number, y: number, z: number): Matrix;
  63220. /**
  63221. * Creates a translation matrix and stores it in a given matrix
  63222. * @param x defines the translation on X axis
  63223. * @param y defines the translation on Y axis
  63224. * @param z defines the translationon Z axis
  63225. * @param result defines the target matrix
  63226. */
  63227. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63228. /**
  63229. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63230. * @param startValue defines the start value
  63231. * @param endValue defines the end value
  63232. * @param gradient defines the gradient factor
  63233. * @returns the new matrix
  63234. */
  63235. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63236. /**
  63237. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63238. * @param startValue defines the start value
  63239. * @param endValue defines the end value
  63240. * @param gradient defines the gradient factor
  63241. * @param result defines the Matrix object where to store data
  63242. */
  63243. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63244. /**
  63245. * Builds a new matrix whose values are computed by:
  63246. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63247. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63248. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63249. * @param startValue defines the first matrix
  63250. * @param endValue defines the second matrix
  63251. * @param gradient defines the gradient between the two matrices
  63252. * @returns the new matrix
  63253. */
  63254. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63255. /**
  63256. * Update a matrix to values which are computed by:
  63257. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63258. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63259. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63260. * @param startValue defines the first matrix
  63261. * @param endValue defines the second matrix
  63262. * @param gradient defines the gradient between the two matrices
  63263. * @param result defines the target matrix
  63264. */
  63265. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63266. /**
  63267. * 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"
  63268. * This function works in left handed mode
  63269. * @param eye defines the final position of the entity
  63270. * @param target defines where the entity should look at
  63271. * @param up defines the up vector for the entity
  63272. * @returns the new matrix
  63273. */
  63274. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63275. /**
  63276. * 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".
  63277. * This function works in left handed mode
  63278. * @param eye defines the final position of the entity
  63279. * @param target defines where the entity should look at
  63280. * @param up defines the up vector for the entity
  63281. * @param result defines the target matrix
  63282. */
  63283. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63284. /**
  63285. * 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"
  63286. * This function works in right handed mode
  63287. * @param eye defines the final position of the entity
  63288. * @param target defines where the entity should look at
  63289. * @param up defines the up vector for the entity
  63290. * @returns the new matrix
  63291. */
  63292. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63293. /**
  63294. * 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".
  63295. * This function works in right handed mode
  63296. * @param eye defines the final position of the entity
  63297. * @param target defines where the entity should look at
  63298. * @param up defines the up vector for the entity
  63299. * @param result defines the target matrix
  63300. */
  63301. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63302. /**
  63303. * Create a left-handed orthographic projection matrix
  63304. * @param width defines the viewport width
  63305. * @param height defines the viewport height
  63306. * @param znear defines the near clip plane
  63307. * @param zfar defines the far clip plane
  63308. * @returns a new matrix as a left-handed orthographic projection matrix
  63309. */
  63310. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63311. /**
  63312. * Store a left-handed orthographic projection to a given matrix
  63313. * @param width defines the viewport width
  63314. * @param height defines the viewport height
  63315. * @param znear defines the near clip plane
  63316. * @param zfar defines the far clip plane
  63317. * @param result defines the target matrix
  63318. */
  63319. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63320. /**
  63321. * Create a left-handed orthographic projection matrix
  63322. * @param left defines the viewport left coordinate
  63323. * @param right defines the viewport right coordinate
  63324. * @param bottom defines the viewport bottom coordinate
  63325. * @param top defines the viewport top coordinate
  63326. * @param znear defines the near clip plane
  63327. * @param zfar defines the far clip plane
  63328. * @returns a new matrix as a left-handed orthographic projection matrix
  63329. */
  63330. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63331. /**
  63332. * Stores a left-handed orthographic projection into a given matrix
  63333. * @param left defines the viewport left coordinate
  63334. * @param right defines the viewport right coordinate
  63335. * @param bottom defines the viewport bottom coordinate
  63336. * @param top defines the viewport top coordinate
  63337. * @param znear defines the near clip plane
  63338. * @param zfar defines the far clip plane
  63339. * @param result defines the target matrix
  63340. */
  63341. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63342. /**
  63343. * Creates a right-handed orthographic projection matrix
  63344. * @param left defines the viewport left coordinate
  63345. * @param right defines the viewport right coordinate
  63346. * @param bottom defines the viewport bottom coordinate
  63347. * @param top defines the viewport top coordinate
  63348. * @param znear defines the near clip plane
  63349. * @param zfar defines the far clip plane
  63350. * @returns a new matrix as a right-handed orthographic projection matrix
  63351. */
  63352. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63353. /**
  63354. * Stores a right-handed orthographic projection into a given matrix
  63355. * @param left defines the viewport left coordinate
  63356. * @param right defines the viewport right coordinate
  63357. * @param bottom defines the viewport bottom coordinate
  63358. * @param top defines the viewport top coordinate
  63359. * @param znear defines the near clip plane
  63360. * @param zfar defines the far clip plane
  63361. * @param result defines the target matrix
  63362. */
  63363. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63364. /**
  63365. * Creates a left-handed perspective projection matrix
  63366. * @param width defines the viewport width
  63367. * @param height defines the viewport height
  63368. * @param znear defines the near clip plane
  63369. * @param zfar defines the far clip plane
  63370. * @returns a new matrix as a left-handed perspective projection matrix
  63371. */
  63372. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63373. /**
  63374. * Creates a left-handed perspective projection matrix
  63375. * @param fov defines the horizontal field of view
  63376. * @param aspect defines the aspect ratio
  63377. * @param znear defines the near clip plane
  63378. * @param zfar defines the far clip plane
  63379. * @returns a new matrix as a left-handed perspective projection matrix
  63380. */
  63381. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63382. /**
  63383. * Stores a left-handed perspective projection into a given matrix
  63384. * @param fov defines the horizontal field of view
  63385. * @param aspect defines the aspect ratio
  63386. * @param znear defines the near clip plane
  63387. * @param zfar defines the far clip plane
  63388. * @param result defines the target matrix
  63389. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63390. */
  63391. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63392. /**
  63393. * Creates a right-handed perspective projection matrix
  63394. * @param fov defines the horizontal field of view
  63395. * @param aspect defines the aspect ratio
  63396. * @param znear defines the near clip plane
  63397. * @param zfar defines the far clip plane
  63398. * @returns a new matrix as a right-handed perspective projection matrix
  63399. */
  63400. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63401. /**
  63402. * Stores a right-handed perspective projection into a given matrix
  63403. * @param fov defines the horizontal field of view
  63404. * @param aspect defines the aspect ratio
  63405. * @param znear defines the near clip plane
  63406. * @param zfar defines the far clip plane
  63407. * @param result defines the target matrix
  63408. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63409. */
  63410. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63411. /**
  63412. * Stores a perspective projection for WebVR info a given matrix
  63413. * @param fov defines the field of view
  63414. * @param znear defines the near clip plane
  63415. * @param zfar defines the far clip plane
  63416. * @param result defines the target matrix
  63417. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63418. */
  63419. static PerspectiveFovWebVRToRef(fov: {
  63420. upDegrees: number;
  63421. downDegrees: number;
  63422. leftDegrees: number;
  63423. rightDegrees: number;
  63424. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63425. /**
  63426. * Computes a complete transformation matrix
  63427. * @param viewport defines the viewport to use
  63428. * @param world defines the world matrix
  63429. * @param view defines the view matrix
  63430. * @param projection defines the projection matrix
  63431. * @param zmin defines the near clip plane
  63432. * @param zmax defines the far clip plane
  63433. * @returns the transformation matrix
  63434. */
  63435. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63436. /**
  63437. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63438. * @param matrix defines the matrix to use
  63439. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63440. */
  63441. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63442. /**
  63443. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63444. * @param matrix defines the matrix to use
  63445. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63446. */
  63447. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63448. /**
  63449. * Compute the transpose of a given matrix
  63450. * @param matrix defines the matrix to transpose
  63451. * @returns the new matrix
  63452. */
  63453. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63454. /**
  63455. * Compute the transpose of a matrix and store it in a target matrix
  63456. * @param matrix defines the matrix to transpose
  63457. * @param result defines the target matrix
  63458. */
  63459. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63460. /**
  63461. * Computes a reflection matrix from a plane
  63462. * @param plane defines the reflection plane
  63463. * @returns a new matrix
  63464. */
  63465. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63466. /**
  63467. * Computes a reflection matrix from a plane
  63468. * @param plane defines the reflection plane
  63469. * @param result defines the target matrix
  63470. */
  63471. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63472. /**
  63473. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63474. * @param xaxis defines the value of the 1st axis
  63475. * @param yaxis defines the value of the 2nd axis
  63476. * @param zaxis defines the value of the 3rd axis
  63477. * @param result defines the target matrix
  63478. */
  63479. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63480. /**
  63481. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63482. * @param quat defines the quaternion to use
  63483. * @param result defines the target matrix
  63484. */
  63485. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63486. }
  63487. /**
  63488. * Represens a plane by the equation ax + by + cz + d = 0
  63489. */
  63490. export class Plane {
  63491. /**
  63492. * Normal of the plane (a,b,c)
  63493. */
  63494. normal: Vector3;
  63495. /**
  63496. * d component of the plane
  63497. */
  63498. d: number;
  63499. /**
  63500. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63501. * @param a a component of the plane
  63502. * @param b b component of the plane
  63503. * @param c c component of the plane
  63504. * @param d d component of the plane
  63505. */
  63506. constructor(a: number, b: number, c: number, d: number);
  63507. /**
  63508. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63509. */
  63510. asArray(): number[];
  63511. /**
  63512. * @returns a new plane copied from the current Plane.
  63513. */
  63514. clone(): Plane;
  63515. /**
  63516. * @returns the string "Plane".
  63517. */
  63518. getClassName(): string;
  63519. /**
  63520. * @returns the Plane hash code.
  63521. */
  63522. getHashCode(): number;
  63523. /**
  63524. * Normalize the current Plane in place.
  63525. * @returns the updated Plane.
  63526. */
  63527. normalize(): Plane;
  63528. /**
  63529. * Applies a transformation the plane and returns the result
  63530. * @param transformation the transformation matrix to be applied to the plane
  63531. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63532. */
  63533. transform(transformation: DeepImmutable<Matrix>): Plane;
  63534. /**
  63535. * Calcualtte the dot product between the point and the plane normal
  63536. * @param point point to calculate the dot product with
  63537. * @returns the dot product (float) of the point coordinates and the plane normal.
  63538. */
  63539. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63540. /**
  63541. * Updates the current Plane from the plane defined by the three given points.
  63542. * @param point1 one of the points used to contruct the plane
  63543. * @param point2 one of the points used to contruct the plane
  63544. * @param point3 one of the points used to contruct the plane
  63545. * @returns the updated Plane.
  63546. */
  63547. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63548. /**
  63549. * Checks if the plane is facing a given direction
  63550. * @param direction the direction to check if the plane is facing
  63551. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63552. * @returns True is the vector "direction" is the same side than the plane normal.
  63553. */
  63554. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63555. /**
  63556. * Calculates the distance to a point
  63557. * @param point point to calculate distance to
  63558. * @returns the signed distance (float) from the given point to the Plane.
  63559. */
  63560. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63561. /**
  63562. * Creates a plane from an array
  63563. * @param array the array to create a plane from
  63564. * @returns a new Plane from the given array.
  63565. */
  63566. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63567. /**
  63568. * Creates a plane from three points
  63569. * @param point1 point used to create the plane
  63570. * @param point2 point used to create the plane
  63571. * @param point3 point used to create the plane
  63572. * @returns a new Plane defined by the three given points.
  63573. */
  63574. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63575. /**
  63576. * Creates a plane from an origin point and a normal
  63577. * @param origin origin of the plane to be constructed
  63578. * @param normal normal of the plane to be constructed
  63579. * @returns a new Plane the normal vector to this plane at the given origin point.
  63580. * Note : the vector "normal" is updated because normalized.
  63581. */
  63582. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63583. /**
  63584. * Calculates the distance from a plane and a point
  63585. * @param origin origin of the plane to be constructed
  63586. * @param normal normal of the plane to be constructed
  63587. * @param point point to calculate distance to
  63588. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63589. */
  63590. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63591. }
  63592. /**
  63593. * Class used to represent a viewport on screen
  63594. */
  63595. export class Viewport {
  63596. /** viewport left coordinate */
  63597. x: number;
  63598. /** viewport top coordinate */
  63599. y: number;
  63600. /**viewport width */
  63601. width: number;
  63602. /** viewport height */
  63603. height: number;
  63604. /**
  63605. * Creates a Viewport object located at (x, y) and sized (width, height)
  63606. * @param x defines viewport left coordinate
  63607. * @param y defines viewport top coordinate
  63608. * @param width defines the viewport width
  63609. * @param height defines the viewport height
  63610. */
  63611. constructor(
  63612. /** viewport left coordinate */
  63613. x: number,
  63614. /** viewport top coordinate */
  63615. y: number,
  63616. /**viewport width */
  63617. width: number,
  63618. /** viewport height */
  63619. height: number);
  63620. /**
  63621. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63622. * @param renderWidth defines the rendering width
  63623. * @param renderHeight defines the rendering height
  63624. * @returns a new Viewport
  63625. */
  63626. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63627. /**
  63628. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63629. * @param renderWidth defines the rendering width
  63630. * @param renderHeight defines the rendering height
  63631. * @param ref defines the target viewport
  63632. * @returns the current viewport
  63633. */
  63634. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63635. /**
  63636. * Returns a new Viewport copied from the current one
  63637. * @returns a new Viewport
  63638. */
  63639. clone(): Viewport;
  63640. }
  63641. /**
  63642. * Reprasents a camera frustum
  63643. */
  63644. export class Frustum {
  63645. /**
  63646. * Gets the planes representing the frustum
  63647. * @param transform matrix to be applied to the returned planes
  63648. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63649. */
  63650. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63651. /**
  63652. * Gets the near frustum plane transformed by the transform matrix
  63653. * @param transform transformation matrix to be applied to the resulting frustum plane
  63654. * @param frustumPlane the resuling frustum plane
  63655. */
  63656. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63657. /**
  63658. * Gets the far frustum plane transformed by the transform matrix
  63659. * @param transform transformation matrix to be applied to the resulting frustum plane
  63660. * @param frustumPlane the resuling frustum plane
  63661. */
  63662. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63663. /**
  63664. * Gets the left frustum plane transformed by the transform matrix
  63665. * @param transform transformation matrix to be applied to the resulting frustum plane
  63666. * @param frustumPlane the resuling frustum plane
  63667. */
  63668. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63669. /**
  63670. * Gets the right frustum plane transformed by the transform matrix
  63671. * @param transform transformation matrix to be applied to the resulting frustum plane
  63672. * @param frustumPlane the resuling frustum plane
  63673. */
  63674. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63675. /**
  63676. * Gets the top frustum plane transformed by the transform matrix
  63677. * @param transform transformation matrix to be applied to the resulting frustum plane
  63678. * @param frustumPlane the resuling frustum plane
  63679. */
  63680. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63681. /**
  63682. * Gets the bottom frustum plane transformed by the transform matrix
  63683. * @param transform transformation matrix to be applied to the resulting frustum plane
  63684. * @param frustumPlane the resuling frustum plane
  63685. */
  63686. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63687. /**
  63688. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63689. * @param transform transformation matrix to be applied to the resulting frustum planes
  63690. * @param frustumPlanes the resuling frustum planes
  63691. */
  63692. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63693. }
  63694. /** Defines supported spaces */
  63695. export enum Space {
  63696. /** Local (object) space */
  63697. LOCAL = 0,
  63698. /** World space */
  63699. WORLD = 1,
  63700. /** Bone space */
  63701. BONE = 2
  63702. }
  63703. /** Defines the 3 main axes */
  63704. export class Axis {
  63705. /** X axis */
  63706. static X: Vector3;
  63707. /** Y axis */
  63708. static Y: Vector3;
  63709. /** Z axis */
  63710. static Z: Vector3;
  63711. }
  63712. /** Class used to represent a Bezier curve */
  63713. export class BezierCurve {
  63714. /**
  63715. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63716. * @param t defines the time
  63717. * @param x1 defines the left coordinate on X axis
  63718. * @param y1 defines the left coordinate on Y axis
  63719. * @param x2 defines the right coordinate on X axis
  63720. * @param y2 defines the right coordinate on Y axis
  63721. * @returns the interpolated value
  63722. */
  63723. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63724. }
  63725. /**
  63726. * Defines potential orientation for back face culling
  63727. */
  63728. export enum Orientation {
  63729. /**
  63730. * Clockwise
  63731. */
  63732. CW = 0,
  63733. /** Counter clockwise */
  63734. CCW = 1
  63735. }
  63736. /**
  63737. * Defines angle representation
  63738. */
  63739. export class Angle {
  63740. private _radians;
  63741. /**
  63742. * Creates an Angle object of "radians" radians (float).
  63743. * @param radians the angle in radians
  63744. */
  63745. constructor(radians: number);
  63746. /**
  63747. * Get value in degrees
  63748. * @returns the Angle value in degrees (float)
  63749. */
  63750. degrees(): number;
  63751. /**
  63752. * Get value in radians
  63753. * @returns the Angle value in radians (float)
  63754. */
  63755. radians(): number;
  63756. /**
  63757. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63758. * @param a defines first vector
  63759. * @param b defines second vector
  63760. * @returns a new Angle
  63761. */
  63762. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63763. /**
  63764. * Gets a new Angle object from the given float in radians
  63765. * @param radians defines the angle value in radians
  63766. * @returns a new Angle
  63767. */
  63768. static FromRadians(radians: number): Angle;
  63769. /**
  63770. * Gets a new Angle object from the given float in degrees
  63771. * @param degrees defines the angle value in degrees
  63772. * @returns a new Angle
  63773. */
  63774. static FromDegrees(degrees: number): Angle;
  63775. }
  63776. /**
  63777. * This represents an arc in a 2d space.
  63778. */
  63779. export class Arc2 {
  63780. /** Defines the start point of the arc */
  63781. startPoint: Vector2;
  63782. /** Defines the mid point of the arc */
  63783. midPoint: Vector2;
  63784. /** Defines the end point of the arc */
  63785. endPoint: Vector2;
  63786. /**
  63787. * Defines the center point of the arc.
  63788. */
  63789. centerPoint: Vector2;
  63790. /**
  63791. * Defines the radius of the arc.
  63792. */
  63793. radius: number;
  63794. /**
  63795. * Defines the angle of the arc (from mid point to end point).
  63796. */
  63797. angle: Angle;
  63798. /**
  63799. * Defines the start angle of the arc (from start point to middle point).
  63800. */
  63801. startAngle: Angle;
  63802. /**
  63803. * Defines the orientation of the arc (clock wise/counter clock wise).
  63804. */
  63805. orientation: Orientation;
  63806. /**
  63807. * Creates an Arc object from the three given points : start, middle and end.
  63808. * @param startPoint Defines the start point of the arc
  63809. * @param midPoint Defines the midlle point of the arc
  63810. * @param endPoint Defines the end point of the arc
  63811. */
  63812. constructor(
  63813. /** Defines the start point of the arc */
  63814. startPoint: Vector2,
  63815. /** Defines the mid point of the arc */
  63816. midPoint: Vector2,
  63817. /** Defines the end point of the arc */
  63818. endPoint: Vector2);
  63819. }
  63820. /**
  63821. * Represents a 2D path made up of multiple 2D points
  63822. */
  63823. export class Path2 {
  63824. private _points;
  63825. private _length;
  63826. /**
  63827. * If the path start and end point are the same
  63828. */
  63829. closed: boolean;
  63830. /**
  63831. * Creates a Path2 object from the starting 2D coordinates x and y.
  63832. * @param x the starting points x value
  63833. * @param y the starting points y value
  63834. */
  63835. constructor(x: number, y: number);
  63836. /**
  63837. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63838. * @param x the added points x value
  63839. * @param y the added points y value
  63840. * @returns the updated Path2.
  63841. */
  63842. addLineTo(x: number, y: number): Path2;
  63843. /**
  63844. * 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.
  63845. * @param midX middle point x value
  63846. * @param midY middle point y value
  63847. * @param endX end point x value
  63848. * @param endY end point y value
  63849. * @param numberOfSegments (default: 36)
  63850. * @returns the updated Path2.
  63851. */
  63852. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63853. /**
  63854. * Closes the Path2.
  63855. * @returns the Path2.
  63856. */
  63857. close(): Path2;
  63858. /**
  63859. * Gets the sum of the distance between each sequential point in the path
  63860. * @returns the Path2 total length (float).
  63861. */
  63862. length(): number;
  63863. /**
  63864. * Gets the points which construct the path
  63865. * @returns the Path2 internal array of points.
  63866. */
  63867. getPoints(): Vector2[];
  63868. /**
  63869. * Retreives the point at the distance aways from the starting point
  63870. * @param normalizedLengthPosition the length along the path to retreive the point from
  63871. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63872. */
  63873. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63874. /**
  63875. * Creates a new path starting from an x and y position
  63876. * @param x starting x value
  63877. * @param y starting y value
  63878. * @returns a new Path2 starting at the coordinates (x, y).
  63879. */
  63880. static StartingAt(x: number, y: number): Path2;
  63881. }
  63882. /**
  63883. * Represents a 3D path made up of multiple 3D points
  63884. */
  63885. export class Path3D {
  63886. /**
  63887. * an array of Vector3, the curve axis of the Path3D
  63888. */
  63889. path: Vector3[];
  63890. private _curve;
  63891. private _distances;
  63892. private _tangents;
  63893. private _normals;
  63894. private _binormals;
  63895. private _raw;
  63896. /**
  63897. * new Path3D(path, normal, raw)
  63898. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63899. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63900. * @param path an array of Vector3, the curve axis of the Path3D
  63901. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63902. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63903. */
  63904. constructor(
  63905. /**
  63906. * an array of Vector3, the curve axis of the Path3D
  63907. */
  63908. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63909. /**
  63910. * Returns the Path3D array of successive Vector3 designing its curve.
  63911. * @returns the Path3D array of successive Vector3 designing its curve.
  63912. */
  63913. getCurve(): Vector3[];
  63914. /**
  63915. * Returns an array populated with tangent vectors on each Path3D curve point.
  63916. * @returns an array populated with tangent vectors on each Path3D curve point.
  63917. */
  63918. getTangents(): Vector3[];
  63919. /**
  63920. * Returns an array populated with normal vectors on each Path3D curve point.
  63921. * @returns an array populated with normal vectors on each Path3D curve point.
  63922. */
  63923. getNormals(): Vector3[];
  63924. /**
  63925. * Returns an array populated with binormal vectors on each Path3D curve point.
  63926. * @returns an array populated with binormal vectors on each Path3D curve point.
  63927. */
  63928. getBinormals(): Vector3[];
  63929. /**
  63930. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63931. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63932. */
  63933. getDistances(): number[];
  63934. /**
  63935. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63936. * @param path path which all values are copied into the curves points
  63937. * @param firstNormal which should be projected onto the curve
  63938. * @returns the same object updated.
  63939. */
  63940. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63941. private _compute;
  63942. private _getFirstNonNullVector;
  63943. private _getLastNonNullVector;
  63944. private _normalVector;
  63945. }
  63946. /**
  63947. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63948. * A Curve3 is designed from a series of successive Vector3.
  63949. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63950. */
  63951. export class Curve3 {
  63952. private _points;
  63953. private _length;
  63954. /**
  63955. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63956. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63957. * @param v1 (Vector3) the control point
  63958. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63959. * @param nbPoints (integer) the wanted number of points in the curve
  63960. * @returns the created Curve3
  63961. */
  63962. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63963. /**
  63964. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63965. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63966. * @param v1 (Vector3) the first control point
  63967. * @param v2 (Vector3) the second control point
  63968. * @param v3 (Vector3) the end point of the Cubic Bezier
  63969. * @param nbPoints (integer) the wanted number of points in the curve
  63970. * @returns the created Curve3
  63971. */
  63972. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63973. /**
  63974. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63975. * @param p1 (Vector3) the origin point of the Hermite Spline
  63976. * @param t1 (Vector3) the tangent vector at the origin point
  63977. * @param p2 (Vector3) the end point of the Hermite Spline
  63978. * @param t2 (Vector3) the tangent vector at the end point
  63979. * @param nbPoints (integer) the wanted number of points in the curve
  63980. * @returns the created Curve3
  63981. */
  63982. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63983. /**
  63984. * Returns a Curve3 object along a CatmullRom Spline curve :
  63985. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63986. * @param nbPoints (integer) the wanted number of points between each curve control points
  63987. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63988. * @returns the created Curve3
  63989. */
  63990. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63991. /**
  63992. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63993. * A Curve3 is designed from a series of successive Vector3.
  63994. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63995. * @param points points which make up the curve
  63996. */
  63997. constructor(points: Vector3[]);
  63998. /**
  63999. * @returns the Curve3 stored array of successive Vector3
  64000. */
  64001. getPoints(): Vector3[];
  64002. /**
  64003. * @returns the computed length (float) of the curve.
  64004. */
  64005. length(): number;
  64006. /**
  64007. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64008. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64009. * curveA and curveB keep unchanged.
  64010. * @param curve the curve to continue from this curve
  64011. * @returns the newly constructed curve
  64012. */
  64013. continue(curve: DeepImmutable<Curve3>): Curve3;
  64014. private _computeLength;
  64015. }
  64016. /**
  64017. * Contains position and normal vectors for a vertex
  64018. */
  64019. export class PositionNormalVertex {
  64020. /** the position of the vertex (defaut: 0,0,0) */
  64021. position: Vector3;
  64022. /** the normal of the vertex (defaut: 0,1,0) */
  64023. normal: Vector3;
  64024. /**
  64025. * Creates a PositionNormalVertex
  64026. * @param position the position of the vertex (defaut: 0,0,0)
  64027. * @param normal the normal of the vertex (defaut: 0,1,0)
  64028. */
  64029. constructor(
  64030. /** the position of the vertex (defaut: 0,0,0) */
  64031. position?: Vector3,
  64032. /** the normal of the vertex (defaut: 0,1,0) */
  64033. normal?: Vector3);
  64034. /**
  64035. * Clones the PositionNormalVertex
  64036. * @returns the cloned PositionNormalVertex
  64037. */
  64038. clone(): PositionNormalVertex;
  64039. }
  64040. /**
  64041. * Contains position, normal and uv vectors for a vertex
  64042. */
  64043. export class PositionNormalTextureVertex {
  64044. /** the position of the vertex (defaut: 0,0,0) */
  64045. position: Vector3;
  64046. /** the normal of the vertex (defaut: 0,1,0) */
  64047. normal: Vector3;
  64048. /** the uv of the vertex (default: 0,0) */
  64049. uv: Vector2;
  64050. /**
  64051. * Creates a PositionNormalTextureVertex
  64052. * @param position the position of the vertex (defaut: 0,0,0)
  64053. * @param normal the normal of the vertex (defaut: 0,1,0)
  64054. * @param uv the uv of the vertex (default: 0,0)
  64055. */
  64056. constructor(
  64057. /** the position of the vertex (defaut: 0,0,0) */
  64058. position?: Vector3,
  64059. /** the normal of the vertex (defaut: 0,1,0) */
  64060. normal?: Vector3,
  64061. /** the uv of the vertex (default: 0,0) */
  64062. uv?: Vector2);
  64063. /**
  64064. * Clones the PositionNormalTextureVertex
  64065. * @returns the cloned PositionNormalTextureVertex
  64066. */
  64067. clone(): PositionNormalTextureVertex;
  64068. }
  64069. /**
  64070. * @hidden
  64071. */
  64072. export class Tmp {
  64073. static Color3: Color3[];
  64074. static Color4: Color4[];
  64075. static Vector2: Vector2[];
  64076. static Vector3: Vector3[];
  64077. static Vector4: Vector4[];
  64078. static Quaternion: Quaternion[];
  64079. static Matrix: Matrix[];
  64080. }
  64081. }
  64082. declare module BABYLON {
  64083. /**
  64084. * Class used to enable access to offline support
  64085. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64086. */
  64087. export interface IOfflineProvider {
  64088. /**
  64089. * Gets a boolean indicating if scene must be saved in the database
  64090. */
  64091. enableSceneOffline: boolean;
  64092. /**
  64093. * Gets a boolean indicating if textures must be saved in the database
  64094. */
  64095. enableTexturesOffline: boolean;
  64096. /**
  64097. * Open the offline support and make it available
  64098. * @param successCallback defines the callback to call on success
  64099. * @param errorCallback defines the callback to call on error
  64100. */
  64101. open(successCallback: () => void, errorCallback: () => void): void;
  64102. /**
  64103. * Loads an image from the offline support
  64104. * @param url defines the url to load from
  64105. * @param image defines the target DOM image
  64106. */
  64107. loadImage(url: string, image: HTMLImageElement): void;
  64108. /**
  64109. * Loads a file from offline support
  64110. * @param url defines the URL to load from
  64111. * @param sceneLoaded defines a callback to call on success
  64112. * @param progressCallBack defines a callback to call when progress changed
  64113. * @param errorCallback defines a callback to call on error
  64114. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64115. */
  64116. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64117. }
  64118. }
  64119. declare module BABYLON {
  64120. /**
  64121. * A class serves as a medium between the observable and its observers
  64122. */
  64123. export class EventState {
  64124. /**
  64125. * Create a new EventState
  64126. * @param mask defines the mask associated with this state
  64127. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64128. * @param target defines the original target of the state
  64129. * @param currentTarget defines the current target of the state
  64130. */
  64131. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64132. /**
  64133. * Initialize the current event state
  64134. * @param mask defines the mask associated with this state
  64135. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64136. * @param target defines the original target of the state
  64137. * @param currentTarget defines the current target of the state
  64138. * @returns the current event state
  64139. */
  64140. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64141. /**
  64142. * An Observer can set this property to true to prevent subsequent observers of being notified
  64143. */
  64144. skipNextObservers: boolean;
  64145. /**
  64146. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64147. */
  64148. mask: number;
  64149. /**
  64150. * The object that originally notified the event
  64151. */
  64152. target?: any;
  64153. /**
  64154. * The current object in the bubbling phase
  64155. */
  64156. currentTarget?: any;
  64157. /**
  64158. * This will be populated with the return value of the last function that was executed.
  64159. * If it is the first function in the callback chain it will be the event data.
  64160. */
  64161. lastReturnValue?: any;
  64162. }
  64163. /**
  64164. * Represent an Observer registered to a given Observable object.
  64165. */
  64166. export class Observer<T> {
  64167. /**
  64168. * Defines the callback to call when the observer is notified
  64169. */
  64170. callback: (eventData: T, eventState: EventState) => void;
  64171. /**
  64172. * Defines the mask of the observer (used to filter notifications)
  64173. */
  64174. mask: number;
  64175. /**
  64176. * Defines the current scope used to restore the JS context
  64177. */
  64178. scope: any;
  64179. /** @hidden */
  64180. _willBeUnregistered: boolean;
  64181. /**
  64182. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64183. */
  64184. unregisterOnNextCall: boolean;
  64185. /**
  64186. * Creates a new observer
  64187. * @param callback defines the callback to call when the observer is notified
  64188. * @param mask defines the mask of the observer (used to filter notifications)
  64189. * @param scope defines the current scope used to restore the JS context
  64190. */
  64191. constructor(
  64192. /**
  64193. * Defines the callback to call when the observer is notified
  64194. */
  64195. callback: (eventData: T, eventState: EventState) => void,
  64196. /**
  64197. * Defines the mask of the observer (used to filter notifications)
  64198. */
  64199. mask: number,
  64200. /**
  64201. * Defines the current scope used to restore the JS context
  64202. */
  64203. scope?: any);
  64204. }
  64205. /**
  64206. * Represent a list of observers registered to multiple Observables object.
  64207. */
  64208. export class MultiObserver<T> {
  64209. private _observers;
  64210. private _observables;
  64211. /**
  64212. * Release associated resources
  64213. */
  64214. dispose(): void;
  64215. /**
  64216. * Raise a callback when one of the observable will notify
  64217. * @param observables defines a list of observables to watch
  64218. * @param callback defines the callback to call on notification
  64219. * @param mask defines the mask used to filter notifications
  64220. * @param scope defines the current scope used to restore the JS context
  64221. * @returns the new MultiObserver
  64222. */
  64223. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64224. }
  64225. /**
  64226. * The Observable class is a simple implementation of the Observable pattern.
  64227. *
  64228. * 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.
  64229. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64230. * 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).
  64231. * 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.
  64232. */
  64233. export class Observable<T> {
  64234. private _observers;
  64235. private _eventState;
  64236. private _onObserverAdded;
  64237. /**
  64238. * Creates a new observable
  64239. * @param onObserverAdded defines a callback to call when a new observer is added
  64240. */
  64241. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64242. /**
  64243. * Create a new Observer with the specified callback
  64244. * @param callback the callback that will be executed for that Observer
  64245. * @param mask the mask used to filter observers
  64246. * @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.
  64247. * @param scope optional scope for the callback to be called from
  64248. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64249. * @returns the new observer created for the callback
  64250. */
  64251. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64252. /**
  64253. * Create a new Observer with the specified callback and unregisters after the next notification
  64254. * @param callback the callback that will be executed for that Observer
  64255. * @returns the new observer created for the callback
  64256. */
  64257. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64258. /**
  64259. * Remove an Observer from the Observable object
  64260. * @param observer the instance of the Observer to remove
  64261. * @returns false if it doesn't belong to this Observable
  64262. */
  64263. remove(observer: Nullable<Observer<T>>): boolean;
  64264. /**
  64265. * Remove a callback from the Observable object
  64266. * @param callback the callback to remove
  64267. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64268. * @returns false if it doesn't belong to this Observable
  64269. */
  64270. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64271. private _deferUnregister;
  64272. private _remove;
  64273. /**
  64274. * Moves the observable to the top of the observer list making it get called first when notified
  64275. * @param observer the observer to move
  64276. */
  64277. makeObserverTopPriority(observer: Observer<T>): void;
  64278. /**
  64279. * Moves the observable to the bottom of the observer list making it get called last when notified
  64280. * @param observer the observer to move
  64281. */
  64282. makeObserverBottomPriority(observer: Observer<T>): void;
  64283. /**
  64284. * Notify all Observers by calling their respective callback with the given data
  64285. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64286. * @param eventData defines the data to send to all observers
  64287. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64288. * @param target defines the original target of the state
  64289. * @param currentTarget defines the current target of the state
  64290. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64291. */
  64292. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64293. /**
  64294. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64295. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64296. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64297. * and it is crucial that all callbacks will be executed.
  64298. * The order of the callbacks is kept, callbacks are not executed parallel.
  64299. *
  64300. * @param eventData The data to be sent to each callback
  64301. * @param mask is used to filter observers defaults to -1
  64302. * @param target defines the callback target (see EventState)
  64303. * @param currentTarget defines he current object in the bubbling phase
  64304. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64305. */
  64306. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64307. /**
  64308. * Notify a specific observer
  64309. * @param observer defines the observer to notify
  64310. * @param eventData defines the data to be sent to each callback
  64311. * @param mask is used to filter observers defaults to -1
  64312. */
  64313. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64314. /**
  64315. * Gets a boolean indicating if the observable has at least one observer
  64316. * @returns true is the Observable has at least one Observer registered
  64317. */
  64318. hasObservers(): boolean;
  64319. /**
  64320. * Clear the list of observers
  64321. */
  64322. clear(): void;
  64323. /**
  64324. * Clone the current observable
  64325. * @returns a new observable
  64326. */
  64327. clone(): Observable<T>;
  64328. /**
  64329. * Does this observable handles observer registered with a given mask
  64330. * @param mask defines the mask to be tested
  64331. * @return whether or not one observer registered with the given mask is handeled
  64332. **/
  64333. hasSpecificMask(mask?: number): boolean;
  64334. }
  64335. }
  64336. declare module BABYLON {
  64337. /**
  64338. * Class used to help managing file picking and drag'n'drop
  64339. * File Storage
  64340. */
  64341. export class FilesInputStore {
  64342. /**
  64343. * List of files ready to be loaded
  64344. */
  64345. static FilesToLoad: {
  64346. [key: string]: File;
  64347. };
  64348. }
  64349. }
  64350. declare module BABYLON {
  64351. /** Defines the cross module used constants to avoid circular dependncies */
  64352. export class Constants {
  64353. /** Defines that alpha blending is disabled */
  64354. static readonly ALPHA_DISABLE: number;
  64355. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64356. static readonly ALPHA_ADD: number;
  64357. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64358. static readonly ALPHA_COMBINE: number;
  64359. /** Defines that alpha blending to DEST - SRC * DEST */
  64360. static readonly ALPHA_SUBTRACT: number;
  64361. /** Defines that alpha blending to SRC * DEST */
  64362. static readonly ALPHA_MULTIPLY: number;
  64363. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64364. static readonly ALPHA_MAXIMIZED: number;
  64365. /** Defines that alpha blending to SRC + DEST */
  64366. static readonly ALPHA_ONEONE: number;
  64367. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64368. static readonly ALPHA_PREMULTIPLIED: number;
  64369. /**
  64370. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64371. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64372. */
  64373. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64374. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64375. static readonly ALPHA_INTERPOLATE: number;
  64376. /**
  64377. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64378. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64379. */
  64380. static readonly ALPHA_SCREENMODE: number;
  64381. /** Defines that the ressource is not delayed*/
  64382. static readonly DELAYLOADSTATE_NONE: number;
  64383. /** Defines that the ressource was successfully delay loaded */
  64384. static readonly DELAYLOADSTATE_LOADED: number;
  64385. /** Defines that the ressource is currently delay loading */
  64386. static readonly DELAYLOADSTATE_LOADING: number;
  64387. /** Defines that the ressource is delayed and has not started loading */
  64388. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64389. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64390. static readonly NEVER: number;
  64391. /** 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 */
  64392. static readonly ALWAYS: number;
  64393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64394. static readonly LESS: number;
  64395. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64396. static readonly EQUAL: number;
  64397. /** 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 */
  64398. static readonly LEQUAL: number;
  64399. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64400. static readonly GREATER: number;
  64401. /** 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 */
  64402. static readonly GEQUAL: number;
  64403. /** 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 */
  64404. static readonly NOTEQUAL: number;
  64405. /** Passed to stencilOperation to specify that stencil value must be kept */
  64406. static readonly KEEP: number;
  64407. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64408. static readonly REPLACE: number;
  64409. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64410. static readonly INCR: number;
  64411. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64412. static readonly DECR: number;
  64413. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64414. static readonly INVERT: number;
  64415. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64416. static readonly INCR_WRAP: number;
  64417. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64418. static readonly DECR_WRAP: number;
  64419. /** Texture is not repeating outside of 0..1 UVs */
  64420. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64421. /** Texture is repeating outside of 0..1 UVs */
  64422. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64423. /** Texture is repeating and mirrored */
  64424. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64425. /** ALPHA */
  64426. static readonly TEXTUREFORMAT_ALPHA: number;
  64427. /** LUMINANCE */
  64428. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64429. /** LUMINANCE_ALPHA */
  64430. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64431. /** RGB */
  64432. static readonly TEXTUREFORMAT_RGB: number;
  64433. /** RGBA */
  64434. static readonly TEXTUREFORMAT_RGBA: number;
  64435. /** RED */
  64436. static readonly TEXTUREFORMAT_RED: number;
  64437. /** RED (2nd reference) */
  64438. static readonly TEXTUREFORMAT_R: number;
  64439. /** RG */
  64440. static readonly TEXTUREFORMAT_RG: number;
  64441. /** RED_INTEGER */
  64442. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64443. /** RED_INTEGER (2nd reference) */
  64444. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64445. /** RG_INTEGER */
  64446. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64447. /** RGB_INTEGER */
  64448. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64449. /** RGBA_INTEGER */
  64450. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64451. /** UNSIGNED_BYTE */
  64452. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64453. /** UNSIGNED_BYTE (2nd reference) */
  64454. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64455. /** FLOAT */
  64456. static readonly TEXTURETYPE_FLOAT: number;
  64457. /** HALF_FLOAT */
  64458. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64459. /** BYTE */
  64460. static readonly TEXTURETYPE_BYTE: number;
  64461. /** SHORT */
  64462. static readonly TEXTURETYPE_SHORT: number;
  64463. /** UNSIGNED_SHORT */
  64464. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64465. /** INT */
  64466. static readonly TEXTURETYPE_INT: number;
  64467. /** UNSIGNED_INT */
  64468. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64469. /** UNSIGNED_SHORT_4_4_4_4 */
  64470. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64471. /** UNSIGNED_SHORT_5_5_5_1 */
  64472. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64473. /** UNSIGNED_SHORT_5_6_5 */
  64474. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64475. /** UNSIGNED_INT_2_10_10_10_REV */
  64476. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64477. /** UNSIGNED_INT_24_8 */
  64478. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64479. /** UNSIGNED_INT_10F_11F_11F_REV */
  64480. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64481. /** UNSIGNED_INT_5_9_9_9_REV */
  64482. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64483. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64484. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64485. /** nearest is mag = nearest and min = nearest and mip = linear */
  64486. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64487. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64488. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64489. /** Trilinear is mag = linear and min = linear and mip = linear */
  64490. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64491. /** nearest is mag = nearest and min = nearest and mip = linear */
  64492. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64493. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64494. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64495. /** Trilinear is mag = linear and min = linear and mip = linear */
  64496. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64497. /** mag = nearest and min = nearest and mip = nearest */
  64498. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64499. /** mag = nearest and min = linear and mip = nearest */
  64500. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64501. /** mag = nearest and min = linear and mip = linear */
  64502. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64503. /** mag = nearest and min = linear and mip = none */
  64504. static readonly TEXTURE_NEAREST_LINEAR: number;
  64505. /** mag = nearest and min = nearest and mip = none */
  64506. static readonly TEXTURE_NEAREST_NEAREST: number;
  64507. /** mag = linear and min = nearest and mip = nearest */
  64508. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64509. /** mag = linear and min = nearest and mip = linear */
  64510. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64511. /** mag = linear and min = linear and mip = none */
  64512. static readonly TEXTURE_LINEAR_LINEAR: number;
  64513. /** mag = linear and min = nearest and mip = none */
  64514. static readonly TEXTURE_LINEAR_NEAREST: number;
  64515. /** Explicit coordinates mode */
  64516. static readonly TEXTURE_EXPLICIT_MODE: number;
  64517. /** Spherical coordinates mode */
  64518. static readonly TEXTURE_SPHERICAL_MODE: number;
  64519. /** Planar coordinates mode */
  64520. static readonly TEXTURE_PLANAR_MODE: number;
  64521. /** Cubic coordinates mode */
  64522. static readonly TEXTURE_CUBIC_MODE: number;
  64523. /** Projection coordinates mode */
  64524. static readonly TEXTURE_PROJECTION_MODE: number;
  64525. /** Skybox coordinates mode */
  64526. static readonly TEXTURE_SKYBOX_MODE: number;
  64527. /** Inverse Cubic coordinates mode */
  64528. static readonly TEXTURE_INVCUBIC_MODE: number;
  64529. /** Equirectangular coordinates mode */
  64530. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64531. /** Equirectangular Fixed coordinates mode */
  64532. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64533. /** Equirectangular Fixed Mirrored coordinates mode */
  64534. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64535. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64536. static readonly SCALEMODE_FLOOR: number;
  64537. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64538. static readonly SCALEMODE_NEAREST: number;
  64539. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64540. static readonly SCALEMODE_CEILING: number;
  64541. /**
  64542. * The dirty texture flag value
  64543. */
  64544. static readonly MATERIAL_TextureDirtyFlag: number;
  64545. /**
  64546. * The dirty light flag value
  64547. */
  64548. static readonly MATERIAL_LightDirtyFlag: number;
  64549. /**
  64550. * The dirty fresnel flag value
  64551. */
  64552. static readonly MATERIAL_FresnelDirtyFlag: number;
  64553. /**
  64554. * The dirty attribute flag value
  64555. */
  64556. static readonly MATERIAL_AttributesDirtyFlag: number;
  64557. /**
  64558. * The dirty misc flag value
  64559. */
  64560. static readonly MATERIAL_MiscDirtyFlag: number;
  64561. /**
  64562. * The all dirty flag value
  64563. */
  64564. static readonly MATERIAL_AllDirtyFlag: number;
  64565. /**
  64566. * Returns the triangle fill mode
  64567. */
  64568. static readonly MATERIAL_TriangleFillMode: number;
  64569. /**
  64570. * Returns the wireframe mode
  64571. */
  64572. static readonly MATERIAL_WireFrameFillMode: number;
  64573. /**
  64574. * Returns the point fill mode
  64575. */
  64576. static readonly MATERIAL_PointFillMode: number;
  64577. /**
  64578. * Returns the point list draw mode
  64579. */
  64580. static readonly MATERIAL_PointListDrawMode: number;
  64581. /**
  64582. * Returns the line list draw mode
  64583. */
  64584. static readonly MATERIAL_LineListDrawMode: number;
  64585. /**
  64586. * Returns the line loop draw mode
  64587. */
  64588. static readonly MATERIAL_LineLoopDrawMode: number;
  64589. /**
  64590. * Returns the line strip draw mode
  64591. */
  64592. static readonly MATERIAL_LineStripDrawMode: number;
  64593. /**
  64594. * Returns the triangle strip draw mode
  64595. */
  64596. static readonly MATERIAL_TriangleStripDrawMode: number;
  64597. /**
  64598. * Returns the triangle fan draw mode
  64599. */
  64600. static readonly MATERIAL_TriangleFanDrawMode: number;
  64601. /**
  64602. * Stores the clock-wise side orientation
  64603. */
  64604. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64605. /**
  64606. * Stores the counter clock-wise side orientation
  64607. */
  64608. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64609. /**
  64610. * Nothing
  64611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64612. */
  64613. static readonly ACTION_NothingTrigger: number;
  64614. /**
  64615. * On pick
  64616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64617. */
  64618. static readonly ACTION_OnPickTrigger: number;
  64619. /**
  64620. * On left pick
  64621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64622. */
  64623. static readonly ACTION_OnLeftPickTrigger: number;
  64624. /**
  64625. * On right pick
  64626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64627. */
  64628. static readonly ACTION_OnRightPickTrigger: number;
  64629. /**
  64630. * On center pick
  64631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64632. */
  64633. static readonly ACTION_OnCenterPickTrigger: number;
  64634. /**
  64635. * On pick down
  64636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64637. */
  64638. static readonly ACTION_OnPickDownTrigger: number;
  64639. /**
  64640. * On double pick
  64641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64642. */
  64643. static readonly ACTION_OnDoublePickTrigger: number;
  64644. /**
  64645. * On pick up
  64646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64647. */
  64648. static readonly ACTION_OnPickUpTrigger: number;
  64649. /**
  64650. * On pick out.
  64651. * This trigger will only be raised if you also declared a OnPickDown
  64652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64653. */
  64654. static readonly ACTION_OnPickOutTrigger: number;
  64655. /**
  64656. * On long press
  64657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64658. */
  64659. static readonly ACTION_OnLongPressTrigger: number;
  64660. /**
  64661. * On pointer over
  64662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64663. */
  64664. static readonly ACTION_OnPointerOverTrigger: number;
  64665. /**
  64666. * On pointer out
  64667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64668. */
  64669. static readonly ACTION_OnPointerOutTrigger: number;
  64670. /**
  64671. * On every frame
  64672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64673. */
  64674. static readonly ACTION_OnEveryFrameTrigger: number;
  64675. /**
  64676. * On intersection enter
  64677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64678. */
  64679. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64680. /**
  64681. * On intersection exit
  64682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64683. */
  64684. static readonly ACTION_OnIntersectionExitTrigger: number;
  64685. /**
  64686. * On key down
  64687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64688. */
  64689. static readonly ACTION_OnKeyDownTrigger: number;
  64690. /**
  64691. * On key up
  64692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64693. */
  64694. static readonly ACTION_OnKeyUpTrigger: number;
  64695. /**
  64696. * Billboard mode will only apply to Y axis
  64697. */
  64698. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64699. /**
  64700. * Billboard mode will apply to all axes
  64701. */
  64702. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64703. /**
  64704. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64705. */
  64706. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64707. /**
  64708. * Gets or sets base Assets URL
  64709. */
  64710. static readonly PARTICLES_BaseAssetsUrl: string;
  64711. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64712. * Test order :
  64713. * Is the bounding sphere outside the frustum ?
  64714. * If not, are the bounding box vertices outside the frustum ?
  64715. * It not, then the cullable object is in the frustum.
  64716. */
  64717. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64718. /** Culling strategy : Bounding Sphere Only.
  64719. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64720. * It's also less accurate than the standard because some not visible objects can still be selected.
  64721. * Test : is the bounding sphere outside the frustum ?
  64722. * If not, then the cullable object is in the frustum.
  64723. */
  64724. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64725. /** Culling strategy : Optimistic Inclusion.
  64726. * This in an inclusion test first, then the standard exclusion test.
  64727. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64728. * 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.
  64729. * Anyway, it's as accurate as the standard strategy.
  64730. * Test :
  64731. * Is the cullable object bounding sphere center in the frustum ?
  64732. * If not, apply the default culling strategy.
  64733. */
  64734. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64735. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64736. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64737. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64738. * 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.
  64739. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64740. * Test :
  64741. * Is the cullable object bounding sphere center in the frustum ?
  64742. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64743. */
  64744. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64745. /**
  64746. * No logging while loading
  64747. */
  64748. static readonly SCENELOADER_NO_LOGGING: number;
  64749. /**
  64750. * Minimal logging while loading
  64751. */
  64752. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64753. /**
  64754. * Summary logging while loading
  64755. */
  64756. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64757. /**
  64758. * Detailled logging while loading
  64759. */
  64760. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64761. }
  64762. }
  64763. declare module BABYLON {
  64764. /**
  64765. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64766. * Babylon.js
  64767. */
  64768. export class DomManagement {
  64769. /**
  64770. * Checks if the window object exists
  64771. * @returns true if the window object exists
  64772. */
  64773. static IsWindowObjectExist(): boolean;
  64774. /**
  64775. * Extracts text content from a DOM element hierarchy
  64776. * @param element defines the root element
  64777. * @returns a string
  64778. */
  64779. static GetDOMTextContent(element: HTMLElement): string;
  64780. }
  64781. }
  64782. declare module BABYLON {
  64783. /**
  64784. * Logger used througouht the application to allow configuration of
  64785. * the log level required for the messages.
  64786. */
  64787. export class Logger {
  64788. /**
  64789. * No log
  64790. */
  64791. static readonly NoneLogLevel: number;
  64792. /**
  64793. * Only message logs
  64794. */
  64795. static readonly MessageLogLevel: number;
  64796. /**
  64797. * Only warning logs
  64798. */
  64799. static readonly WarningLogLevel: number;
  64800. /**
  64801. * Only error logs
  64802. */
  64803. static readonly ErrorLogLevel: number;
  64804. /**
  64805. * All logs
  64806. */
  64807. static readonly AllLogLevel: number;
  64808. private static _LogCache;
  64809. /**
  64810. * Gets a value indicating the number of loading errors
  64811. * @ignorenaming
  64812. */
  64813. static errorsCount: number;
  64814. /**
  64815. * Callback called when a new log is added
  64816. */
  64817. static OnNewCacheEntry: (entry: string) => void;
  64818. private static _AddLogEntry;
  64819. private static _FormatMessage;
  64820. private static _LogDisabled;
  64821. private static _LogEnabled;
  64822. private static _WarnDisabled;
  64823. private static _WarnEnabled;
  64824. private static _ErrorDisabled;
  64825. private static _ErrorEnabled;
  64826. /**
  64827. * Log a message to the console
  64828. */
  64829. static Log: (message: string) => void;
  64830. /**
  64831. * Write a warning message to the console
  64832. */
  64833. static Warn: (message: string) => void;
  64834. /**
  64835. * Write an error message to the console
  64836. */
  64837. static Error: (message: string) => void;
  64838. /**
  64839. * Gets current log cache (list of logs)
  64840. */
  64841. static readonly LogCache: string;
  64842. /**
  64843. * Clears the log cache
  64844. */
  64845. static ClearLogCache(): void;
  64846. /**
  64847. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64848. */
  64849. static LogLevels: number;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /** @hidden */
  64854. export class _TypeStore {
  64855. /** @hidden */
  64856. static RegisteredTypes: {
  64857. [key: string]: Object;
  64858. };
  64859. /** @hidden */
  64860. static GetClass(fqdn: string): any;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. /**
  64865. * Class containing a set of static utilities functions for deep copy.
  64866. */
  64867. export class DeepCopier {
  64868. /**
  64869. * Tries to copy an object by duplicating every property
  64870. * @param source defines the source object
  64871. * @param destination defines the target object
  64872. * @param doNotCopyList defines a list of properties to avoid
  64873. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64874. */
  64875. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64876. }
  64877. }
  64878. declare module BABYLON {
  64879. /**
  64880. * Class containing a set of static utilities functions for precision date
  64881. */
  64882. export class PrecisionDate {
  64883. /**
  64884. * Gets either window.performance.now() if supported or Date.now() else
  64885. */
  64886. static readonly Now: number;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /** @hidden */
  64891. export class _DevTools {
  64892. static WarnImport(name: string): string;
  64893. }
  64894. }
  64895. declare module BABYLON {
  64896. /**
  64897. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64898. */
  64899. export class WebRequest {
  64900. private _xhr;
  64901. /**
  64902. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64903. * i.e. when loading files, where the server/service expects an Authorization header
  64904. */
  64905. static CustomRequestHeaders: {
  64906. [key: string]: string;
  64907. };
  64908. /**
  64909. * Add callback functions in this array to update all the requests before they get sent to the network
  64910. */
  64911. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64912. private _injectCustomRequestHeaders;
  64913. /**
  64914. * Gets or sets a function to be called when loading progress changes
  64915. */
  64916. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64917. /**
  64918. * Returns client's state
  64919. */
  64920. readonly readyState: number;
  64921. /**
  64922. * Returns client's status
  64923. */
  64924. readonly status: number;
  64925. /**
  64926. * Returns client's status as a text
  64927. */
  64928. readonly statusText: string;
  64929. /**
  64930. * Returns client's response
  64931. */
  64932. readonly response: any;
  64933. /**
  64934. * Returns client's response url
  64935. */
  64936. readonly responseURL: string;
  64937. /**
  64938. * Returns client's response as text
  64939. */
  64940. readonly responseText: string;
  64941. /**
  64942. * Gets or sets the expected response type
  64943. */
  64944. responseType: XMLHttpRequestResponseType;
  64945. /** @hidden */
  64946. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64947. /** @hidden */
  64948. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64949. /**
  64950. * Cancels any network activity
  64951. */
  64952. abort(): void;
  64953. /**
  64954. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64955. * @param body defines an optional request body
  64956. */
  64957. send(body?: Document | BodyInit | null): void;
  64958. /**
  64959. * Sets the request method, request URL
  64960. * @param method defines the method to use (GET, POST, etc..)
  64961. * @param url defines the url to connect with
  64962. */
  64963. open(method: string, url: string): void;
  64964. }
  64965. }
  64966. declare module BABYLON {
  64967. /**
  64968. * Class used to evalaute queries containing `and` and `or` operators
  64969. */
  64970. export class AndOrNotEvaluator {
  64971. /**
  64972. * Evaluate a query
  64973. * @param query defines the query to evaluate
  64974. * @param evaluateCallback defines the callback used to filter result
  64975. * @returns true if the query matches
  64976. */
  64977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64978. private static _HandleParenthesisContent;
  64979. private static _SimplifyNegation;
  64980. }
  64981. }
  64982. declare module BABYLON {
  64983. /**
  64984. * Class used to store custom tags
  64985. */
  64986. export class Tags {
  64987. /**
  64988. * Adds support for tags on the given object
  64989. * @param obj defines the object to use
  64990. */
  64991. static EnableFor(obj: any): void;
  64992. /**
  64993. * Removes tags support
  64994. * @param obj defines the object to use
  64995. */
  64996. static DisableFor(obj: any): void;
  64997. /**
  64998. * Gets a boolean indicating if the given object has tags
  64999. * @param obj defines the object to use
  65000. * @returns a boolean
  65001. */
  65002. static HasTags(obj: any): boolean;
  65003. /**
  65004. * Gets the tags available on a given object
  65005. * @param obj defines the object to use
  65006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65007. * @returns the tags
  65008. */
  65009. static GetTags(obj: any, asString?: boolean): any;
  65010. /**
  65011. * Adds tags to an object
  65012. * @param obj defines the object to use
  65013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65015. */
  65016. static AddTagsTo(obj: any, tagsString: string): void;
  65017. /**
  65018. * @hidden
  65019. */
  65020. static _AddTagTo(obj: any, tag: string): void;
  65021. /**
  65022. * Removes specific tags from a specific object
  65023. * @param obj defines the object to use
  65024. * @param tagsString defines the tags to remove
  65025. */
  65026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65027. /**
  65028. * @hidden
  65029. */
  65030. static _RemoveTagFrom(obj: any, tag: string): void;
  65031. /**
  65032. * Defines if tags hosted on an object match a given query
  65033. * @param obj defines the object to use
  65034. * @param tagsQuery defines the tag query
  65035. * @returns a boolean
  65036. */
  65037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * Manages the defines for the Material
  65043. */
  65044. export class MaterialDefines {
  65045. private _keys;
  65046. private _isDirty;
  65047. /** @hidden */
  65048. _renderId: number;
  65049. /** @hidden */
  65050. _areLightsDirty: boolean;
  65051. /** @hidden */
  65052. _areAttributesDirty: boolean;
  65053. /** @hidden */
  65054. _areTexturesDirty: boolean;
  65055. /** @hidden */
  65056. _areFresnelDirty: boolean;
  65057. /** @hidden */
  65058. _areMiscDirty: boolean;
  65059. /** @hidden */
  65060. _areImageProcessingDirty: boolean;
  65061. /** @hidden */
  65062. _normals: boolean;
  65063. /** @hidden */
  65064. _uvs: boolean;
  65065. /** @hidden */
  65066. _needNormals: boolean;
  65067. /** @hidden */
  65068. _needUVs: boolean;
  65069. /**
  65070. * Specifies if the material needs to be re-calculated
  65071. */
  65072. readonly isDirty: boolean;
  65073. /**
  65074. * Marks the material to indicate that it has been re-calculated
  65075. */
  65076. markAsProcessed(): void;
  65077. /**
  65078. * Marks the material to indicate that it needs to be re-calculated
  65079. */
  65080. markAsUnprocessed(): void;
  65081. /**
  65082. * Marks the material to indicate all of its defines need to be re-calculated
  65083. */
  65084. markAllAsDirty(): void;
  65085. /**
  65086. * Marks the material to indicate that image processing needs to be re-calculated
  65087. */
  65088. markAsImageProcessingDirty(): void;
  65089. /**
  65090. * Marks the material to indicate the lights need to be re-calculated
  65091. */
  65092. markAsLightDirty(): void;
  65093. /**
  65094. * Marks the attribute state as changed
  65095. */
  65096. markAsAttributesDirty(): void;
  65097. /**
  65098. * Marks the texture state as changed
  65099. */
  65100. markAsTexturesDirty(): void;
  65101. /**
  65102. * Marks the fresnel state as changed
  65103. */
  65104. markAsFresnelDirty(): void;
  65105. /**
  65106. * Marks the misc state as changed
  65107. */
  65108. markAsMiscDirty(): void;
  65109. /**
  65110. * Rebuilds the material defines
  65111. */
  65112. rebuild(): void;
  65113. /**
  65114. * Specifies if two material defines are equal
  65115. * @param other - A material define instance to compare to
  65116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65117. */
  65118. isEqual(other: MaterialDefines): boolean;
  65119. /**
  65120. * Clones this instance's defines to another instance
  65121. * @param other - material defines to clone values to
  65122. */
  65123. cloneTo(other: MaterialDefines): void;
  65124. /**
  65125. * Resets the material define values
  65126. */
  65127. reset(): void;
  65128. /**
  65129. * Converts the material define values to a string
  65130. * @returns - String of material define information
  65131. */
  65132. toString(): string;
  65133. }
  65134. }
  65135. declare module BABYLON {
  65136. /**
  65137. * Class used to store and describe the pipeline context associated with an effect
  65138. */
  65139. export interface IPipelineContext {
  65140. /**
  65141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65142. */
  65143. isAsync: boolean;
  65144. /**
  65145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65146. */
  65147. isReady: boolean;
  65148. }
  65149. }
  65150. declare module BABYLON {
  65151. /**
  65152. * Class used to store gfx data (like WebGLBuffer)
  65153. */
  65154. export class DataBuffer {
  65155. /**
  65156. * Gets or sets the number of objects referencing this buffer
  65157. */
  65158. references: number;
  65159. /** Gets or sets the size of the underlying buffer */
  65160. capacity: number;
  65161. /**
  65162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65163. */
  65164. is32Bits: boolean;
  65165. /**
  65166. * Gets the underlying buffer
  65167. */
  65168. readonly underlyingResource: any;
  65169. }
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65174. */
  65175. export class PerformanceMonitor {
  65176. private _enabled;
  65177. private _rollingFrameTime;
  65178. private _lastFrameTimeMs;
  65179. /**
  65180. * constructor
  65181. * @param frameSampleSize The number of samples required to saturate the sliding window
  65182. */
  65183. constructor(frameSampleSize?: number);
  65184. /**
  65185. * Samples current frame
  65186. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65187. */
  65188. sampleFrame(timeMs?: number): void;
  65189. /**
  65190. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65191. */
  65192. readonly averageFrameTime: number;
  65193. /**
  65194. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65195. */
  65196. readonly averageFrameTimeVariance: number;
  65197. /**
  65198. * Returns the frame time of the most recent frame
  65199. */
  65200. readonly instantaneousFrameTime: number;
  65201. /**
  65202. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65203. */
  65204. readonly averageFPS: number;
  65205. /**
  65206. * Returns the average framerate in frames per second using the most recent frame time
  65207. */
  65208. readonly instantaneousFPS: number;
  65209. /**
  65210. * Returns true if enough samples have been taken to completely fill the sliding window
  65211. */
  65212. readonly isSaturated: boolean;
  65213. /**
  65214. * Enables contributions to the sliding window sample set
  65215. */
  65216. enable(): void;
  65217. /**
  65218. * Disables contributions to the sliding window sample set
  65219. * Samples will not be interpolated over the disabled period
  65220. */
  65221. disable(): void;
  65222. /**
  65223. * Returns true if sampling is enabled
  65224. */
  65225. readonly isEnabled: boolean;
  65226. /**
  65227. * Resets performance monitor
  65228. */
  65229. reset(): void;
  65230. }
  65231. /**
  65232. * RollingAverage
  65233. *
  65234. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65235. */
  65236. export class RollingAverage {
  65237. /**
  65238. * Current average
  65239. */
  65240. average: number;
  65241. /**
  65242. * Current variance
  65243. */
  65244. variance: number;
  65245. protected _samples: Array<number>;
  65246. protected _sampleCount: number;
  65247. protected _pos: number;
  65248. protected _m2: number;
  65249. /**
  65250. * constructor
  65251. * @param length The number of samples required to saturate the sliding window
  65252. */
  65253. constructor(length: number);
  65254. /**
  65255. * Adds a sample to the sample set
  65256. * @param v The sample value
  65257. */
  65258. add(v: number): void;
  65259. /**
  65260. * Returns previously added values or null if outside of history or outside the sliding window domain
  65261. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65262. * @return Value previously recorded with add() or null if outside of range
  65263. */
  65264. history(i: number): number;
  65265. /**
  65266. * Returns true if enough samples have been taken to completely fill the sliding window
  65267. * @return true if sample-set saturated
  65268. */
  65269. isSaturated(): boolean;
  65270. /**
  65271. * Resets the rolling average (equivalent to 0 samples taken so far)
  65272. */
  65273. reset(): void;
  65274. /**
  65275. * Wraps a value around the sample range boundaries
  65276. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65277. * @return Wrapped position in sample range
  65278. */
  65279. protected _wrapPosition(i: number): number;
  65280. }
  65281. }
  65282. declare module BABYLON {
  65283. /**
  65284. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65285. * The underlying implementation relies on an associative array to ensure the best performances.
  65286. * The value can be anything including 'null' but except 'undefined'
  65287. */
  65288. export class StringDictionary<T> {
  65289. /**
  65290. * This will clear this dictionary and copy the content from the 'source' one.
  65291. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65292. * @param source the dictionary to take the content from and copy to this dictionary
  65293. */
  65294. copyFrom(source: StringDictionary<T>): void;
  65295. /**
  65296. * Get a value based from its key
  65297. * @param key the given key to get the matching value from
  65298. * @return the value if found, otherwise undefined is returned
  65299. */
  65300. get(key: string): T | undefined;
  65301. /**
  65302. * Get a value from its key or add it if it doesn't exist.
  65303. * This method will ensure you that a given key/data will be present in the dictionary.
  65304. * @param key the given key to get the matching value from
  65305. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65306. * The factory will only be invoked if there's no data for the given key.
  65307. * @return the value corresponding to the key.
  65308. */
  65309. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65310. /**
  65311. * Get a value from its key if present in the dictionary otherwise add it
  65312. * @param key the key to get the value from
  65313. * @param val if there's no such key/value pair in the dictionary add it with this value
  65314. * @return the value corresponding to the key
  65315. */
  65316. getOrAdd(key: string, val: T): T;
  65317. /**
  65318. * Check if there's a given key in the dictionary
  65319. * @param key the key to check for
  65320. * @return true if the key is present, false otherwise
  65321. */
  65322. contains(key: string): boolean;
  65323. /**
  65324. * Add a new key and its corresponding value
  65325. * @param key the key to add
  65326. * @param value the value corresponding to the key
  65327. * @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
  65328. */
  65329. add(key: string, value: T): boolean;
  65330. /**
  65331. * Update a specific value associated to a key
  65332. * @param key defines the key to use
  65333. * @param value defines the value to store
  65334. * @returns true if the value was updated (or false if the key was not found)
  65335. */
  65336. set(key: string, value: T): boolean;
  65337. /**
  65338. * Get the element of the given key and remove it from the dictionary
  65339. * @param key defines the key to search
  65340. * @returns the value associated with the key or null if not found
  65341. */
  65342. getAndRemove(key: string): Nullable<T>;
  65343. /**
  65344. * Remove a key/value from the dictionary.
  65345. * @param key the key to remove
  65346. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65347. */
  65348. remove(key: string): boolean;
  65349. /**
  65350. * Clear the whole content of the dictionary
  65351. */
  65352. clear(): void;
  65353. /**
  65354. * Gets the current count
  65355. */
  65356. readonly count: number;
  65357. /**
  65358. * Execute a callback on each key/val of the dictionary.
  65359. * Note that you can remove any element in this dictionary in the callback implementation
  65360. * @param callback the callback to execute on a given key/value pair
  65361. */
  65362. forEach(callback: (key: string, val: T) => void): void;
  65363. /**
  65364. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65365. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65366. * Note that you can remove any element in this dictionary in the callback implementation
  65367. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65368. * @returns the first item
  65369. */
  65370. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65371. private _count;
  65372. private _data;
  65373. }
  65374. }
  65375. declare module BABYLON {
  65376. /**
  65377. * Helper class that provides a small promise polyfill
  65378. */
  65379. export class PromisePolyfill {
  65380. /**
  65381. * Static function used to check if the polyfill is required
  65382. * If this is the case then the function will inject the polyfill to window.Promise
  65383. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65384. */
  65385. static Apply(force?: boolean): void;
  65386. }
  65387. }
  65388. declare module BABYLON {
  65389. /**
  65390. * Class used to store data that will be store in GPU memory
  65391. */
  65392. export class Buffer {
  65393. private _engine;
  65394. private _buffer;
  65395. /** @hidden */
  65396. _data: Nullable<DataArray>;
  65397. private _updatable;
  65398. private _instanced;
  65399. /**
  65400. * Gets the byte stride.
  65401. */
  65402. readonly byteStride: number;
  65403. /**
  65404. * Constructor
  65405. * @param engine the engine
  65406. * @param data the data to use for this buffer
  65407. * @param updatable whether the data is updatable
  65408. * @param stride the stride (optional)
  65409. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65410. * @param instanced whether the buffer is instanced (optional)
  65411. * @param useBytes set to true if the stride in in bytes (optional)
  65412. */
  65413. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65414. /**
  65415. * Create a new VertexBuffer based on the current buffer
  65416. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65417. * @param offset defines offset in the buffer (0 by default)
  65418. * @param size defines the size in floats of attributes (position is 3 for instance)
  65419. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65420. * @param instanced defines if the vertex buffer contains indexed data
  65421. * @param useBytes defines if the offset and stride are in bytes
  65422. * @returns the new vertex buffer
  65423. */
  65424. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65425. /**
  65426. * Gets a boolean indicating if the Buffer is updatable?
  65427. * @returns true if the buffer is updatable
  65428. */
  65429. isUpdatable(): boolean;
  65430. /**
  65431. * Gets current buffer's data
  65432. * @returns a DataArray or null
  65433. */
  65434. getData(): Nullable<DataArray>;
  65435. /**
  65436. * Gets underlying native buffer
  65437. * @returns underlying native buffer
  65438. */
  65439. getBuffer(): Nullable<DataBuffer>;
  65440. /**
  65441. * Gets the stride in float32 units (i.e. byte stride / 4).
  65442. * May not be an integer if the byte stride is not divisible by 4.
  65443. * DEPRECATED. Use byteStride instead.
  65444. * @returns the stride in float32 units
  65445. */
  65446. getStrideSize(): number;
  65447. /**
  65448. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65449. * @param data defines the data to store
  65450. */
  65451. create(data?: Nullable<DataArray>): void;
  65452. /** @hidden */
  65453. _rebuild(): void;
  65454. /**
  65455. * Update current buffer data
  65456. * @param data defines the data to store
  65457. */
  65458. update(data: DataArray): void;
  65459. /**
  65460. * Updates the data directly.
  65461. * @param data the new data
  65462. * @param offset the new offset
  65463. * @param vertexCount the vertex count (optional)
  65464. * @param useBytes set to true if the offset is in bytes
  65465. */
  65466. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65467. /**
  65468. * Release all resources
  65469. */
  65470. dispose(): void;
  65471. }
  65472. /**
  65473. * Specialized buffer used to store vertex data
  65474. */
  65475. export class VertexBuffer {
  65476. /** @hidden */
  65477. _buffer: Buffer;
  65478. private _kind;
  65479. private _size;
  65480. private _ownsBuffer;
  65481. private _instanced;
  65482. private _instanceDivisor;
  65483. /**
  65484. * The byte type.
  65485. */
  65486. static readonly BYTE: number;
  65487. /**
  65488. * The unsigned byte type.
  65489. */
  65490. static readonly UNSIGNED_BYTE: number;
  65491. /**
  65492. * The short type.
  65493. */
  65494. static readonly SHORT: number;
  65495. /**
  65496. * The unsigned short type.
  65497. */
  65498. static readonly UNSIGNED_SHORT: number;
  65499. /**
  65500. * The integer type.
  65501. */
  65502. static readonly INT: number;
  65503. /**
  65504. * The unsigned integer type.
  65505. */
  65506. static readonly UNSIGNED_INT: number;
  65507. /**
  65508. * The float type.
  65509. */
  65510. static readonly FLOAT: number;
  65511. /**
  65512. * Gets or sets the instance divisor when in instanced mode
  65513. */
  65514. instanceDivisor: number;
  65515. /**
  65516. * Gets the byte stride.
  65517. */
  65518. readonly byteStride: number;
  65519. /**
  65520. * Gets the byte offset.
  65521. */
  65522. readonly byteOffset: number;
  65523. /**
  65524. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65525. */
  65526. readonly normalized: boolean;
  65527. /**
  65528. * Gets the data type of each component in the array.
  65529. */
  65530. readonly type: number;
  65531. /**
  65532. * Constructor
  65533. * @param engine the engine
  65534. * @param data the data to use for this vertex buffer
  65535. * @param kind the vertex buffer kind
  65536. * @param updatable whether the data is updatable
  65537. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65538. * @param stride the stride (optional)
  65539. * @param instanced whether the buffer is instanced (optional)
  65540. * @param offset the offset of the data (optional)
  65541. * @param size the number of components (optional)
  65542. * @param type the type of the component (optional)
  65543. * @param normalized whether the data contains normalized data (optional)
  65544. * @param useBytes set to true if stride and offset are in bytes (optional)
  65545. */
  65546. 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);
  65547. /** @hidden */
  65548. _rebuild(): void;
  65549. /**
  65550. * Returns the kind of the VertexBuffer (string)
  65551. * @returns a string
  65552. */
  65553. getKind(): string;
  65554. /**
  65555. * Gets a boolean indicating if the VertexBuffer is updatable?
  65556. * @returns true if the buffer is updatable
  65557. */
  65558. isUpdatable(): boolean;
  65559. /**
  65560. * Gets current buffer's data
  65561. * @returns a DataArray or null
  65562. */
  65563. getData(): Nullable<DataArray>;
  65564. /**
  65565. * Gets underlying native buffer
  65566. * @returns underlying native buffer
  65567. */
  65568. getBuffer(): Nullable<DataBuffer>;
  65569. /**
  65570. * Gets the stride in float32 units (i.e. byte stride / 4).
  65571. * May not be an integer if the byte stride is not divisible by 4.
  65572. * DEPRECATED. Use byteStride instead.
  65573. * @returns the stride in float32 units
  65574. */
  65575. getStrideSize(): number;
  65576. /**
  65577. * Returns the offset as a multiple of the type byte length.
  65578. * DEPRECATED. Use byteOffset instead.
  65579. * @returns the offset in bytes
  65580. */
  65581. getOffset(): number;
  65582. /**
  65583. * Returns the number of components per vertex attribute (integer)
  65584. * @returns the size in float
  65585. */
  65586. getSize(): number;
  65587. /**
  65588. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65589. * @returns true if this buffer is instanced
  65590. */
  65591. getIsInstanced(): boolean;
  65592. /**
  65593. * Returns the instancing divisor, zero for non-instanced (integer).
  65594. * @returns a number
  65595. */
  65596. getInstanceDivisor(): number;
  65597. /**
  65598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65599. * @param data defines the data to store
  65600. */
  65601. create(data?: DataArray): void;
  65602. /**
  65603. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65604. * This function will create a new buffer if the current one is not updatable
  65605. * @param data defines the data to store
  65606. */
  65607. update(data: DataArray): void;
  65608. /**
  65609. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65610. * Returns the directly updated WebGLBuffer.
  65611. * @param data the new data
  65612. * @param offset the new offset
  65613. * @param useBytes set to true if the offset is in bytes
  65614. */
  65615. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65616. /**
  65617. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65618. */
  65619. dispose(): void;
  65620. /**
  65621. * Enumerates each value of this vertex buffer as numbers.
  65622. * @param count the number of values to enumerate
  65623. * @param callback the callback function called for each value
  65624. */
  65625. forEach(count: number, callback: (value: number, index: number) => void): void;
  65626. /**
  65627. * Positions
  65628. */
  65629. static readonly PositionKind: string;
  65630. /**
  65631. * Normals
  65632. */
  65633. static readonly NormalKind: string;
  65634. /**
  65635. * Tangents
  65636. */
  65637. static readonly TangentKind: string;
  65638. /**
  65639. * Texture coordinates
  65640. */
  65641. static readonly UVKind: string;
  65642. /**
  65643. * Texture coordinates 2
  65644. */
  65645. static readonly UV2Kind: string;
  65646. /**
  65647. * Texture coordinates 3
  65648. */
  65649. static readonly UV3Kind: string;
  65650. /**
  65651. * Texture coordinates 4
  65652. */
  65653. static readonly UV4Kind: string;
  65654. /**
  65655. * Texture coordinates 5
  65656. */
  65657. static readonly UV5Kind: string;
  65658. /**
  65659. * Texture coordinates 6
  65660. */
  65661. static readonly UV6Kind: string;
  65662. /**
  65663. * Colors
  65664. */
  65665. static readonly ColorKind: string;
  65666. /**
  65667. * Matrix indices (for bones)
  65668. */
  65669. static readonly MatricesIndicesKind: string;
  65670. /**
  65671. * Matrix weights (for bones)
  65672. */
  65673. static readonly MatricesWeightsKind: string;
  65674. /**
  65675. * Additional matrix indices (for bones)
  65676. */
  65677. static readonly MatricesIndicesExtraKind: string;
  65678. /**
  65679. * Additional matrix weights (for bones)
  65680. */
  65681. static readonly MatricesWeightsExtraKind: string;
  65682. /**
  65683. * Deduces the stride given a kind.
  65684. * @param kind The kind string to deduce
  65685. * @returns The deduced stride
  65686. */
  65687. static DeduceStride(kind: string): number;
  65688. /**
  65689. * Gets the byte length of the given type.
  65690. * @param type the type
  65691. * @returns the number of bytes
  65692. */
  65693. static GetTypeByteLength(type: number): number;
  65694. /**
  65695. * Enumerates each value of the given parameters as numbers.
  65696. * @param data the data to enumerate
  65697. * @param byteOffset the byte offset of the data
  65698. * @param byteStride the byte stride of the data
  65699. * @param componentCount the number of components per element
  65700. * @param componentType the type of the component
  65701. * @param count the total number of components
  65702. * @param normalized whether the data is normalized
  65703. * @param callback the callback function called for each value
  65704. */
  65705. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65706. private static _GetFloatValue;
  65707. }
  65708. }
  65709. declare module BABYLON {
  65710. /**
  65711. * Class representing spherical harmonics coefficients to the 3rd degree
  65712. */
  65713. export class SphericalHarmonics {
  65714. /**
  65715. * Defines whether or not the harmonics have been prescaled for rendering.
  65716. */
  65717. preScaled: boolean;
  65718. /**
  65719. * The l0,0 coefficients of the spherical harmonics
  65720. */
  65721. l00: Vector3;
  65722. /**
  65723. * The l1,-1 coefficients of the spherical harmonics
  65724. */
  65725. l1_1: Vector3;
  65726. /**
  65727. * The l1,0 coefficients of the spherical harmonics
  65728. */
  65729. l10: Vector3;
  65730. /**
  65731. * The l1,1 coefficients of the spherical harmonics
  65732. */
  65733. l11: Vector3;
  65734. /**
  65735. * The l2,-2 coefficients of the spherical harmonics
  65736. */
  65737. l2_2: Vector3;
  65738. /**
  65739. * The l2,-1 coefficients of the spherical harmonics
  65740. */
  65741. l2_1: Vector3;
  65742. /**
  65743. * The l2,0 coefficients of the spherical harmonics
  65744. */
  65745. l20: Vector3;
  65746. /**
  65747. * The l2,1 coefficients of the spherical harmonics
  65748. */
  65749. l21: Vector3;
  65750. /**
  65751. * The l2,2 coefficients of the spherical harmonics
  65752. */
  65753. l22: Vector3;
  65754. /**
  65755. * Adds a light to the spherical harmonics
  65756. * @param direction the direction of the light
  65757. * @param color the color of the light
  65758. * @param deltaSolidAngle the delta solid angle of the light
  65759. */
  65760. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65761. /**
  65762. * Scales the spherical harmonics by the given amount
  65763. * @param scale the amount to scale
  65764. */
  65765. scaleInPlace(scale: number): void;
  65766. /**
  65767. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65768. *
  65769. * ```
  65770. * E_lm = A_l * L_lm
  65771. * ```
  65772. *
  65773. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65774. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65775. * the scaling factors are given in equation 9.
  65776. */
  65777. convertIncidentRadianceToIrradiance(): void;
  65778. /**
  65779. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65780. *
  65781. * ```
  65782. * L = (1/pi) * E * rho
  65783. * ```
  65784. *
  65785. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65786. */
  65787. convertIrradianceToLambertianRadiance(): void;
  65788. /**
  65789. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65790. * required operations at run time.
  65791. *
  65792. * This is simply done by scaling back the SH with Ylm constants parameter.
  65793. * The trigonometric part being applied by the shader at run time.
  65794. */
  65795. preScaleForRendering(): void;
  65796. /**
  65797. * Constructs a spherical harmonics from an array.
  65798. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65799. * @returns the spherical harmonics
  65800. */
  65801. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65802. /**
  65803. * Gets the spherical harmonics from polynomial
  65804. * @param polynomial the spherical polynomial
  65805. * @returns the spherical harmonics
  65806. */
  65807. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65808. }
  65809. /**
  65810. * Class representing spherical polynomial coefficients to the 3rd degree
  65811. */
  65812. export class SphericalPolynomial {
  65813. private _harmonics;
  65814. /**
  65815. * The spherical harmonics used to create the polynomials.
  65816. */
  65817. readonly preScaledHarmonics: SphericalHarmonics;
  65818. /**
  65819. * The x coefficients of the spherical polynomial
  65820. */
  65821. x: Vector3;
  65822. /**
  65823. * The y coefficients of the spherical polynomial
  65824. */
  65825. y: Vector3;
  65826. /**
  65827. * The z coefficients of the spherical polynomial
  65828. */
  65829. z: Vector3;
  65830. /**
  65831. * The xx coefficients of the spherical polynomial
  65832. */
  65833. xx: Vector3;
  65834. /**
  65835. * The yy coefficients of the spherical polynomial
  65836. */
  65837. yy: Vector3;
  65838. /**
  65839. * The zz coefficients of the spherical polynomial
  65840. */
  65841. zz: Vector3;
  65842. /**
  65843. * The xy coefficients of the spherical polynomial
  65844. */
  65845. xy: Vector3;
  65846. /**
  65847. * The yz coefficients of the spherical polynomial
  65848. */
  65849. yz: Vector3;
  65850. /**
  65851. * The zx coefficients of the spherical polynomial
  65852. */
  65853. zx: Vector3;
  65854. /**
  65855. * Adds an ambient color to the spherical polynomial
  65856. * @param color the color to add
  65857. */
  65858. addAmbient(color: Color3): void;
  65859. /**
  65860. * Scales the spherical polynomial by the given amount
  65861. * @param scale the amount to scale
  65862. */
  65863. scaleInPlace(scale: number): void;
  65864. /**
  65865. * Gets the spherical polynomial from harmonics
  65866. * @param harmonics the spherical harmonics
  65867. * @returns the spherical polynomial
  65868. */
  65869. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65870. /**
  65871. * Constructs a spherical polynomial from an array.
  65872. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65873. * @returns the spherical polynomial
  65874. */
  65875. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65876. }
  65877. }
  65878. declare module BABYLON {
  65879. /**
  65880. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65881. */
  65882. export interface CubeMapInfo {
  65883. /**
  65884. * The pixel array for the front face.
  65885. * This is stored in format, left to right, up to down format.
  65886. */
  65887. front: Nullable<ArrayBufferView>;
  65888. /**
  65889. * The pixel array for the back face.
  65890. * This is stored in format, left to right, up to down format.
  65891. */
  65892. back: Nullable<ArrayBufferView>;
  65893. /**
  65894. * The pixel array for the left face.
  65895. * This is stored in format, left to right, up to down format.
  65896. */
  65897. left: Nullable<ArrayBufferView>;
  65898. /**
  65899. * The pixel array for the right face.
  65900. * This is stored in format, left to right, up to down format.
  65901. */
  65902. right: Nullable<ArrayBufferView>;
  65903. /**
  65904. * The pixel array for the up face.
  65905. * This is stored in format, left to right, up to down format.
  65906. */
  65907. up: Nullable<ArrayBufferView>;
  65908. /**
  65909. * The pixel array for the down face.
  65910. * This is stored in format, left to right, up to down format.
  65911. */
  65912. down: Nullable<ArrayBufferView>;
  65913. /**
  65914. * The size of the cubemap stored.
  65915. *
  65916. * Each faces will be size * size pixels.
  65917. */
  65918. size: number;
  65919. /**
  65920. * The format of the texture.
  65921. *
  65922. * RGBA, RGB.
  65923. */
  65924. format: number;
  65925. /**
  65926. * The type of the texture data.
  65927. *
  65928. * UNSIGNED_INT, FLOAT.
  65929. */
  65930. type: number;
  65931. /**
  65932. * Specifies whether the texture is in gamma space.
  65933. */
  65934. gammaSpace: boolean;
  65935. }
  65936. /**
  65937. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65938. */
  65939. export class PanoramaToCubeMapTools {
  65940. private static FACE_FRONT;
  65941. private static FACE_BACK;
  65942. private static FACE_RIGHT;
  65943. private static FACE_LEFT;
  65944. private static FACE_DOWN;
  65945. private static FACE_UP;
  65946. /**
  65947. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65948. *
  65949. * @param float32Array The source data.
  65950. * @param inputWidth The width of the input panorama.
  65951. * @param inputHeight The height of the input panorama.
  65952. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65953. * @return The cubemap data
  65954. */
  65955. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65956. private static CreateCubemapTexture;
  65957. private static CalcProjectionSpherical;
  65958. }
  65959. }
  65960. declare module BABYLON {
  65961. /**
  65962. * Helper class dealing with the extraction of spherical polynomial dataArray
  65963. * from a cube map.
  65964. */
  65965. export class CubeMapToSphericalPolynomialTools {
  65966. private static FileFaces;
  65967. /**
  65968. * Converts a texture to the according Spherical Polynomial data.
  65969. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65970. *
  65971. * @param texture The texture to extract the information from.
  65972. * @return The Spherical Polynomial data.
  65973. */
  65974. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65975. /**
  65976. * Converts a cubemap to the according Spherical Polynomial data.
  65977. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65978. *
  65979. * @param cubeInfo The Cube map to extract the information from.
  65980. * @return The Spherical Polynomial data.
  65981. */
  65982. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65983. }
  65984. }
  65985. declare module BABYLON {
  65986. /**
  65987. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65988. * during the life time of the application.
  65989. */
  65990. export class EngineStore {
  65991. /** Gets the list of created engines */
  65992. static Instances: Engine[];
  65993. /**
  65994. * Gets the latest created engine
  65995. */
  65996. static readonly LastCreatedEngine: Nullable<Engine>;
  65997. /**
  65998. * Gets the latest created scene
  65999. */
  66000. static readonly LastCreatedScene: Nullable<Scene>;
  66001. }
  66002. }
  66003. declare module BABYLON {
  66004. /**
  66005. * Define options used to create a render target texture
  66006. */
  66007. export class RenderTargetCreationOptions {
  66008. /**
  66009. * Specifies is mipmaps must be generated
  66010. */
  66011. generateMipMaps?: boolean;
  66012. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66013. generateDepthBuffer?: boolean;
  66014. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66015. generateStencilBuffer?: boolean;
  66016. /** Defines texture type (int by default) */
  66017. type?: number;
  66018. /** Defines sampling mode (trilinear by default) */
  66019. samplingMode?: number;
  66020. /** Defines format (RGBA by default) */
  66021. format?: number;
  66022. }
  66023. }
  66024. declare module BABYLON {
  66025. /**
  66026. * @hidden
  66027. **/
  66028. export class _AlphaState {
  66029. private _isAlphaBlendDirty;
  66030. private _isBlendFunctionParametersDirty;
  66031. private _isBlendEquationParametersDirty;
  66032. private _isBlendConstantsDirty;
  66033. private _alphaBlend;
  66034. private _blendFunctionParameters;
  66035. private _blendEquationParameters;
  66036. private _blendConstants;
  66037. /**
  66038. * Initializes the state.
  66039. */
  66040. constructor();
  66041. readonly isDirty: boolean;
  66042. alphaBlend: boolean;
  66043. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66044. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66045. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66046. reset(): void;
  66047. apply(gl: WebGLRenderingContext): void;
  66048. }
  66049. }
  66050. declare module BABYLON {
  66051. /**
  66052. * @hidden
  66053. **/
  66054. export class _DepthCullingState {
  66055. private _isDepthTestDirty;
  66056. private _isDepthMaskDirty;
  66057. private _isDepthFuncDirty;
  66058. private _isCullFaceDirty;
  66059. private _isCullDirty;
  66060. private _isZOffsetDirty;
  66061. private _isFrontFaceDirty;
  66062. private _depthTest;
  66063. private _depthMask;
  66064. private _depthFunc;
  66065. private _cull;
  66066. private _cullFace;
  66067. private _zOffset;
  66068. private _frontFace;
  66069. /**
  66070. * Initializes the state.
  66071. */
  66072. constructor();
  66073. readonly isDirty: boolean;
  66074. zOffset: number;
  66075. cullFace: Nullable<number>;
  66076. cull: Nullable<boolean>;
  66077. depthFunc: Nullable<number>;
  66078. depthMask: boolean;
  66079. depthTest: boolean;
  66080. frontFace: Nullable<number>;
  66081. reset(): void;
  66082. apply(gl: WebGLRenderingContext): void;
  66083. }
  66084. }
  66085. declare module BABYLON {
  66086. /**
  66087. * @hidden
  66088. **/
  66089. export class _StencilState {
  66090. /** 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 */
  66091. static readonly ALWAYS: number;
  66092. /** Passed to stencilOperation to specify that stencil value must be kept */
  66093. static readonly KEEP: number;
  66094. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66095. static readonly REPLACE: number;
  66096. private _isStencilTestDirty;
  66097. private _isStencilMaskDirty;
  66098. private _isStencilFuncDirty;
  66099. private _isStencilOpDirty;
  66100. private _stencilTest;
  66101. private _stencilMask;
  66102. private _stencilFunc;
  66103. private _stencilFuncRef;
  66104. private _stencilFuncMask;
  66105. private _stencilOpStencilFail;
  66106. private _stencilOpDepthFail;
  66107. private _stencilOpStencilDepthPass;
  66108. readonly isDirty: boolean;
  66109. stencilFunc: number;
  66110. stencilFuncRef: number;
  66111. stencilFuncMask: number;
  66112. stencilOpStencilFail: number;
  66113. stencilOpDepthFail: number;
  66114. stencilOpStencilDepthPass: number;
  66115. stencilMask: number;
  66116. stencilTest: boolean;
  66117. constructor();
  66118. reset(): void;
  66119. apply(gl: WebGLRenderingContext): void;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * @hidden
  66125. **/
  66126. export class _TimeToken {
  66127. _startTimeQuery: Nullable<WebGLQuery>;
  66128. _endTimeQuery: Nullable<WebGLQuery>;
  66129. _timeElapsedQuery: Nullable<WebGLQuery>;
  66130. _timeElapsedQueryEnded: boolean;
  66131. }
  66132. }
  66133. declare module BABYLON {
  66134. /**
  66135. * Class used to store data associated with WebGL texture data for the engine
  66136. * This class should not be used directly
  66137. */
  66138. export class InternalTexture {
  66139. /** hidden */
  66140. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66141. /**
  66142. * The source of the texture data is unknown
  66143. */
  66144. static DATASOURCE_UNKNOWN: number;
  66145. /**
  66146. * Texture data comes from an URL
  66147. */
  66148. static DATASOURCE_URL: number;
  66149. /**
  66150. * Texture data is only used for temporary storage
  66151. */
  66152. static DATASOURCE_TEMP: number;
  66153. /**
  66154. * Texture data comes from raw data (ArrayBuffer)
  66155. */
  66156. static DATASOURCE_RAW: number;
  66157. /**
  66158. * Texture content is dynamic (video or dynamic texture)
  66159. */
  66160. static DATASOURCE_DYNAMIC: number;
  66161. /**
  66162. * Texture content is generated by rendering to it
  66163. */
  66164. static DATASOURCE_RENDERTARGET: number;
  66165. /**
  66166. * Texture content is part of a multi render target process
  66167. */
  66168. static DATASOURCE_MULTIRENDERTARGET: number;
  66169. /**
  66170. * Texture data comes from a cube data file
  66171. */
  66172. static DATASOURCE_CUBE: number;
  66173. /**
  66174. * Texture data comes from a raw cube data
  66175. */
  66176. static DATASOURCE_CUBERAW: number;
  66177. /**
  66178. * Texture data come from a prefiltered cube data file
  66179. */
  66180. static DATASOURCE_CUBEPREFILTERED: number;
  66181. /**
  66182. * Texture content is raw 3D data
  66183. */
  66184. static DATASOURCE_RAW3D: number;
  66185. /**
  66186. * Texture content is a depth texture
  66187. */
  66188. static DATASOURCE_DEPTHTEXTURE: number;
  66189. /**
  66190. * Texture data comes from a raw cube data encoded with RGBD
  66191. */
  66192. static DATASOURCE_CUBERAW_RGBD: number;
  66193. /**
  66194. * Defines if the texture is ready
  66195. */
  66196. isReady: boolean;
  66197. /**
  66198. * Defines if the texture is a cube texture
  66199. */
  66200. isCube: boolean;
  66201. /**
  66202. * Defines if the texture contains 3D data
  66203. */
  66204. is3D: boolean;
  66205. /**
  66206. * Defines if the texture contains multiview data
  66207. */
  66208. isMultiview: boolean;
  66209. /**
  66210. * Gets the URL used to load this texture
  66211. */
  66212. url: string;
  66213. /**
  66214. * Gets the sampling mode of the texture
  66215. */
  66216. samplingMode: number;
  66217. /**
  66218. * Gets a boolean indicating if the texture needs mipmaps generation
  66219. */
  66220. generateMipMaps: boolean;
  66221. /**
  66222. * Gets the number of samples used by the texture (WebGL2+ only)
  66223. */
  66224. samples: number;
  66225. /**
  66226. * Gets the type of the texture (int, float...)
  66227. */
  66228. type: number;
  66229. /**
  66230. * Gets the format of the texture (RGB, RGBA...)
  66231. */
  66232. format: number;
  66233. /**
  66234. * Observable called when the texture is loaded
  66235. */
  66236. onLoadedObservable: Observable<InternalTexture>;
  66237. /**
  66238. * Gets the width of the texture
  66239. */
  66240. width: number;
  66241. /**
  66242. * Gets the height of the texture
  66243. */
  66244. height: number;
  66245. /**
  66246. * Gets the depth of the texture
  66247. */
  66248. depth: number;
  66249. /**
  66250. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66251. */
  66252. baseWidth: number;
  66253. /**
  66254. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66255. */
  66256. baseHeight: number;
  66257. /**
  66258. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66259. */
  66260. baseDepth: number;
  66261. /**
  66262. * Gets a boolean indicating if the texture is inverted on Y axis
  66263. */
  66264. invertY: boolean;
  66265. /** @hidden */
  66266. _invertVScale: boolean;
  66267. /** @hidden */
  66268. _associatedChannel: number;
  66269. /** @hidden */
  66270. _dataSource: number;
  66271. /** @hidden */
  66272. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66273. /** @hidden */
  66274. _bufferView: Nullable<ArrayBufferView>;
  66275. /** @hidden */
  66276. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66277. /** @hidden */
  66278. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66279. /** @hidden */
  66280. _size: number;
  66281. /** @hidden */
  66282. _extension: string;
  66283. /** @hidden */
  66284. _files: Nullable<string[]>;
  66285. /** @hidden */
  66286. _workingCanvas: Nullable<HTMLCanvasElement>;
  66287. /** @hidden */
  66288. _workingContext: Nullable<CanvasRenderingContext2D>;
  66289. /** @hidden */
  66290. _framebuffer: Nullable<WebGLFramebuffer>;
  66291. /** @hidden */
  66292. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66293. /** @hidden */
  66294. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66295. /** @hidden */
  66296. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66297. /** @hidden */
  66298. _attachments: Nullable<number[]>;
  66299. /** @hidden */
  66300. _cachedCoordinatesMode: Nullable<number>;
  66301. /** @hidden */
  66302. _cachedWrapU: Nullable<number>;
  66303. /** @hidden */
  66304. _cachedWrapV: Nullable<number>;
  66305. /** @hidden */
  66306. _cachedWrapR: Nullable<number>;
  66307. /** @hidden */
  66308. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66309. /** @hidden */
  66310. _isDisabled: boolean;
  66311. /** @hidden */
  66312. _compression: Nullable<string>;
  66313. /** @hidden */
  66314. _generateStencilBuffer: boolean;
  66315. /** @hidden */
  66316. _generateDepthBuffer: boolean;
  66317. /** @hidden */
  66318. _comparisonFunction: number;
  66319. /** @hidden */
  66320. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66321. /** @hidden */
  66322. _lodGenerationScale: number;
  66323. /** @hidden */
  66324. _lodGenerationOffset: number;
  66325. /** @hidden */
  66326. _colorTextureArray: Nullable<WebGLTexture>;
  66327. /** @hidden */
  66328. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66329. /** @hidden */
  66330. _lodTextureHigh: Nullable<BaseTexture>;
  66331. /** @hidden */
  66332. _lodTextureMid: Nullable<BaseTexture>;
  66333. /** @hidden */
  66334. _lodTextureLow: Nullable<BaseTexture>;
  66335. /** @hidden */
  66336. _isRGBD: boolean;
  66337. /** @hidden */
  66338. _webGLTexture: Nullable<WebGLTexture>;
  66339. /** @hidden */
  66340. _references: number;
  66341. private _engine;
  66342. /**
  66343. * Gets the Engine the texture belongs to.
  66344. * @returns The babylon engine
  66345. */
  66346. getEngine(): Engine;
  66347. /**
  66348. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66349. */
  66350. readonly dataSource: number;
  66351. /**
  66352. * Creates a new InternalTexture
  66353. * @param engine defines the engine to use
  66354. * @param dataSource defines the type of data that will be used
  66355. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66356. */
  66357. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66358. /**
  66359. * Increments the number of references (ie. the number of Texture that point to it)
  66360. */
  66361. incrementReferences(): void;
  66362. /**
  66363. * Change the size of the texture (not the size of the content)
  66364. * @param width defines the new width
  66365. * @param height defines the new height
  66366. * @param depth defines the new depth (1 by default)
  66367. */
  66368. updateSize(width: int, height: int, depth?: int): void;
  66369. /** @hidden */
  66370. _rebuild(): void;
  66371. /** @hidden */
  66372. _swapAndDie(target: InternalTexture): void;
  66373. /**
  66374. * Dispose the current allocated resources
  66375. */
  66376. dispose(): void;
  66377. }
  66378. }
  66379. declare module BABYLON {
  66380. /**
  66381. * This represents the main contract an easing function should follow.
  66382. * Easing functions are used throughout the animation system.
  66383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66384. */
  66385. export interface IEasingFunction {
  66386. /**
  66387. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66388. * of the easing function.
  66389. * The link below provides some of the most common examples of easing functions.
  66390. * @see https://easings.net/
  66391. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66392. * @returns the corresponding value on the curve defined by the easing function
  66393. */
  66394. ease(gradient: number): number;
  66395. }
  66396. /**
  66397. * Base class used for every default easing function.
  66398. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66399. */
  66400. export class EasingFunction implements IEasingFunction {
  66401. /**
  66402. * Interpolation follows the mathematical formula associated with the easing function.
  66403. */
  66404. static readonly EASINGMODE_EASEIN: number;
  66405. /**
  66406. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66407. */
  66408. static readonly EASINGMODE_EASEOUT: number;
  66409. /**
  66410. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66411. */
  66412. static readonly EASINGMODE_EASEINOUT: number;
  66413. private _easingMode;
  66414. /**
  66415. * Sets the easing mode of the current function.
  66416. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66417. */
  66418. setEasingMode(easingMode: number): void;
  66419. /**
  66420. * Gets the current easing mode.
  66421. * @returns the easing mode
  66422. */
  66423. getEasingMode(): number;
  66424. /**
  66425. * @hidden
  66426. */
  66427. easeInCore(gradient: number): number;
  66428. /**
  66429. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66430. * of the easing function.
  66431. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66432. * @returns the corresponding value on the curve defined by the easing function
  66433. */
  66434. ease(gradient: number): number;
  66435. }
  66436. /**
  66437. * Easing function with a circle shape (see link below).
  66438. * @see https://easings.net/#easeInCirc
  66439. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66440. */
  66441. export class CircleEase extends EasingFunction implements IEasingFunction {
  66442. /** @hidden */
  66443. easeInCore(gradient: number): number;
  66444. }
  66445. /**
  66446. * Easing function with a ease back shape (see link below).
  66447. * @see https://easings.net/#easeInBack
  66448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66449. */
  66450. export class BackEase extends EasingFunction implements IEasingFunction {
  66451. /** Defines the amplitude of the function */
  66452. amplitude: number;
  66453. /**
  66454. * Instantiates a back ease easing
  66455. * @see https://easings.net/#easeInBack
  66456. * @param amplitude Defines the amplitude of the function
  66457. */
  66458. constructor(
  66459. /** Defines the amplitude of the function */
  66460. amplitude?: number);
  66461. /** @hidden */
  66462. easeInCore(gradient: number): number;
  66463. }
  66464. /**
  66465. * Easing function with a bouncing shape (see link below).
  66466. * @see https://easings.net/#easeInBounce
  66467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66468. */
  66469. export class BounceEase extends EasingFunction implements IEasingFunction {
  66470. /** Defines the number of bounces */
  66471. bounces: number;
  66472. /** Defines the amplitude of the bounce */
  66473. bounciness: number;
  66474. /**
  66475. * Instantiates a bounce easing
  66476. * @see https://easings.net/#easeInBounce
  66477. * @param bounces Defines the number of bounces
  66478. * @param bounciness Defines the amplitude of the bounce
  66479. */
  66480. constructor(
  66481. /** Defines the number of bounces */
  66482. bounces?: number,
  66483. /** Defines the amplitude of the bounce */
  66484. bounciness?: number);
  66485. /** @hidden */
  66486. easeInCore(gradient: number): number;
  66487. }
  66488. /**
  66489. * Easing function with a power of 3 shape (see link below).
  66490. * @see https://easings.net/#easeInCubic
  66491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66492. */
  66493. export class CubicEase extends EasingFunction implements IEasingFunction {
  66494. /** @hidden */
  66495. easeInCore(gradient: number): number;
  66496. }
  66497. /**
  66498. * Easing function with an elastic shape (see link below).
  66499. * @see https://easings.net/#easeInElastic
  66500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66501. */
  66502. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66503. /** Defines the number of oscillations*/
  66504. oscillations: number;
  66505. /** Defines the amplitude of the oscillations*/
  66506. springiness: number;
  66507. /**
  66508. * Instantiates an elastic easing function
  66509. * @see https://easings.net/#easeInElastic
  66510. * @param oscillations Defines the number of oscillations
  66511. * @param springiness Defines the amplitude of the oscillations
  66512. */
  66513. constructor(
  66514. /** Defines the number of oscillations*/
  66515. oscillations?: number,
  66516. /** Defines the amplitude of the oscillations*/
  66517. springiness?: number);
  66518. /** @hidden */
  66519. easeInCore(gradient: number): number;
  66520. }
  66521. /**
  66522. * Easing function with an exponential shape (see link below).
  66523. * @see https://easings.net/#easeInExpo
  66524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66525. */
  66526. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66527. /** Defines the exponent of the function */
  66528. exponent: number;
  66529. /**
  66530. * Instantiates an exponential easing function
  66531. * @see https://easings.net/#easeInExpo
  66532. * @param exponent Defines the exponent of the function
  66533. */
  66534. constructor(
  66535. /** Defines the exponent of the function */
  66536. exponent?: number);
  66537. /** @hidden */
  66538. easeInCore(gradient: number): number;
  66539. }
  66540. /**
  66541. * Easing function with a power shape (see link below).
  66542. * @see https://easings.net/#easeInQuad
  66543. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66544. */
  66545. export class PowerEase extends EasingFunction implements IEasingFunction {
  66546. /** Defines the power of the function */
  66547. power: number;
  66548. /**
  66549. * Instantiates an power base easing function
  66550. * @see https://easings.net/#easeInQuad
  66551. * @param power Defines the power of the function
  66552. */
  66553. constructor(
  66554. /** Defines the power of the function */
  66555. power?: number);
  66556. /** @hidden */
  66557. easeInCore(gradient: number): number;
  66558. }
  66559. /**
  66560. * Easing function with a power of 2 shape (see link below).
  66561. * @see https://easings.net/#easeInQuad
  66562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66563. */
  66564. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66565. /** @hidden */
  66566. easeInCore(gradient: number): number;
  66567. }
  66568. /**
  66569. * Easing function with a power of 4 shape (see link below).
  66570. * @see https://easings.net/#easeInQuart
  66571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66572. */
  66573. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66574. /** @hidden */
  66575. easeInCore(gradient: number): number;
  66576. }
  66577. /**
  66578. * Easing function with a power of 5 shape (see link below).
  66579. * @see https://easings.net/#easeInQuint
  66580. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66581. */
  66582. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66583. /** @hidden */
  66584. easeInCore(gradient: number): number;
  66585. }
  66586. /**
  66587. * Easing function with a sin shape (see link below).
  66588. * @see https://easings.net/#easeInSine
  66589. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66590. */
  66591. export class SineEase extends EasingFunction implements IEasingFunction {
  66592. /** @hidden */
  66593. easeInCore(gradient: number): number;
  66594. }
  66595. /**
  66596. * Easing function with a bezier shape (see link below).
  66597. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66598. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66599. */
  66600. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66601. /** Defines the x component of the start tangent in the bezier curve */
  66602. x1: number;
  66603. /** Defines the y component of the start tangent in the bezier curve */
  66604. y1: number;
  66605. /** Defines the x component of the end tangent in the bezier curve */
  66606. x2: number;
  66607. /** Defines the y component of the end tangent in the bezier curve */
  66608. y2: number;
  66609. /**
  66610. * Instantiates a bezier function
  66611. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66612. * @param x1 Defines the x component of the start tangent in the bezier curve
  66613. * @param y1 Defines the y component of the start tangent in the bezier curve
  66614. * @param x2 Defines the x component of the end tangent in the bezier curve
  66615. * @param y2 Defines the y component of the end tangent in the bezier curve
  66616. */
  66617. constructor(
  66618. /** Defines the x component of the start tangent in the bezier curve */
  66619. x1?: number,
  66620. /** Defines the y component of the start tangent in the bezier curve */
  66621. y1?: number,
  66622. /** Defines the x component of the end tangent in the bezier curve */
  66623. x2?: number,
  66624. /** Defines the y component of the end tangent in the bezier curve */
  66625. y2?: number);
  66626. /** @hidden */
  66627. easeInCore(gradient: number): number;
  66628. }
  66629. }
  66630. declare module BABYLON {
  66631. /**
  66632. * Defines an interface which represents an animation key frame
  66633. */
  66634. export interface IAnimationKey {
  66635. /**
  66636. * Frame of the key frame
  66637. */
  66638. frame: number;
  66639. /**
  66640. * Value at the specifies key frame
  66641. */
  66642. value: any;
  66643. /**
  66644. * The input tangent for the cubic hermite spline
  66645. */
  66646. inTangent?: any;
  66647. /**
  66648. * The output tangent for the cubic hermite spline
  66649. */
  66650. outTangent?: any;
  66651. /**
  66652. * The animation interpolation type
  66653. */
  66654. interpolation?: AnimationKeyInterpolation;
  66655. }
  66656. /**
  66657. * Enum for the animation key frame interpolation type
  66658. */
  66659. export enum AnimationKeyInterpolation {
  66660. /**
  66661. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66662. */
  66663. STEP = 1
  66664. }
  66665. }
  66666. declare module BABYLON {
  66667. /**
  66668. * Represents the range of an animation
  66669. */
  66670. export class AnimationRange {
  66671. /**The name of the animation range**/
  66672. name: string;
  66673. /**The starting frame of the animation */
  66674. from: number;
  66675. /**The ending frame of the animation*/
  66676. to: number;
  66677. /**
  66678. * Initializes the range of an animation
  66679. * @param name The name of the animation range
  66680. * @param from The starting frame of the animation
  66681. * @param to The ending frame of the animation
  66682. */
  66683. constructor(
  66684. /**The name of the animation range**/
  66685. name: string,
  66686. /**The starting frame of the animation */
  66687. from: number,
  66688. /**The ending frame of the animation*/
  66689. to: number);
  66690. /**
  66691. * Makes a copy of the animation range
  66692. * @returns A copy of the animation range
  66693. */
  66694. clone(): AnimationRange;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /**
  66699. * Composed of a frame, and an action function
  66700. */
  66701. export class AnimationEvent {
  66702. /** The frame for which the event is triggered **/
  66703. frame: number;
  66704. /** The event to perform when triggered **/
  66705. action: (currentFrame: number) => void;
  66706. /** Specifies if the event should be triggered only once**/
  66707. onlyOnce?: boolean | undefined;
  66708. /**
  66709. * Specifies if the animation event is done
  66710. */
  66711. isDone: boolean;
  66712. /**
  66713. * Initializes the animation event
  66714. * @param frame The frame for which the event is triggered
  66715. * @param action The event to perform when triggered
  66716. * @param onlyOnce Specifies if the event should be triggered only once
  66717. */
  66718. constructor(
  66719. /** The frame for which the event is triggered **/
  66720. frame: number,
  66721. /** The event to perform when triggered **/
  66722. action: (currentFrame: number) => void,
  66723. /** Specifies if the event should be triggered only once**/
  66724. onlyOnce?: boolean | undefined);
  66725. /** @hidden */
  66726. _clone(): AnimationEvent;
  66727. }
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * Interface used to define a behavior
  66732. */
  66733. export interface Behavior<T> {
  66734. /** gets or sets behavior's name */
  66735. name: string;
  66736. /**
  66737. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66738. */
  66739. init(): void;
  66740. /**
  66741. * Called when the behavior is attached to a target
  66742. * @param target defines the target where the behavior is attached to
  66743. */
  66744. attach(target: T): void;
  66745. /**
  66746. * Called when the behavior is detached from its target
  66747. */
  66748. detach(): void;
  66749. }
  66750. /**
  66751. * Interface implemented by classes supporting behaviors
  66752. */
  66753. export interface IBehaviorAware<T> {
  66754. /**
  66755. * Attach a behavior
  66756. * @param behavior defines the behavior to attach
  66757. * @returns the current host
  66758. */
  66759. addBehavior(behavior: Behavior<T>): T;
  66760. /**
  66761. * Remove a behavior from the current object
  66762. * @param behavior defines the behavior to detach
  66763. * @returns the current host
  66764. */
  66765. removeBehavior(behavior: Behavior<T>): T;
  66766. /**
  66767. * Gets a behavior using its name to search
  66768. * @param name defines the name to search
  66769. * @returns the behavior or null if not found
  66770. */
  66771. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66772. }
  66773. }
  66774. declare module BABYLON {
  66775. /**
  66776. * @hidden
  66777. */
  66778. export class IntersectionInfo {
  66779. bu: Nullable<number>;
  66780. bv: Nullable<number>;
  66781. distance: number;
  66782. faceId: number;
  66783. subMeshId: number;
  66784. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66785. }
  66786. }
  66787. declare module BABYLON {
  66788. /**
  66789. * Class used to store bounding sphere information
  66790. */
  66791. export class BoundingSphere {
  66792. /**
  66793. * Gets the center of the bounding sphere in local space
  66794. */
  66795. readonly center: Vector3;
  66796. /**
  66797. * Radius of the bounding sphere in local space
  66798. */
  66799. radius: number;
  66800. /**
  66801. * Gets the center of the bounding sphere in world space
  66802. */
  66803. readonly centerWorld: Vector3;
  66804. /**
  66805. * Radius of the bounding sphere in world space
  66806. */
  66807. radiusWorld: number;
  66808. /**
  66809. * Gets the minimum vector in local space
  66810. */
  66811. readonly minimum: Vector3;
  66812. /**
  66813. * Gets the maximum vector in local space
  66814. */
  66815. readonly maximum: Vector3;
  66816. private _worldMatrix;
  66817. private static readonly TmpVector3;
  66818. /**
  66819. * Creates a new bounding sphere
  66820. * @param min defines the minimum vector (in local space)
  66821. * @param max defines the maximum vector (in local space)
  66822. * @param worldMatrix defines the new world matrix
  66823. */
  66824. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66825. /**
  66826. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66827. * @param min defines the new minimum vector (in local space)
  66828. * @param max defines the new maximum vector (in local space)
  66829. * @param worldMatrix defines the new world matrix
  66830. */
  66831. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66832. /**
  66833. * Scale the current bounding sphere by applying a scale factor
  66834. * @param factor defines the scale factor to apply
  66835. * @returns the current bounding box
  66836. */
  66837. scale(factor: number): BoundingSphere;
  66838. /**
  66839. * Gets the world matrix of the bounding box
  66840. * @returns a matrix
  66841. */
  66842. getWorldMatrix(): DeepImmutable<Matrix>;
  66843. /** @hidden */
  66844. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66845. /**
  66846. * Tests if the bounding sphere is intersecting the frustum planes
  66847. * @param frustumPlanes defines the frustum planes to test
  66848. * @returns true if there is an intersection
  66849. */
  66850. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66851. /**
  66852. * Tests if the bounding sphere center is in between the frustum planes.
  66853. * Used for optimistic fast inclusion.
  66854. * @param frustumPlanes defines the frustum planes to test
  66855. * @returns true if the sphere center is in between the frustum planes
  66856. */
  66857. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66858. /**
  66859. * Tests if a point is inside the bounding sphere
  66860. * @param point defines the point to test
  66861. * @returns true if the point is inside the bounding sphere
  66862. */
  66863. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66864. /**
  66865. * Checks if two sphere intersct
  66866. * @param sphere0 sphere 0
  66867. * @param sphere1 sphere 1
  66868. * @returns true if the speres intersect
  66869. */
  66870. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66871. }
  66872. }
  66873. declare module BABYLON {
  66874. /**
  66875. * Class used to store bounding box information
  66876. */
  66877. export class BoundingBox implements ICullable {
  66878. /**
  66879. * Gets the 8 vectors representing the bounding box in local space
  66880. */
  66881. readonly vectors: Vector3[];
  66882. /**
  66883. * Gets the center of the bounding box in local space
  66884. */
  66885. readonly center: Vector3;
  66886. /**
  66887. * Gets the center of the bounding box in world space
  66888. */
  66889. readonly centerWorld: Vector3;
  66890. /**
  66891. * Gets the extend size in local space
  66892. */
  66893. readonly extendSize: Vector3;
  66894. /**
  66895. * Gets the extend size in world space
  66896. */
  66897. readonly extendSizeWorld: Vector3;
  66898. /**
  66899. * Gets the OBB (object bounding box) directions
  66900. */
  66901. readonly directions: Vector3[];
  66902. /**
  66903. * Gets the 8 vectors representing the bounding box in world space
  66904. */
  66905. readonly vectorsWorld: Vector3[];
  66906. /**
  66907. * Gets the minimum vector in world space
  66908. */
  66909. readonly minimumWorld: Vector3;
  66910. /**
  66911. * Gets the maximum vector in world space
  66912. */
  66913. readonly maximumWorld: Vector3;
  66914. /**
  66915. * Gets the minimum vector in local space
  66916. */
  66917. readonly minimum: Vector3;
  66918. /**
  66919. * Gets the maximum vector in local space
  66920. */
  66921. readonly maximum: Vector3;
  66922. private _worldMatrix;
  66923. private static readonly TmpVector3;
  66924. /**
  66925. * @hidden
  66926. */
  66927. _tag: number;
  66928. /**
  66929. * Creates a new bounding box
  66930. * @param min defines the minimum vector (in local space)
  66931. * @param max defines the maximum vector (in local space)
  66932. * @param worldMatrix defines the new world matrix
  66933. */
  66934. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66935. /**
  66936. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66937. * @param min defines the new minimum vector (in local space)
  66938. * @param max defines the new maximum vector (in local space)
  66939. * @param worldMatrix defines the new world matrix
  66940. */
  66941. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66942. /**
  66943. * Scale the current bounding box by applying a scale factor
  66944. * @param factor defines the scale factor to apply
  66945. * @returns the current bounding box
  66946. */
  66947. scale(factor: number): BoundingBox;
  66948. /**
  66949. * Gets the world matrix of the bounding box
  66950. * @returns a matrix
  66951. */
  66952. getWorldMatrix(): DeepImmutable<Matrix>;
  66953. /** @hidden */
  66954. _update(world: DeepImmutable<Matrix>): void;
  66955. /**
  66956. * Tests if the bounding box is intersecting the frustum planes
  66957. * @param frustumPlanes defines the frustum planes to test
  66958. * @returns true if there is an intersection
  66959. */
  66960. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66961. /**
  66962. * Tests if the bounding box is entirely inside the frustum planes
  66963. * @param frustumPlanes defines the frustum planes to test
  66964. * @returns true if there is an inclusion
  66965. */
  66966. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66967. /**
  66968. * Tests if a point is inside the bounding box
  66969. * @param point defines the point to test
  66970. * @returns true if the point is inside the bounding box
  66971. */
  66972. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66973. /**
  66974. * Tests if the bounding box intersects with a bounding sphere
  66975. * @param sphere defines the sphere to test
  66976. * @returns true if there is an intersection
  66977. */
  66978. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66979. /**
  66980. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66981. * @param min defines the min vector to use
  66982. * @param max defines the max vector to use
  66983. * @returns true if there is an intersection
  66984. */
  66985. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66986. /**
  66987. * Tests if two bounding boxes are intersections
  66988. * @param box0 defines the first box to test
  66989. * @param box1 defines the second box to test
  66990. * @returns true if there is an intersection
  66991. */
  66992. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66993. /**
  66994. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66995. * @param minPoint defines the minimum vector of the bounding box
  66996. * @param maxPoint defines the maximum vector of the bounding box
  66997. * @param sphereCenter defines the sphere center
  66998. * @param sphereRadius defines the sphere radius
  66999. * @returns true if there is an intersection
  67000. */
  67001. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67002. /**
  67003. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67004. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67005. * @param frustumPlanes defines the frustum planes to test
  67006. * @return true if there is an inclusion
  67007. */
  67008. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67009. /**
  67010. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67011. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67012. * @param frustumPlanes defines the frustum planes to test
  67013. * @return true if there is an intersection
  67014. */
  67015. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67016. }
  67017. }
  67018. declare module BABYLON {
  67019. /** @hidden */
  67020. export class Collider {
  67021. /** Define if a collision was found */
  67022. collisionFound: boolean;
  67023. /**
  67024. * Define last intersection point in local space
  67025. */
  67026. intersectionPoint: Vector3;
  67027. /**
  67028. * Define last collided mesh
  67029. */
  67030. collidedMesh: Nullable<AbstractMesh>;
  67031. private _collisionPoint;
  67032. private _planeIntersectionPoint;
  67033. private _tempVector;
  67034. private _tempVector2;
  67035. private _tempVector3;
  67036. private _tempVector4;
  67037. private _edge;
  67038. private _baseToVertex;
  67039. private _destinationPoint;
  67040. private _slidePlaneNormal;
  67041. private _displacementVector;
  67042. /** @hidden */
  67043. _radius: Vector3;
  67044. /** @hidden */
  67045. _retry: number;
  67046. private _velocity;
  67047. private _basePoint;
  67048. private _epsilon;
  67049. /** @hidden */
  67050. _velocityWorldLength: number;
  67051. /** @hidden */
  67052. _basePointWorld: Vector3;
  67053. private _velocityWorld;
  67054. private _normalizedVelocity;
  67055. /** @hidden */
  67056. _initialVelocity: Vector3;
  67057. /** @hidden */
  67058. _initialPosition: Vector3;
  67059. private _nearestDistance;
  67060. private _collisionMask;
  67061. collisionMask: number;
  67062. /**
  67063. * Gets the plane normal used to compute the sliding response (in local space)
  67064. */
  67065. readonly slidePlaneNormal: Vector3;
  67066. /** @hidden */
  67067. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67068. /** @hidden */
  67069. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67070. /** @hidden */
  67071. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67072. /** @hidden */
  67073. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67074. /** @hidden */
  67075. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67076. /** @hidden */
  67077. _getResponse(pos: Vector3, vel: Vector3): void;
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /**
  67082. * Interface for cullable objects
  67083. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67084. */
  67085. export interface ICullable {
  67086. /**
  67087. * Checks if the object or part of the object is in the frustum
  67088. * @param frustumPlanes Camera near/planes
  67089. * @returns true if the object is in frustum otherwise false
  67090. */
  67091. isInFrustum(frustumPlanes: Plane[]): boolean;
  67092. /**
  67093. * Checks if a cullable object (mesh...) is in the camera frustum
  67094. * Unlike isInFrustum this cheks the full bounding box
  67095. * @param frustumPlanes Camera near/planes
  67096. * @returns true if the object is in frustum otherwise false
  67097. */
  67098. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67099. }
  67100. /**
  67101. * Info for a bounding data of a mesh
  67102. */
  67103. export class BoundingInfo implements ICullable {
  67104. /**
  67105. * Bounding box for the mesh
  67106. */
  67107. readonly boundingBox: BoundingBox;
  67108. /**
  67109. * Bounding sphere for the mesh
  67110. */
  67111. readonly boundingSphere: BoundingSphere;
  67112. private _isLocked;
  67113. private static readonly TmpVector3;
  67114. /**
  67115. * Constructs bounding info
  67116. * @param minimum min vector of the bounding box/sphere
  67117. * @param maximum max vector of the bounding box/sphere
  67118. * @param worldMatrix defines the new world matrix
  67119. */
  67120. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67121. /**
  67122. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67123. * @param min defines the new minimum vector (in local space)
  67124. * @param max defines the new maximum vector (in local space)
  67125. * @param worldMatrix defines the new world matrix
  67126. */
  67127. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67128. /**
  67129. * min vector of the bounding box/sphere
  67130. */
  67131. readonly minimum: Vector3;
  67132. /**
  67133. * max vector of the bounding box/sphere
  67134. */
  67135. readonly maximum: Vector3;
  67136. /**
  67137. * If the info is locked and won't be updated to avoid perf overhead
  67138. */
  67139. isLocked: boolean;
  67140. /**
  67141. * Updates the bounding sphere and box
  67142. * @param world world matrix to be used to update
  67143. */
  67144. update(world: DeepImmutable<Matrix>): void;
  67145. /**
  67146. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67147. * @param center New center of the bounding info
  67148. * @param extend New extend of the bounding info
  67149. * @returns the current bounding info
  67150. */
  67151. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67152. /**
  67153. * Scale the current bounding info by applying a scale factor
  67154. * @param factor defines the scale factor to apply
  67155. * @returns the current bounding info
  67156. */
  67157. scale(factor: number): BoundingInfo;
  67158. /**
  67159. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67160. * @param frustumPlanes defines the frustum to test
  67161. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67162. * @returns true if the bounding info is in the frustum planes
  67163. */
  67164. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67165. /**
  67166. * Gets the world distance between the min and max points of the bounding box
  67167. */
  67168. readonly diagonalLength: number;
  67169. /**
  67170. * Checks if a cullable object (mesh...) is in the camera frustum
  67171. * Unlike isInFrustum this cheks the full bounding box
  67172. * @param frustumPlanes Camera near/planes
  67173. * @returns true if the object is in frustum otherwise false
  67174. */
  67175. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67176. /** @hidden */
  67177. _checkCollision(collider: Collider): boolean;
  67178. /**
  67179. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67180. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67181. * @param point the point to check intersection with
  67182. * @returns if the point intersects
  67183. */
  67184. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67185. /**
  67186. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67187. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67188. * @param boundingInfo the bounding info to check intersection with
  67189. * @param precise if the intersection should be done using OBB
  67190. * @returns if the bounding info intersects
  67191. */
  67192. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67193. }
  67194. }
  67195. declare module BABYLON {
  67196. /**
  67197. * Defines an array and its length.
  67198. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67199. */
  67200. export interface ISmartArrayLike<T> {
  67201. /**
  67202. * The data of the array.
  67203. */
  67204. data: Array<T>;
  67205. /**
  67206. * The active length of the array.
  67207. */
  67208. length: number;
  67209. }
  67210. /**
  67211. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67212. */
  67213. export class SmartArray<T> implements ISmartArrayLike<T> {
  67214. /**
  67215. * The full set of data from the array.
  67216. */
  67217. data: Array<T>;
  67218. /**
  67219. * The active length of the array.
  67220. */
  67221. length: number;
  67222. protected _id: number;
  67223. /**
  67224. * Instantiates a Smart Array.
  67225. * @param capacity defines the default capacity of the array.
  67226. */
  67227. constructor(capacity: number);
  67228. /**
  67229. * Pushes a value at the end of the active data.
  67230. * @param value defines the object to push in the array.
  67231. */
  67232. push(value: T): void;
  67233. /**
  67234. * Iterates over the active data and apply the lambda to them.
  67235. * @param func defines the action to apply on each value.
  67236. */
  67237. forEach(func: (content: T) => void): void;
  67238. /**
  67239. * Sorts the full sets of data.
  67240. * @param compareFn defines the comparison function to apply.
  67241. */
  67242. sort(compareFn: (a: T, b: T) => number): void;
  67243. /**
  67244. * Resets the active data to an empty array.
  67245. */
  67246. reset(): void;
  67247. /**
  67248. * Releases all the data from the array as well as the array.
  67249. */
  67250. dispose(): void;
  67251. /**
  67252. * Concats the active data with a given array.
  67253. * @param array defines the data to concatenate with.
  67254. */
  67255. concat(array: any): void;
  67256. /**
  67257. * Returns the position of a value in the active data.
  67258. * @param value defines the value to find the index for
  67259. * @returns the index if found in the active data otherwise -1
  67260. */
  67261. indexOf(value: T): number;
  67262. /**
  67263. * Returns whether an element is part of the active data.
  67264. * @param value defines the value to look for
  67265. * @returns true if found in the active data otherwise false
  67266. */
  67267. contains(value: T): boolean;
  67268. private static _GlobalId;
  67269. }
  67270. /**
  67271. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67272. * The data in this array can only be present once
  67273. */
  67274. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67275. private _duplicateId;
  67276. /**
  67277. * Pushes a value at the end of the active data.
  67278. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67279. * @param value defines the object to push in the array.
  67280. */
  67281. push(value: T): void;
  67282. /**
  67283. * Pushes a value at the end of the active data.
  67284. * If the data is already present, it won t be added again
  67285. * @param value defines the object to push in the array.
  67286. * @returns true if added false if it was already present
  67287. */
  67288. pushNoDuplicate(value: T): boolean;
  67289. /**
  67290. * Resets the active data to an empty array.
  67291. */
  67292. reset(): void;
  67293. /**
  67294. * Concats the active data with a given array.
  67295. * This ensures no dupplicate will be present in the result.
  67296. * @param array defines the data to concatenate with.
  67297. */
  67298. concatWithNoDuplicate(array: any): void;
  67299. }
  67300. }
  67301. declare module BABYLON {
  67302. /**
  67303. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67304. * separate meshes. This can be use to improve performances.
  67305. * @see http://doc.babylonjs.com/how_to/multi_materials
  67306. */
  67307. export class MultiMaterial extends Material {
  67308. private _subMaterials;
  67309. /**
  67310. * Gets or Sets the list of Materials used within the multi material.
  67311. * They need to be ordered according to the submeshes order in the associated mesh
  67312. */
  67313. subMaterials: Nullable<Material>[];
  67314. /**
  67315. * Function used to align with Node.getChildren()
  67316. * @returns the list of Materials used within the multi material
  67317. */
  67318. getChildren(): Nullable<Material>[];
  67319. /**
  67320. * Instantiates a new Multi Material
  67321. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67322. * separate meshes. This can be use to improve performances.
  67323. * @see http://doc.babylonjs.com/how_to/multi_materials
  67324. * @param name Define the name in the scene
  67325. * @param scene Define the scene the material belongs to
  67326. */
  67327. constructor(name: string, scene: Scene);
  67328. private _hookArray;
  67329. /**
  67330. * Get one of the submaterial by its index in the submaterials array
  67331. * @param index The index to look the sub material at
  67332. * @returns The Material if the index has been defined
  67333. */
  67334. getSubMaterial(index: number): Nullable<Material>;
  67335. /**
  67336. * Get the list of active textures for the whole sub materials list.
  67337. * @returns All the textures that will be used during the rendering
  67338. */
  67339. getActiveTextures(): BaseTexture[];
  67340. /**
  67341. * Gets the current class name of the material e.g. "MultiMaterial"
  67342. * Mainly use in serialization.
  67343. * @returns the class name
  67344. */
  67345. getClassName(): string;
  67346. /**
  67347. * Checks if the material is ready to render the requested sub mesh
  67348. * @param mesh Define the mesh the submesh belongs to
  67349. * @param subMesh Define the sub mesh to look readyness for
  67350. * @param useInstances Define whether or not the material is used with instances
  67351. * @returns true if ready, otherwise false
  67352. */
  67353. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67354. /**
  67355. * Clones the current material and its related sub materials
  67356. * @param name Define the name of the newly cloned material
  67357. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67358. * @returns the cloned material
  67359. */
  67360. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67361. /**
  67362. * Serializes the materials into a JSON representation.
  67363. * @returns the JSON representation
  67364. */
  67365. serialize(): any;
  67366. /**
  67367. * Dispose the material and release its associated resources
  67368. * @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)
  67369. * @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)
  67370. * @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)
  67371. */
  67372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67373. /**
  67374. * Creates a MultiMaterial from parsed MultiMaterial data.
  67375. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67376. * @param scene defines the hosting scene
  67377. * @returns a new MultiMaterial
  67378. */
  67379. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67380. }
  67381. }
  67382. declare module BABYLON {
  67383. /**
  67384. * Class used to represent data loading progression
  67385. */
  67386. export class SceneLoaderFlags {
  67387. private static _ForceFullSceneLoadingForIncremental;
  67388. private static _ShowLoadingScreen;
  67389. private static _CleanBoneMatrixWeights;
  67390. private static _loggingLevel;
  67391. /**
  67392. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67393. */
  67394. static ForceFullSceneLoadingForIncremental: boolean;
  67395. /**
  67396. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67397. */
  67398. static ShowLoadingScreen: boolean;
  67399. /**
  67400. * Defines the current logging level (while loading the scene)
  67401. * @ignorenaming
  67402. */
  67403. static loggingLevel: number;
  67404. /**
  67405. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67406. */
  67407. static CleanBoneMatrixWeights: boolean;
  67408. }
  67409. }
  67410. declare module BABYLON {
  67411. /**
  67412. * 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.
  67413. * @see https://doc.babylonjs.com/how_to/transformnode
  67414. */
  67415. export class TransformNode extends Node {
  67416. /**
  67417. * Object will not rotate to face the camera
  67418. */
  67419. static BILLBOARDMODE_NONE: number;
  67420. /**
  67421. * Object will rotate to face the camera but only on the x axis
  67422. */
  67423. static BILLBOARDMODE_X: number;
  67424. /**
  67425. * Object will rotate to face the camera but only on the y axis
  67426. */
  67427. static BILLBOARDMODE_Y: number;
  67428. /**
  67429. * Object will rotate to face the camera but only on the z axis
  67430. */
  67431. static BILLBOARDMODE_Z: number;
  67432. /**
  67433. * Object will rotate to face the camera
  67434. */
  67435. static BILLBOARDMODE_ALL: number;
  67436. private _forward;
  67437. private _forwardInverted;
  67438. private _up;
  67439. private _right;
  67440. private _rightInverted;
  67441. private _position;
  67442. private _rotation;
  67443. private _rotationQuaternion;
  67444. protected _scaling: Vector3;
  67445. protected _isDirty: boolean;
  67446. private _transformToBoneReferal;
  67447. private _billboardMode;
  67448. /**
  67449. * Gets or sets the billboard mode. Default is 0.
  67450. *
  67451. * | Value | Type | Description |
  67452. * | --- | --- | --- |
  67453. * | 0 | BILLBOARDMODE_NONE | |
  67454. * | 1 | BILLBOARDMODE_X | |
  67455. * | 2 | BILLBOARDMODE_Y | |
  67456. * | 4 | BILLBOARDMODE_Z | |
  67457. * | 7 | BILLBOARDMODE_ALL | |
  67458. *
  67459. */
  67460. billboardMode: number;
  67461. private _preserveParentRotationForBillboard;
  67462. /**
  67463. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67464. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67465. */
  67466. preserveParentRotationForBillboard: boolean;
  67467. /**
  67468. * 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
  67469. */
  67470. scalingDeterminant: number;
  67471. private _infiniteDistance;
  67472. /**
  67473. * Gets or sets the distance of the object to max, often used by skybox
  67474. */
  67475. infiniteDistance: boolean;
  67476. /**
  67477. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67478. * By default the system will update normals to compensate
  67479. */
  67480. ignoreNonUniformScaling: boolean;
  67481. /**
  67482. * 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
  67483. */
  67484. reIntegrateRotationIntoRotationQuaternion: boolean;
  67485. /** @hidden */
  67486. _poseMatrix: Nullable<Matrix>;
  67487. /** @hidden */
  67488. _localMatrix: Matrix;
  67489. private _usePivotMatrix;
  67490. private _absolutePosition;
  67491. private _pivotMatrix;
  67492. private _pivotMatrixInverse;
  67493. protected _postMultiplyPivotMatrix: boolean;
  67494. protected _isWorldMatrixFrozen: boolean;
  67495. /** @hidden */
  67496. _indexInSceneTransformNodesArray: number;
  67497. /**
  67498. * An event triggered after the world matrix is updated
  67499. */
  67500. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67501. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67502. /**
  67503. * Gets a string identifying the name of the class
  67504. * @returns "TransformNode" string
  67505. */
  67506. getClassName(): string;
  67507. /**
  67508. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67509. */
  67510. position: Vector3;
  67511. /**
  67512. * 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)).
  67513. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67514. */
  67515. rotation: Vector3;
  67516. /**
  67517. * 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)).
  67518. */
  67519. scaling: Vector3;
  67520. /**
  67521. * 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).
  67522. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67523. */
  67524. rotationQuaternion: Nullable<Quaternion>;
  67525. /**
  67526. * The forward direction of that transform in world space.
  67527. */
  67528. readonly forward: Vector3;
  67529. /**
  67530. * The up direction of that transform in world space.
  67531. */
  67532. readonly up: Vector3;
  67533. /**
  67534. * The right direction of that transform in world space.
  67535. */
  67536. readonly right: Vector3;
  67537. /**
  67538. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67539. * @param matrix the matrix to copy the pose from
  67540. * @returns this TransformNode.
  67541. */
  67542. updatePoseMatrix(matrix: Matrix): TransformNode;
  67543. /**
  67544. * Returns the mesh Pose matrix.
  67545. * @returns the pose matrix
  67546. */
  67547. getPoseMatrix(): Matrix;
  67548. /** @hidden */
  67549. _isSynchronized(): boolean;
  67550. /** @hidden */
  67551. _initCache(): void;
  67552. /**
  67553. * Flag the transform node as dirty (Forcing it to update everything)
  67554. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67555. * @returns this transform node
  67556. */
  67557. markAsDirty(property: string): TransformNode;
  67558. /**
  67559. * Returns the current mesh absolute position.
  67560. * Returns a Vector3.
  67561. */
  67562. readonly absolutePosition: Vector3;
  67563. /**
  67564. * Sets a new matrix to apply before all other transformation
  67565. * @param matrix defines the transform matrix
  67566. * @returns the current TransformNode
  67567. */
  67568. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67569. /**
  67570. * Sets a new pivot matrix to the current node
  67571. * @param matrix defines the new pivot matrix to use
  67572. * @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
  67573. * @returns the current TransformNode
  67574. */
  67575. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67576. /**
  67577. * Returns the mesh pivot matrix.
  67578. * Default : Identity.
  67579. * @returns the matrix
  67580. */
  67581. getPivotMatrix(): Matrix;
  67582. /**
  67583. * Prevents the World matrix to be computed any longer.
  67584. * @returns the TransformNode.
  67585. */
  67586. freezeWorldMatrix(): TransformNode;
  67587. /**
  67588. * Allows back the World matrix computation.
  67589. * @returns the TransformNode.
  67590. */
  67591. unfreezeWorldMatrix(): this;
  67592. /**
  67593. * True if the World matrix has been frozen.
  67594. */
  67595. readonly isWorldMatrixFrozen: boolean;
  67596. /**
  67597. * Retuns the mesh absolute position in the World.
  67598. * @returns a Vector3.
  67599. */
  67600. getAbsolutePosition(): Vector3;
  67601. /**
  67602. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67603. * @param absolutePosition the absolute position to set
  67604. * @returns the TransformNode.
  67605. */
  67606. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67607. /**
  67608. * Sets the mesh position in its local space.
  67609. * @param vector3 the position to set in localspace
  67610. * @returns the TransformNode.
  67611. */
  67612. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67613. /**
  67614. * Returns the mesh position in the local space from the current World matrix values.
  67615. * @returns a new Vector3.
  67616. */
  67617. getPositionExpressedInLocalSpace(): Vector3;
  67618. /**
  67619. * Translates the mesh along the passed Vector3 in its local space.
  67620. * @param vector3 the distance to translate in localspace
  67621. * @returns the TransformNode.
  67622. */
  67623. locallyTranslate(vector3: Vector3): TransformNode;
  67624. private static _lookAtVectorCache;
  67625. /**
  67626. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67627. * @param targetPoint the position (must be in same space as current mesh) to look at
  67628. * @param yawCor optional yaw (y-axis) correction in radians
  67629. * @param pitchCor optional pitch (x-axis) correction in radians
  67630. * @param rollCor optional roll (z-axis) correction in radians
  67631. * @param space the choosen space of the target
  67632. * @returns the TransformNode.
  67633. */
  67634. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67635. /**
  67636. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67637. * This Vector3 is expressed in the World space.
  67638. * @param localAxis axis to rotate
  67639. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67640. */
  67641. getDirection(localAxis: Vector3): Vector3;
  67642. /**
  67643. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67644. * localAxis is expressed in the mesh local space.
  67645. * result is computed in the Wordl space from the mesh World matrix.
  67646. * @param localAxis axis to rotate
  67647. * @param result the resulting transformnode
  67648. * @returns this TransformNode.
  67649. */
  67650. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67651. /**
  67652. * Sets this transform node rotation to the given local axis.
  67653. * @param localAxis the axis in local space
  67654. * @param yawCor optional yaw (y-axis) correction in radians
  67655. * @param pitchCor optional pitch (x-axis) correction in radians
  67656. * @param rollCor optional roll (z-axis) correction in radians
  67657. * @returns this TransformNode
  67658. */
  67659. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67660. /**
  67661. * Sets a new pivot point to the current node
  67662. * @param point defines the new pivot point to use
  67663. * @param space defines if the point is in world or local space (local by default)
  67664. * @returns the current TransformNode
  67665. */
  67666. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67667. /**
  67668. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67669. * @returns the pivot point
  67670. */
  67671. getPivotPoint(): Vector3;
  67672. /**
  67673. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67674. * @param result the vector3 to store the result
  67675. * @returns this TransformNode.
  67676. */
  67677. getPivotPointToRef(result: Vector3): TransformNode;
  67678. /**
  67679. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67680. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67681. */
  67682. getAbsolutePivotPoint(): Vector3;
  67683. /**
  67684. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67685. * @param result vector3 to store the result
  67686. * @returns this TransformNode.
  67687. */
  67688. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67689. /**
  67690. * Defines the passed node as the parent of the current node.
  67691. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67692. * @see https://doc.babylonjs.com/how_to/parenting
  67693. * @param node the node ot set as the parent
  67694. * @returns this TransformNode.
  67695. */
  67696. setParent(node: Nullable<Node>): TransformNode;
  67697. private _nonUniformScaling;
  67698. /**
  67699. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67700. */
  67701. readonly nonUniformScaling: boolean;
  67702. /** @hidden */
  67703. _updateNonUniformScalingState(value: boolean): boolean;
  67704. /**
  67705. * Attach the current TransformNode to another TransformNode associated with a bone
  67706. * @param bone Bone affecting the TransformNode
  67707. * @param affectedTransformNode TransformNode associated with the bone
  67708. * @returns this object
  67709. */
  67710. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67711. /**
  67712. * Detach the transform node if its associated with a bone
  67713. * @returns this object
  67714. */
  67715. detachFromBone(): TransformNode;
  67716. private static _rotationAxisCache;
  67717. /**
  67718. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67719. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67720. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67721. * The passed axis is also normalized.
  67722. * @param axis the axis to rotate around
  67723. * @param amount the amount to rotate in radians
  67724. * @param space Space to rotate in (Default: local)
  67725. * @returns the TransformNode.
  67726. */
  67727. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67728. /**
  67729. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67730. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67731. * The passed axis is also normalized. .
  67732. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67733. * @param point the point to rotate around
  67734. * @param axis the axis to rotate around
  67735. * @param amount the amount to rotate in radians
  67736. * @returns the TransformNode
  67737. */
  67738. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67739. /**
  67740. * Translates the mesh along the axis vector for the passed distance in the given space.
  67741. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67742. * @param axis the axis to translate in
  67743. * @param distance the distance to translate
  67744. * @param space Space to rotate in (Default: local)
  67745. * @returns the TransformNode.
  67746. */
  67747. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67748. /**
  67749. * Adds a rotation step to the mesh current rotation.
  67750. * x, y, z are Euler angles expressed in radians.
  67751. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67752. * This means this rotation is made in the mesh local space only.
  67753. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67754. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67755. * ```javascript
  67756. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67757. * ```
  67758. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67759. * 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.
  67760. * @param x Rotation to add
  67761. * @param y Rotation to add
  67762. * @param z Rotation to add
  67763. * @returns the TransformNode.
  67764. */
  67765. addRotation(x: number, y: number, z: number): TransformNode;
  67766. /**
  67767. * @hidden
  67768. */
  67769. protected _getEffectiveParent(): Nullable<Node>;
  67770. /**
  67771. * Computes the world matrix of the node
  67772. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67773. * @returns the world matrix
  67774. */
  67775. computeWorldMatrix(force?: boolean): Matrix;
  67776. protected _afterComputeWorldMatrix(): void;
  67777. /**
  67778. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67779. * @param func callback function to add
  67780. *
  67781. * @returns the TransformNode.
  67782. */
  67783. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67784. /**
  67785. * Removes a registered callback function.
  67786. * @param func callback function to remove
  67787. * @returns the TransformNode.
  67788. */
  67789. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67790. /**
  67791. * Gets the position of the current mesh in camera space
  67792. * @param camera defines the camera to use
  67793. * @returns a position
  67794. */
  67795. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67796. /**
  67797. * Returns the distance from the mesh to the active camera
  67798. * @param camera defines the camera to use
  67799. * @returns the distance
  67800. */
  67801. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67802. /**
  67803. * Clone the current transform node
  67804. * @param name Name of the new clone
  67805. * @param newParent New parent for the clone
  67806. * @param doNotCloneChildren Do not clone children hierarchy
  67807. * @returns the new transform node
  67808. */
  67809. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67810. /**
  67811. * Serializes the objects information.
  67812. * @param currentSerializationObject defines the object to serialize in
  67813. * @returns the serialized object
  67814. */
  67815. serialize(currentSerializationObject?: any): any;
  67816. /**
  67817. * Returns a new TransformNode object parsed from the source provided.
  67818. * @param parsedTransformNode is the source.
  67819. * @param scene the scne the object belongs to
  67820. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67821. * @returns a new TransformNode object parsed from the source provided.
  67822. */
  67823. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67824. /**
  67825. * Get all child-transformNodes of this node
  67826. * @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
  67827. * @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
  67828. * @returns an array of TransformNode
  67829. */
  67830. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67831. /**
  67832. * Releases resources associated with this transform node.
  67833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67835. */
  67836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67837. }
  67838. }
  67839. declare module BABYLON {
  67840. /**
  67841. * Class used to override all child animations of a given target
  67842. */
  67843. export class AnimationPropertiesOverride {
  67844. /**
  67845. * Gets or sets a value indicating if animation blending must be used
  67846. */
  67847. enableBlending: boolean;
  67848. /**
  67849. * Gets or sets the blending speed to use when enableBlending is true
  67850. */
  67851. blendingSpeed: number;
  67852. /**
  67853. * Gets or sets the default loop mode to use
  67854. */
  67855. loopMode: number;
  67856. }
  67857. }
  67858. declare module BABYLON {
  67859. /**
  67860. * Class used to store bone information
  67861. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67862. */
  67863. export class Bone extends Node {
  67864. /**
  67865. * defines the bone name
  67866. */
  67867. name: string;
  67868. private static _tmpVecs;
  67869. private static _tmpQuat;
  67870. private static _tmpMats;
  67871. /**
  67872. * Gets the list of child bones
  67873. */
  67874. children: Bone[];
  67875. /** Gets the animations associated with this bone */
  67876. animations: Animation[];
  67877. /**
  67878. * Gets or sets bone length
  67879. */
  67880. length: number;
  67881. /**
  67882. * @hidden Internal only
  67883. * Set this value to map this bone to a different index in the transform matrices
  67884. * Set this value to -1 to exclude the bone from the transform matrices
  67885. */
  67886. _index: Nullable<number>;
  67887. private _skeleton;
  67888. private _localMatrix;
  67889. private _restPose;
  67890. private _baseMatrix;
  67891. private _absoluteTransform;
  67892. private _invertedAbsoluteTransform;
  67893. private _parent;
  67894. private _scalingDeterminant;
  67895. private _worldTransform;
  67896. private _localScaling;
  67897. private _localRotation;
  67898. private _localPosition;
  67899. private _needToDecompose;
  67900. private _needToCompose;
  67901. /** @hidden */
  67902. _linkedTransformNode: Nullable<TransformNode>;
  67903. /** @hidden */
  67904. /** @hidden */
  67905. _matrix: Matrix;
  67906. /**
  67907. * Create a new bone
  67908. * @param name defines the bone name
  67909. * @param skeleton defines the parent skeleton
  67910. * @param parentBone defines the parent (can be null if the bone is the root)
  67911. * @param localMatrix defines the local matrix
  67912. * @param restPose defines the rest pose matrix
  67913. * @param baseMatrix defines the base matrix
  67914. * @param index defines index of the bone in the hiearchy
  67915. */
  67916. constructor(
  67917. /**
  67918. * defines the bone name
  67919. */
  67920. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67921. /**
  67922. * Gets the current object class name.
  67923. * @return the class name
  67924. */
  67925. getClassName(): string;
  67926. /**
  67927. * Gets the parent skeleton
  67928. * @returns a skeleton
  67929. */
  67930. getSkeleton(): Skeleton;
  67931. /**
  67932. * Gets parent bone
  67933. * @returns a bone or null if the bone is the root of the bone hierarchy
  67934. */
  67935. getParent(): Nullable<Bone>;
  67936. /**
  67937. * Returns an array containing the root bones
  67938. * @returns an array containing the root bones
  67939. */
  67940. getChildren(): Array<Bone>;
  67941. /**
  67942. * Sets the parent bone
  67943. * @param parent defines the parent (can be null if the bone is the root)
  67944. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67945. */
  67946. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67947. /**
  67948. * Gets the local matrix
  67949. * @returns a matrix
  67950. */
  67951. getLocalMatrix(): Matrix;
  67952. /**
  67953. * Gets the base matrix (initial matrix which remains unchanged)
  67954. * @returns a matrix
  67955. */
  67956. getBaseMatrix(): Matrix;
  67957. /**
  67958. * Gets the rest pose matrix
  67959. * @returns a matrix
  67960. */
  67961. getRestPose(): Matrix;
  67962. /**
  67963. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67964. */
  67965. getWorldMatrix(): Matrix;
  67966. /**
  67967. * Sets the local matrix to rest pose matrix
  67968. */
  67969. returnToRest(): void;
  67970. /**
  67971. * Gets the inverse of the absolute transform matrix.
  67972. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67973. * @returns a matrix
  67974. */
  67975. getInvertedAbsoluteTransform(): Matrix;
  67976. /**
  67977. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67978. * @returns a matrix
  67979. */
  67980. getAbsoluteTransform(): Matrix;
  67981. /**
  67982. * Links with the given transform node.
  67983. * The local matrix of this bone is copied from the transform node every frame.
  67984. * @param transformNode defines the transform node to link to
  67985. */
  67986. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67987. /** Gets or sets current position (in local space) */
  67988. position: Vector3;
  67989. /** Gets or sets current rotation (in local space) */
  67990. rotation: Vector3;
  67991. /** Gets or sets current rotation quaternion (in local space) */
  67992. rotationQuaternion: Quaternion;
  67993. /** Gets or sets current scaling (in local space) */
  67994. scaling: Vector3;
  67995. /**
  67996. * Gets the animation properties override
  67997. */
  67998. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67999. private _decompose;
  68000. private _compose;
  68001. /**
  68002. * Update the base and local matrices
  68003. * @param matrix defines the new base or local matrix
  68004. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68005. * @param updateLocalMatrix defines if the local matrix should be updated
  68006. */
  68007. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68008. /** @hidden */
  68009. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68010. /**
  68011. * Flag the bone as dirty (Forcing it to update everything)
  68012. */
  68013. markAsDirty(): void;
  68014. private _markAsDirtyAndCompose;
  68015. private _markAsDirtyAndDecompose;
  68016. /**
  68017. * Translate the bone in local or world space
  68018. * @param vec The amount to translate the bone
  68019. * @param space The space that the translation is in
  68020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68021. */
  68022. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68023. /**
  68024. * Set the postion of the bone in local or world space
  68025. * @param position The position to set the bone
  68026. * @param space The space that the position is in
  68027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68028. */
  68029. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68030. /**
  68031. * Set the absolute position of the bone (world space)
  68032. * @param position The position to set the bone
  68033. * @param mesh The mesh that this bone is attached to
  68034. */
  68035. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68036. /**
  68037. * Scale the bone on the x, y and z axes (in local space)
  68038. * @param x The amount to scale the bone on the x axis
  68039. * @param y The amount to scale the bone on the y axis
  68040. * @param z The amount to scale the bone on the z axis
  68041. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68042. */
  68043. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68044. /**
  68045. * Set the bone scaling in local space
  68046. * @param scale defines the scaling vector
  68047. */
  68048. setScale(scale: Vector3): void;
  68049. /**
  68050. * Gets the current scaling in local space
  68051. * @returns the current scaling vector
  68052. */
  68053. getScale(): Vector3;
  68054. /**
  68055. * Gets the current scaling in local space and stores it in a target vector
  68056. * @param result defines the target vector
  68057. */
  68058. getScaleToRef(result: Vector3): void;
  68059. /**
  68060. * Set the yaw, pitch, and roll of the bone in local or world space
  68061. * @param yaw The rotation of the bone on the y axis
  68062. * @param pitch The rotation of the bone on the x axis
  68063. * @param roll The rotation of the bone on the z axis
  68064. * @param space The space that the axes of rotation are in
  68065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68066. */
  68067. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68068. /**
  68069. * Add a rotation to the bone on an axis in local or world space
  68070. * @param axis The axis to rotate the bone on
  68071. * @param amount The amount to rotate the bone
  68072. * @param space The space that the axis is in
  68073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68074. */
  68075. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68076. /**
  68077. * Set the rotation of the bone to a particular axis angle in local or world space
  68078. * @param axis The axis to rotate the bone on
  68079. * @param angle The angle that the bone should be rotated to
  68080. * @param space The space that the axis is in
  68081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68082. */
  68083. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68084. /**
  68085. * Set the euler rotation of the bone in local of world space
  68086. * @param rotation The euler rotation that the bone should be set to
  68087. * @param space The space that the rotation is in
  68088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68089. */
  68090. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68091. /**
  68092. * Set the quaternion rotation of the bone in local of world space
  68093. * @param quat The quaternion rotation that the bone should be set to
  68094. * @param space The space that the rotation is in
  68095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68096. */
  68097. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68098. /**
  68099. * Set the rotation matrix of the bone in local of world space
  68100. * @param rotMat The rotation matrix that the bone should be set to
  68101. * @param space The space that the rotation is in
  68102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68103. */
  68104. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68105. private _rotateWithMatrix;
  68106. private _getNegativeRotationToRef;
  68107. /**
  68108. * Get the position of the bone in local or world space
  68109. * @param space The space that the returned position is in
  68110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68111. * @returns The position of the bone
  68112. */
  68113. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68114. /**
  68115. * Copy the position of the bone to a vector3 in local or world space
  68116. * @param space The space that the returned position is in
  68117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68118. * @param result The vector3 to copy the position to
  68119. */
  68120. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68121. /**
  68122. * Get the absolute position of the bone (world space)
  68123. * @param mesh The mesh that this bone is attached to
  68124. * @returns The absolute position of the bone
  68125. */
  68126. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68127. /**
  68128. * Copy the absolute position of the bone (world space) to the result param
  68129. * @param mesh The mesh that this bone is attached to
  68130. * @param result The vector3 to copy the absolute position to
  68131. */
  68132. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68133. /**
  68134. * Compute the absolute transforms of this bone and its children
  68135. */
  68136. computeAbsoluteTransforms(): void;
  68137. /**
  68138. * Get the world direction from an axis that is in the local space of the bone
  68139. * @param localAxis The local direction that is used to compute the world direction
  68140. * @param mesh The mesh that this bone is attached to
  68141. * @returns The world direction
  68142. */
  68143. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68144. /**
  68145. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68146. * @param localAxis The local direction that is used to compute the world direction
  68147. * @param mesh The mesh that this bone is attached to
  68148. * @param result The vector3 that the world direction will be copied to
  68149. */
  68150. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68151. /**
  68152. * Get the euler rotation of the bone in local or world space
  68153. * @param space The space that the rotation should be in
  68154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68155. * @returns The euler rotation
  68156. */
  68157. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68158. /**
  68159. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68160. * @param space The space that the rotation should be in
  68161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68162. * @param result The vector3 that the rotation should be copied to
  68163. */
  68164. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68165. /**
  68166. * Get the quaternion rotation of the bone in either local or world space
  68167. * @param space The space that the rotation should be in
  68168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68169. * @returns The quaternion rotation
  68170. */
  68171. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68172. /**
  68173. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68174. * @param space The space that the rotation should be in
  68175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68176. * @param result The quaternion that the rotation should be copied to
  68177. */
  68178. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68179. /**
  68180. * Get the rotation matrix of the bone in local or world space
  68181. * @param space The space that the rotation should be in
  68182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68183. * @returns The rotation matrix
  68184. */
  68185. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68186. /**
  68187. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68188. * @param space The space that the rotation should be in
  68189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68190. * @param result The quaternion that the rotation should be copied to
  68191. */
  68192. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68193. /**
  68194. * Get the world position of a point that is in the local space of the bone
  68195. * @param position The local position
  68196. * @param mesh The mesh that this bone is attached to
  68197. * @returns The world position
  68198. */
  68199. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68200. /**
  68201. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68202. * @param position The local position
  68203. * @param mesh The mesh that this bone is attached to
  68204. * @param result The vector3 that the world position should be copied to
  68205. */
  68206. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68207. /**
  68208. * Get the local position of a point that is in world space
  68209. * @param position The world position
  68210. * @param mesh The mesh that this bone is attached to
  68211. * @returns The local position
  68212. */
  68213. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68214. /**
  68215. * Get the local position of a point that is in world space and copy it to the result param
  68216. * @param position The world position
  68217. * @param mesh The mesh that this bone is attached to
  68218. * @param result The vector3 that the local position should be copied to
  68219. */
  68220. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68221. }
  68222. }
  68223. declare module BABYLON {
  68224. /**
  68225. * Enum that determines the text-wrapping mode to use.
  68226. */
  68227. export enum InspectableType {
  68228. /**
  68229. * Checkbox for booleans
  68230. */
  68231. Checkbox = 0,
  68232. /**
  68233. * Sliders for numbers
  68234. */
  68235. Slider = 1,
  68236. /**
  68237. * Vector3
  68238. */
  68239. Vector3 = 2,
  68240. /**
  68241. * Quaternions
  68242. */
  68243. Quaternion = 3,
  68244. /**
  68245. * Color3
  68246. */
  68247. Color3 = 4
  68248. }
  68249. /**
  68250. * Interface used to define custom inspectable properties.
  68251. * This interface is used by the inspector to display custom property grids
  68252. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68253. */
  68254. export interface IInspectable {
  68255. /**
  68256. * Gets the label to display
  68257. */
  68258. label: string;
  68259. /**
  68260. * Gets the name of the property to edit
  68261. */
  68262. propertyName: string;
  68263. /**
  68264. * Gets the type of the editor to use
  68265. */
  68266. type: InspectableType;
  68267. /**
  68268. * Gets the minimum value of the property when using in "slider" mode
  68269. */
  68270. min?: number;
  68271. /**
  68272. * Gets the maximum value of the property when using in "slider" mode
  68273. */
  68274. max?: number;
  68275. /**
  68276. * Gets the setp to use when using in "slider" mode
  68277. */
  68278. step?: number;
  68279. }
  68280. }
  68281. declare module BABYLON {
  68282. /**
  68283. * This represents the required contract to create a new type of texture loader.
  68284. */
  68285. export interface IInternalTextureLoader {
  68286. /**
  68287. * Defines wether the loader supports cascade loading the different faces.
  68288. */
  68289. supportCascades: boolean;
  68290. /**
  68291. * This returns if the loader support the current file information.
  68292. * @param extension defines the file extension of the file being loaded
  68293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68294. * @param fallback defines the fallback internal texture if any
  68295. * @param isBase64 defines whether the texture is encoded as a base64
  68296. * @param isBuffer defines whether the texture data are stored as a buffer
  68297. * @returns true if the loader can load the specified file
  68298. */
  68299. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68300. /**
  68301. * Transform the url before loading if required.
  68302. * @param rootUrl the url of the texture
  68303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68304. * @returns the transformed texture
  68305. */
  68306. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68307. /**
  68308. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68309. * @param rootUrl the url of the texture
  68310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68311. * @returns the fallback texture
  68312. */
  68313. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68314. /**
  68315. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68316. * @param data contains the texture data
  68317. * @param texture defines the BabylonJS internal texture
  68318. * @param createPolynomials will be true if polynomials have been requested
  68319. * @param onLoad defines the callback to trigger once the texture is ready
  68320. * @param onError defines the callback to trigger in case of error
  68321. */
  68322. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68323. /**
  68324. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68325. * @param data contains the texture data
  68326. * @param texture defines the BabylonJS internal texture
  68327. * @param callback defines the method to call once ready to upload
  68328. */
  68329. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68330. }
  68331. }
  68332. declare module BABYLON {
  68333. interface Engine {
  68334. /**
  68335. * Creates a depth stencil cube texture.
  68336. * This is only available in WebGL 2.
  68337. * @param size The size of face edge in the cube texture.
  68338. * @param options The options defining the cube texture.
  68339. * @returns The cube texture
  68340. */
  68341. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68342. /**
  68343. * Creates a cube texture
  68344. * @param rootUrl defines the url where the files to load is located
  68345. * @param scene defines the current scene
  68346. * @param files defines the list of files to load (1 per face)
  68347. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68348. * @param onLoad defines an optional callback raised when the texture is loaded
  68349. * @param onError defines an optional callback raised if there is an issue to load the texture
  68350. * @param format defines the format of the data
  68351. * @param forcedExtension defines the extension to use to pick the right loader
  68352. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68353. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68354. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68355. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68356. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68357. * @returns the cube texture as an InternalTexture
  68358. */
  68359. 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;
  68360. /**
  68361. * Creates a cube texture
  68362. * @param rootUrl defines the url where the files to load is located
  68363. * @param scene defines the current scene
  68364. * @param files defines the list of files to load (1 per face)
  68365. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68366. * @param onLoad defines an optional callback raised when the texture is loaded
  68367. * @param onError defines an optional callback raised if there is an issue to load the texture
  68368. * @param format defines the format of the data
  68369. * @param forcedExtension defines the extension to use to pick the right loader
  68370. * @returns the cube texture as an InternalTexture
  68371. */
  68372. 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;
  68373. /**
  68374. * Creates a cube texture
  68375. * @param rootUrl defines the url where the files to load is located
  68376. * @param scene defines the current scene
  68377. * @param files defines the list of files to load (1 per face)
  68378. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68379. * @param onLoad defines an optional callback raised when the texture is loaded
  68380. * @param onError defines an optional callback raised if there is an issue to load the texture
  68381. * @param format defines the format of the data
  68382. * @param forcedExtension defines the extension to use to pick the right loader
  68383. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68384. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68385. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68386. * @returns the cube texture as an InternalTexture
  68387. */
  68388. 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;
  68389. /** @hidden */
  68390. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68391. /** @hidden */
  68392. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68393. /** @hidden */
  68394. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68395. /** @hidden */
  68396. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68397. }
  68398. }
  68399. declare module BABYLON {
  68400. /**
  68401. * Class for creating a cube texture
  68402. */
  68403. export class CubeTexture extends BaseTexture {
  68404. private _delayedOnLoad;
  68405. /**
  68406. * The url of the texture
  68407. */
  68408. url: string;
  68409. /**
  68410. * Gets or sets the center of the bounding box associated with the cube texture.
  68411. * It must define where the camera used to render the texture was set
  68412. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68413. */
  68414. boundingBoxPosition: Vector3;
  68415. private _boundingBoxSize;
  68416. /**
  68417. * Gets or sets the size of the bounding box associated with the cube texture
  68418. * When defined, the cubemap will switch to local mode
  68419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68420. * @example https://www.babylonjs-playground.com/#RNASML
  68421. */
  68422. /**
  68423. * Returns the bounding box size
  68424. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68425. */
  68426. boundingBoxSize: Vector3;
  68427. protected _rotationY: number;
  68428. /**
  68429. * Sets texture matrix rotation angle around Y axis in radians.
  68430. */
  68431. /**
  68432. * Gets texture matrix rotation angle around Y axis radians.
  68433. */
  68434. rotationY: number;
  68435. /**
  68436. * Are mip maps generated for this texture or not.
  68437. */
  68438. readonly noMipmap: boolean;
  68439. private _noMipmap;
  68440. private _files;
  68441. private _extensions;
  68442. private _textureMatrix;
  68443. private _format;
  68444. private _createPolynomials;
  68445. /** @hidden */
  68446. _prefiltered: boolean;
  68447. /**
  68448. * Creates a cube texture from an array of image urls
  68449. * @param files defines an array of image urls
  68450. * @param scene defines the hosting scene
  68451. * @param noMipmap specifies if mip maps are not used
  68452. * @returns a cube texture
  68453. */
  68454. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68455. /**
  68456. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68457. * @param url defines the url of the prefiltered texture
  68458. * @param scene defines the scene the texture is attached to
  68459. * @param forcedExtension defines the extension of the file if different from the url
  68460. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68461. * @return the prefiltered texture
  68462. */
  68463. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68464. /**
  68465. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68466. * as prefiltered data.
  68467. * @param rootUrl defines the url of the texture or the root name of the six images
  68468. * @param scene defines the scene the texture is attached to
  68469. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68470. * @param noMipmap defines if mipmaps should be created or not
  68471. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68472. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68473. * @param onError defines a callback triggered in case of error during load
  68474. * @param format defines the internal format to use for the texture once loaded
  68475. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68476. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68477. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68480. * @return the cube texture
  68481. */
  68482. 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);
  68483. /**
  68484. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68485. */
  68486. readonly isPrefiltered: boolean;
  68487. /**
  68488. * Get the current class name of the texture useful for serialization or dynamic coding.
  68489. * @returns "CubeTexture"
  68490. */
  68491. getClassName(): string;
  68492. /**
  68493. * Update the url (and optional buffer) of this texture if url was null during construction.
  68494. * @param url the url of the texture
  68495. * @param forcedExtension defines the extension to use
  68496. * @param onLoad callback called when the texture is loaded (defaults to null)
  68497. */
  68498. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68499. /**
  68500. * Delays loading of the cube texture
  68501. * @param forcedExtension defines the extension to use
  68502. */
  68503. delayLoad(forcedExtension?: string): void;
  68504. /**
  68505. * Returns the reflection texture matrix
  68506. * @returns the reflection texture matrix
  68507. */
  68508. getReflectionTextureMatrix(): Matrix;
  68509. /**
  68510. * Sets the reflection texture matrix
  68511. * @param value Reflection texture matrix
  68512. */
  68513. setReflectionTextureMatrix(value: Matrix): void;
  68514. /**
  68515. * Parses text to create a cube texture
  68516. * @param parsedTexture define the serialized text to read from
  68517. * @param scene defines the hosting scene
  68518. * @param rootUrl defines the root url of the cube texture
  68519. * @returns a cube texture
  68520. */
  68521. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68522. /**
  68523. * Makes a clone, or deep copy, of the cube texture
  68524. * @returns a new cube texture
  68525. */
  68526. clone(): CubeTexture;
  68527. }
  68528. }
  68529. declare module BABYLON {
  68530. /** @hidden */
  68531. export var postprocessVertexShader: {
  68532. name: string;
  68533. shader: string;
  68534. };
  68535. }
  68536. declare module BABYLON {
  68537. /**
  68538. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68539. * This is the base of the follow, arc rotate cameras and Free camera
  68540. * @see http://doc.babylonjs.com/features/cameras
  68541. */
  68542. export class TargetCamera extends Camera {
  68543. private static _RigCamTransformMatrix;
  68544. private static _TargetTransformMatrix;
  68545. private static _TargetFocalPoint;
  68546. /**
  68547. * Define the current direction the camera is moving to
  68548. */
  68549. cameraDirection: Vector3;
  68550. /**
  68551. * Define the current rotation the camera is rotating to
  68552. */
  68553. cameraRotation: Vector2;
  68554. /**
  68555. * When set, the up vector of the camera will be updated by the rotation of the camera
  68556. */
  68557. updateUpVectorFromRotation: boolean;
  68558. private _tmpQuaternion;
  68559. /**
  68560. * Define the current rotation of the camera
  68561. */
  68562. rotation: Vector3;
  68563. /**
  68564. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68565. */
  68566. rotationQuaternion: Quaternion;
  68567. /**
  68568. * Define the current speed of the camera
  68569. */
  68570. speed: number;
  68571. /**
  68572. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68573. * around all axis.
  68574. */
  68575. noRotationConstraint: boolean;
  68576. /**
  68577. * Define the current target of the camera as an object or a position.
  68578. */
  68579. lockedTarget: any;
  68580. /** @hidden */
  68581. _currentTarget: Vector3;
  68582. /** @hidden */
  68583. _initialFocalDistance: number;
  68584. /** @hidden */
  68585. _viewMatrix: Matrix;
  68586. /** @hidden */
  68587. _camMatrix: Matrix;
  68588. /** @hidden */
  68589. _cameraTransformMatrix: Matrix;
  68590. /** @hidden */
  68591. _cameraRotationMatrix: Matrix;
  68592. /** @hidden */
  68593. _referencePoint: Vector3;
  68594. /** @hidden */
  68595. _transformedReferencePoint: Vector3;
  68596. protected _globalCurrentTarget: Vector3;
  68597. protected _globalCurrentUpVector: Vector3;
  68598. /** @hidden */
  68599. _reset: () => void;
  68600. private _defaultUp;
  68601. /**
  68602. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68603. * This is the base of the follow, arc rotate cameras and Free camera
  68604. * @see http://doc.babylonjs.com/features/cameras
  68605. * @param name Defines the name of the camera in the scene
  68606. * @param position Defines the start position of the camera in the scene
  68607. * @param scene Defines the scene the camera belongs to
  68608. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68609. */
  68610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68611. /**
  68612. * Gets the position in front of the camera at a given distance.
  68613. * @param distance The distance from the camera we want the position to be
  68614. * @returns the position
  68615. */
  68616. getFrontPosition(distance: number): Vector3;
  68617. /** @hidden */
  68618. _getLockedTargetPosition(): Nullable<Vector3>;
  68619. private _storedPosition;
  68620. private _storedRotation;
  68621. private _storedRotationQuaternion;
  68622. /**
  68623. * Store current camera state of the camera (fov, position, rotation, etc..)
  68624. * @returns the camera
  68625. */
  68626. storeState(): Camera;
  68627. /**
  68628. * Restored camera state. You must call storeState() first
  68629. * @returns whether it was successful or not
  68630. * @hidden
  68631. */
  68632. _restoreStateValues(): boolean;
  68633. /** @hidden */
  68634. _initCache(): void;
  68635. /** @hidden */
  68636. _updateCache(ignoreParentClass?: boolean): void;
  68637. /** @hidden */
  68638. _isSynchronizedViewMatrix(): boolean;
  68639. /** @hidden */
  68640. _computeLocalCameraSpeed(): number;
  68641. /**
  68642. * Defines the target the camera should look at.
  68643. * This will automatically adapt alpha beta and radius to fit within the new target.
  68644. * @param target Defines the new target as a Vector or a mesh
  68645. */
  68646. setTarget(target: Vector3): void;
  68647. /**
  68648. * Return the current target position of the camera. This value is expressed in local space.
  68649. * @returns the target position
  68650. */
  68651. getTarget(): Vector3;
  68652. /** @hidden */
  68653. _decideIfNeedsToMove(): boolean;
  68654. /** @hidden */
  68655. _updatePosition(): void;
  68656. /** @hidden */
  68657. _checkInputs(): void;
  68658. protected _updateCameraRotationMatrix(): void;
  68659. /**
  68660. * 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)
  68661. * @returns the current camera
  68662. */
  68663. private _rotateUpVectorWithCameraRotationMatrix;
  68664. private _cachedRotationZ;
  68665. private _cachedQuaternionRotationZ;
  68666. /** @hidden */
  68667. _getViewMatrix(): Matrix;
  68668. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68669. /**
  68670. * @hidden
  68671. */
  68672. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68673. /**
  68674. * @hidden
  68675. */
  68676. _updateRigCameras(): void;
  68677. private _getRigCamPositionAndTarget;
  68678. /**
  68679. * Gets the current object class name.
  68680. * @return the class name
  68681. */
  68682. getClassName(): string;
  68683. }
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * @ignore
  68688. * This is a list of all the different input types that are available in the application.
  68689. * Fo instance: ArcRotateCameraGamepadInput...
  68690. */
  68691. export var CameraInputTypes: {};
  68692. /**
  68693. * This is the contract to implement in order to create a new input class.
  68694. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68695. */
  68696. export interface ICameraInput<TCamera extends Camera> {
  68697. /**
  68698. * Defines the camera the input is attached to.
  68699. */
  68700. camera: Nullable<TCamera>;
  68701. /**
  68702. * Gets the class name of the current intput.
  68703. * @returns the class name
  68704. */
  68705. getClassName(): string;
  68706. /**
  68707. * Get the friendly name associated with the input class.
  68708. * @returns the input friendly name
  68709. */
  68710. getSimpleName(): string;
  68711. /**
  68712. * Attach the input controls to a specific dom element to get the input from.
  68713. * @param element Defines the element the controls should be listened from
  68714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68715. */
  68716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68717. /**
  68718. * Detach the current controls from the specified dom element.
  68719. * @param element Defines the element to stop listening the inputs from
  68720. */
  68721. detachControl(element: Nullable<HTMLElement>): void;
  68722. /**
  68723. * Update the current camera state depending on the inputs that have been used this frame.
  68724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68725. */
  68726. checkInputs?: () => void;
  68727. }
  68728. /**
  68729. * Represents a map of input types to input instance or input index to input instance.
  68730. */
  68731. export interface CameraInputsMap<TCamera extends Camera> {
  68732. /**
  68733. * Accessor to the input by input type.
  68734. */
  68735. [name: string]: ICameraInput<TCamera>;
  68736. /**
  68737. * Accessor to the input by input index.
  68738. */
  68739. [idx: number]: ICameraInput<TCamera>;
  68740. }
  68741. /**
  68742. * This represents the input manager used within a camera.
  68743. * It helps dealing with all the different kind of input attached to a camera.
  68744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68745. */
  68746. export class CameraInputsManager<TCamera extends Camera> {
  68747. /**
  68748. * Defines the list of inputs attahed to the camera.
  68749. */
  68750. attached: CameraInputsMap<TCamera>;
  68751. /**
  68752. * Defines the dom element the camera is collecting inputs from.
  68753. * This is null if the controls have not been attached.
  68754. */
  68755. attachedElement: Nullable<HTMLElement>;
  68756. /**
  68757. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68758. */
  68759. noPreventDefault: boolean;
  68760. /**
  68761. * Defined the camera the input manager belongs to.
  68762. */
  68763. camera: TCamera;
  68764. /**
  68765. * Update the current camera state depending on the inputs that have been used this frame.
  68766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68767. */
  68768. checkInputs: () => void;
  68769. /**
  68770. * Instantiate a new Camera Input Manager.
  68771. * @param camera Defines the camera the input manager blongs to
  68772. */
  68773. constructor(camera: TCamera);
  68774. /**
  68775. * Add an input method to a camera
  68776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68777. * @param input camera input method
  68778. */
  68779. add(input: ICameraInput<TCamera>): void;
  68780. /**
  68781. * Remove a specific input method from a camera
  68782. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68783. * @param inputToRemove camera input method
  68784. */
  68785. remove(inputToRemove: ICameraInput<TCamera>): void;
  68786. /**
  68787. * Remove a specific input type from a camera
  68788. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68789. * @param inputType the type of the input to remove
  68790. */
  68791. removeByType(inputType: string): void;
  68792. private _addCheckInputs;
  68793. /**
  68794. * Attach the input controls to the currently attached dom element to listen the events from.
  68795. * @param input Defines the input to attach
  68796. */
  68797. attachInput(input: ICameraInput<TCamera>): void;
  68798. /**
  68799. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68800. * @param element Defines the dom element to collect the events from
  68801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68802. */
  68803. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68804. /**
  68805. * Detach the current manager inputs controls from a specific dom element.
  68806. * @param element Defines the dom element to collect the events from
  68807. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68808. */
  68809. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68810. /**
  68811. * Rebuild the dynamic inputCheck function from the current list of
  68812. * defined inputs in the manager.
  68813. */
  68814. rebuildInputCheck(): void;
  68815. /**
  68816. * Remove all attached input methods from a camera
  68817. */
  68818. clear(): void;
  68819. /**
  68820. * Serialize the current input manager attached to a camera.
  68821. * This ensures than once parsed,
  68822. * the input associated to the camera will be identical to the current ones
  68823. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68824. */
  68825. serialize(serializedCamera: any): void;
  68826. /**
  68827. * Parses an input manager serialized JSON to restore the previous list of inputs
  68828. * and states associated to a camera.
  68829. * @param parsedCamera Defines the JSON to parse
  68830. */
  68831. parse(parsedCamera: any): void;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Gather the list of keyboard event types as constants.
  68837. */
  68838. export class KeyboardEventTypes {
  68839. /**
  68840. * The keydown event is fired when a key becomes active (pressed).
  68841. */
  68842. static readonly KEYDOWN: number;
  68843. /**
  68844. * The keyup event is fired when a key has been released.
  68845. */
  68846. static readonly KEYUP: number;
  68847. }
  68848. /**
  68849. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68850. */
  68851. export class KeyboardInfo {
  68852. /**
  68853. * Defines the type of event (KeyboardEventTypes)
  68854. */
  68855. type: number;
  68856. /**
  68857. * Defines the related dom event
  68858. */
  68859. event: KeyboardEvent;
  68860. /**
  68861. * Instantiates a new keyboard info.
  68862. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68863. * @param type Defines the type of event (KeyboardEventTypes)
  68864. * @param event Defines the related dom event
  68865. */
  68866. constructor(
  68867. /**
  68868. * Defines the type of event (KeyboardEventTypes)
  68869. */
  68870. type: number,
  68871. /**
  68872. * Defines the related dom event
  68873. */
  68874. event: KeyboardEvent);
  68875. }
  68876. /**
  68877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68878. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68879. */
  68880. export class KeyboardInfoPre extends KeyboardInfo {
  68881. /**
  68882. * Defines the type of event (KeyboardEventTypes)
  68883. */
  68884. type: number;
  68885. /**
  68886. * Defines the related dom event
  68887. */
  68888. event: KeyboardEvent;
  68889. /**
  68890. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68891. */
  68892. skipOnPointerObservable: boolean;
  68893. /**
  68894. * Instantiates a new keyboard pre info.
  68895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68896. * @param type Defines the type of event (KeyboardEventTypes)
  68897. * @param event Defines the related dom event
  68898. */
  68899. constructor(
  68900. /**
  68901. * Defines the type of event (KeyboardEventTypes)
  68902. */
  68903. type: number,
  68904. /**
  68905. * Defines the related dom event
  68906. */
  68907. event: KeyboardEvent);
  68908. }
  68909. }
  68910. declare module BABYLON {
  68911. /**
  68912. * Manage the keyboard inputs to control the movement of a free camera.
  68913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68914. */
  68915. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68916. /**
  68917. * Defines the camera the input is attached to.
  68918. */
  68919. camera: FreeCamera;
  68920. /**
  68921. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68922. */
  68923. keysUp: number[];
  68924. /**
  68925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68926. */
  68927. keysDown: number[];
  68928. /**
  68929. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68930. */
  68931. keysLeft: number[];
  68932. /**
  68933. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68934. */
  68935. keysRight: number[];
  68936. private _keys;
  68937. private _onCanvasBlurObserver;
  68938. private _onKeyboardObserver;
  68939. private _engine;
  68940. private _scene;
  68941. /**
  68942. * Attach the input controls to a specific dom element to get the input from.
  68943. * @param element Defines the element the controls should be listened from
  68944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68945. */
  68946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68947. /**
  68948. * Detach the current controls from the specified dom element.
  68949. * @param element Defines the element to stop listening the inputs from
  68950. */
  68951. detachControl(element: Nullable<HTMLElement>): void;
  68952. /**
  68953. * Update the current camera state depending on the inputs that have been used this frame.
  68954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68955. */
  68956. checkInputs(): void;
  68957. /**
  68958. * Gets the class name of the current intput.
  68959. * @returns the class name
  68960. */
  68961. getClassName(): string;
  68962. /** @hidden */
  68963. _onLostFocus(): void;
  68964. /**
  68965. * Get the friendly name associated with the input class.
  68966. * @returns the input friendly name
  68967. */
  68968. getSimpleName(): string;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /**
  68973. * Interface describing all the common properties and methods a shadow light needs to implement.
  68974. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68975. * as well as binding the different shadow properties to the effects.
  68976. */
  68977. export interface IShadowLight extends Light {
  68978. /**
  68979. * The light id in the scene (used in scene.findLighById for instance)
  68980. */
  68981. id: string;
  68982. /**
  68983. * The position the shdow will be casted from.
  68984. */
  68985. position: Vector3;
  68986. /**
  68987. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68988. */
  68989. direction: Vector3;
  68990. /**
  68991. * The transformed position. Position of the light in world space taking parenting in account.
  68992. */
  68993. transformedPosition: Vector3;
  68994. /**
  68995. * The transformed direction. Direction of the light in world space taking parenting in account.
  68996. */
  68997. transformedDirection: Vector3;
  68998. /**
  68999. * The friendly name of the light in the scene.
  69000. */
  69001. name: string;
  69002. /**
  69003. * Defines the shadow projection clipping minimum z value.
  69004. */
  69005. shadowMinZ: number;
  69006. /**
  69007. * Defines the shadow projection clipping maximum z value.
  69008. */
  69009. shadowMaxZ: number;
  69010. /**
  69011. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69012. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69013. */
  69014. computeTransformedInformation(): boolean;
  69015. /**
  69016. * Gets the scene the light belongs to.
  69017. * @returns The scene
  69018. */
  69019. getScene(): Scene;
  69020. /**
  69021. * Callback defining a custom Projection Matrix Builder.
  69022. * This can be used to override the default projection matrix computation.
  69023. */
  69024. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69025. /**
  69026. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69027. * @param matrix The materix to updated with the projection information
  69028. * @param viewMatrix The transform matrix of the light
  69029. * @param renderList The list of mesh to render in the map
  69030. * @returns The current light
  69031. */
  69032. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69033. /**
  69034. * Gets the current depth scale used in ESM.
  69035. * @returns The scale
  69036. */
  69037. getDepthScale(): number;
  69038. /**
  69039. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69040. * @returns true if a cube texture needs to be use
  69041. */
  69042. needCube(): boolean;
  69043. /**
  69044. * Detects if the projection matrix requires to be recomputed this frame.
  69045. * @returns true if it requires to be recomputed otherwise, false.
  69046. */
  69047. needProjectionMatrixCompute(): boolean;
  69048. /**
  69049. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69050. */
  69051. forceProjectionMatrixCompute(): void;
  69052. /**
  69053. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69056. */
  69057. getShadowDirection(faceIndex?: number): Vector3;
  69058. /**
  69059. * Gets the minZ used for shadow according to both the scene and the light.
  69060. * @param activeCamera The camera we are returning the min for
  69061. * @returns the depth min z
  69062. */
  69063. getDepthMinZ(activeCamera: Camera): number;
  69064. /**
  69065. * Gets the maxZ used for shadow according to both the scene and the light.
  69066. * @param activeCamera The camera we are returning the max for
  69067. * @returns the depth max z
  69068. */
  69069. getDepthMaxZ(activeCamera: Camera): number;
  69070. }
  69071. /**
  69072. * Base implementation IShadowLight
  69073. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69074. */
  69075. export abstract class ShadowLight extends Light implements IShadowLight {
  69076. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69077. protected _position: Vector3;
  69078. protected _setPosition(value: Vector3): void;
  69079. /**
  69080. * Sets the position the shadow will be casted from. Also use as the light position for both
  69081. * point and spot lights.
  69082. */
  69083. /**
  69084. * Sets the position the shadow will be casted from. Also use as the light position for both
  69085. * point and spot lights.
  69086. */
  69087. position: Vector3;
  69088. protected _direction: Vector3;
  69089. protected _setDirection(value: Vector3): void;
  69090. /**
  69091. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69092. * Also use as the light direction on spot and directional lights.
  69093. */
  69094. /**
  69095. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69096. * Also use as the light direction on spot and directional lights.
  69097. */
  69098. direction: Vector3;
  69099. private _shadowMinZ;
  69100. /**
  69101. * Gets the shadow projection clipping minimum z value.
  69102. */
  69103. /**
  69104. * Sets the shadow projection clipping minimum z value.
  69105. */
  69106. shadowMinZ: number;
  69107. private _shadowMaxZ;
  69108. /**
  69109. * Sets the shadow projection clipping maximum z value.
  69110. */
  69111. /**
  69112. * Gets the shadow projection clipping maximum z value.
  69113. */
  69114. shadowMaxZ: number;
  69115. /**
  69116. * Callback defining a custom Projection Matrix Builder.
  69117. * This can be used to override the default projection matrix computation.
  69118. */
  69119. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69120. /**
  69121. * The transformed position. Position of the light in world space taking parenting in account.
  69122. */
  69123. transformedPosition: Vector3;
  69124. /**
  69125. * The transformed direction. Direction of the light in world space taking parenting in account.
  69126. */
  69127. transformedDirection: Vector3;
  69128. private _needProjectionMatrixCompute;
  69129. /**
  69130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69132. */
  69133. computeTransformedInformation(): boolean;
  69134. /**
  69135. * Return the depth scale used for the shadow map.
  69136. * @returns the depth scale.
  69137. */
  69138. getDepthScale(): number;
  69139. /**
  69140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69143. */
  69144. getShadowDirection(faceIndex?: number): Vector3;
  69145. /**
  69146. * Returns the ShadowLight absolute position in the World.
  69147. * @returns the position vector in world space
  69148. */
  69149. getAbsolutePosition(): Vector3;
  69150. /**
  69151. * Sets the ShadowLight direction toward the passed target.
  69152. * @param target The point to target in local space
  69153. * @returns the updated ShadowLight direction
  69154. */
  69155. setDirectionToTarget(target: Vector3): Vector3;
  69156. /**
  69157. * Returns the light rotation in euler definition.
  69158. * @returns the x y z rotation in local space.
  69159. */
  69160. getRotation(): Vector3;
  69161. /**
  69162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69163. * @returns true if a cube texture needs to be use
  69164. */
  69165. needCube(): boolean;
  69166. /**
  69167. * Detects if the projection matrix requires to be recomputed this frame.
  69168. * @returns true if it requires to be recomputed otherwise, false.
  69169. */
  69170. needProjectionMatrixCompute(): boolean;
  69171. /**
  69172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69173. */
  69174. forceProjectionMatrixCompute(): void;
  69175. /** @hidden */
  69176. _initCache(): void;
  69177. /** @hidden */
  69178. _isSynchronized(): boolean;
  69179. /**
  69180. * Computes the world matrix of the node
  69181. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69182. * @returns the world matrix
  69183. */
  69184. computeWorldMatrix(force?: boolean): Matrix;
  69185. /**
  69186. * Gets the minZ used for shadow according to both the scene and the light.
  69187. * @param activeCamera The camera we are returning the min for
  69188. * @returns the depth min z
  69189. */
  69190. getDepthMinZ(activeCamera: Camera): number;
  69191. /**
  69192. * Gets the maxZ used for shadow according to both the scene and the light.
  69193. * @param activeCamera The camera we are returning the max for
  69194. * @returns the depth max z
  69195. */
  69196. getDepthMaxZ(activeCamera: Camera): number;
  69197. /**
  69198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69199. * @param matrix The materix to updated with the projection information
  69200. * @param viewMatrix The transform matrix of the light
  69201. * @param renderList The list of mesh to render in the map
  69202. * @returns The current light
  69203. */
  69204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69205. }
  69206. }
  69207. declare module BABYLON {
  69208. /**
  69209. * "Static Class" containing the most commonly used helper while dealing with material for
  69210. * rendering purpose.
  69211. *
  69212. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69213. *
  69214. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69215. */
  69216. export class MaterialHelper {
  69217. /**
  69218. * Bind the current view position to an effect.
  69219. * @param effect The effect to be bound
  69220. * @param scene The scene the eyes position is used from
  69221. */
  69222. static BindEyePosition(effect: Effect, scene: Scene): void;
  69223. /**
  69224. * Helps preparing the defines values about the UVs in used in the effect.
  69225. * UVs are shared as much as we can accross channels in the shaders.
  69226. * @param texture The texture we are preparing the UVs for
  69227. * @param defines The defines to update
  69228. * @param key The channel key "diffuse", "specular"... used in the shader
  69229. */
  69230. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69231. /**
  69232. * Binds a texture matrix value to its corrsponding uniform
  69233. * @param texture The texture to bind the matrix for
  69234. * @param uniformBuffer The uniform buffer receivin the data
  69235. * @param key The channel key "diffuse", "specular"... used in the shader
  69236. */
  69237. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69238. /**
  69239. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69240. * @param mesh defines the current mesh
  69241. * @param scene defines the current scene
  69242. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69243. * @param pointsCloud defines if point cloud rendering has to be turned on
  69244. * @param fogEnabled defines if fog has to be turned on
  69245. * @param alphaTest defines if alpha testing has to be turned on
  69246. * @param defines defines the current list of defines
  69247. */
  69248. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69249. /**
  69250. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69251. * @param scene defines the current scene
  69252. * @param engine defines the current engine
  69253. * @param defines specifies the list of active defines
  69254. * @param useInstances defines if instances have to be turned on
  69255. * @param useClipPlane defines if clip plane have to be turned on
  69256. */
  69257. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69258. /**
  69259. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69260. * @param mesh The mesh containing the geometry data we will draw
  69261. * @param defines The defines to update
  69262. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69263. * @param useBones Precise whether bones should be used or not (override mesh info)
  69264. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69265. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69266. * @returns false if defines are considered not dirty and have not been checked
  69267. */
  69268. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69269. /**
  69270. * Prepares the defines related to multiview
  69271. * @param scene The scene we are intending to draw
  69272. * @param defines The defines to update
  69273. */
  69274. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69275. /**
  69276. * Prepares the defines related to the light information passed in parameter
  69277. * @param scene The scene we are intending to draw
  69278. * @param mesh The mesh the effect is compiling for
  69279. * @param defines The defines to update
  69280. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69281. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69282. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69283. * @returns true if normals will be required for the rest of the effect
  69284. */
  69285. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69286. /**
  69287. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69288. * that won t be acctive due to defines being turned off.
  69289. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69290. * @param samplersList The samplers list
  69291. * @param defines The defines helping in the list generation
  69292. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69293. */
  69294. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69295. /**
  69296. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69297. * @param defines The defines to update while falling back
  69298. * @param fallbacks The authorized effect fallbacks
  69299. * @param maxSimultaneousLights The maximum number of lights allowed
  69300. * @param rank the current rank of the Effect
  69301. * @returns The newly affected rank
  69302. */
  69303. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69304. /**
  69305. * Prepares the list of attributes required for morph targets according to the effect defines.
  69306. * @param attribs The current list of supported attribs
  69307. * @param mesh The mesh to prepare the morph targets attributes for
  69308. * @param defines The current Defines of the effect
  69309. */
  69310. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69311. /**
  69312. * Prepares the list of attributes required for bones according to the effect defines.
  69313. * @param attribs The current list of supported attribs
  69314. * @param mesh The mesh to prepare the bones attributes for
  69315. * @param defines The current Defines of the effect
  69316. * @param fallbacks The current efffect fallback strategy
  69317. */
  69318. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69319. /**
  69320. * Prepares the list of attributes required for instances according to the effect defines.
  69321. * @param attribs The current list of supported attribs
  69322. * @param defines The current Defines of the effect
  69323. */
  69324. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69325. /**
  69326. * Binds the light shadow information to the effect for the given mesh.
  69327. * @param light The light containing the generator
  69328. * @param scene The scene the lights belongs to
  69329. * @param mesh The mesh we are binding the information to render
  69330. * @param lightIndex The light index in the effect used to render the mesh
  69331. * @param effect The effect we are binding the data to
  69332. */
  69333. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69334. /**
  69335. * Binds the light information to the effect.
  69336. * @param light The light containing the generator
  69337. * @param effect The effect we are binding the data to
  69338. * @param lightIndex The light index in the effect used to render
  69339. */
  69340. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69341. /**
  69342. * Binds the lights information from the scene to the effect for the given mesh.
  69343. * @param scene The scene the lights belongs to
  69344. * @param mesh The mesh we are binding the information to render
  69345. * @param effect The effect we are binding the data to
  69346. * @param defines The generated defines for the effect
  69347. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69348. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69349. */
  69350. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69351. private static _tempFogColor;
  69352. /**
  69353. * Binds the fog information from the scene to the effect for the given mesh.
  69354. * @param scene The scene the lights belongs to
  69355. * @param mesh The mesh we are binding the information to render
  69356. * @param effect The effect we are binding the data to
  69357. * @param linearSpace Defines if the fog effect is applied in linear space
  69358. */
  69359. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69360. /**
  69361. * Binds the bones information from the mesh to the effect.
  69362. * @param mesh The mesh we are binding the information to render
  69363. * @param effect The effect we are binding the data to
  69364. */
  69365. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69366. /**
  69367. * Binds the morph targets information from the mesh to the effect.
  69368. * @param abstractMesh The mesh we are binding the information to render
  69369. * @param effect The effect we are binding the data to
  69370. */
  69371. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69372. /**
  69373. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69374. * @param defines The generated defines used in the effect
  69375. * @param effect The effect we are binding the data to
  69376. * @param scene The scene we are willing to render with logarithmic scale for
  69377. */
  69378. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69379. /**
  69380. * Binds the clip plane information from the scene to the effect.
  69381. * @param scene The scene the clip plane information are extracted from
  69382. * @param effect The effect we are binding the data to
  69383. */
  69384. static BindClipPlane(effect: Effect, scene: Scene): void;
  69385. }
  69386. }
  69387. declare module BABYLON {
  69388. /** @hidden */
  69389. export var kernelBlurVaryingDeclaration: {
  69390. name: string;
  69391. shader: string;
  69392. };
  69393. }
  69394. declare module BABYLON {
  69395. /** @hidden */
  69396. export var kernelBlurFragment: {
  69397. name: string;
  69398. shader: string;
  69399. };
  69400. }
  69401. declare module BABYLON {
  69402. /** @hidden */
  69403. export var kernelBlurFragment2: {
  69404. name: string;
  69405. shader: string;
  69406. };
  69407. }
  69408. declare module BABYLON {
  69409. /** @hidden */
  69410. export var kernelBlurPixelShader: {
  69411. name: string;
  69412. shader: string;
  69413. };
  69414. }
  69415. declare module BABYLON {
  69416. /** @hidden */
  69417. export var kernelBlurVertex: {
  69418. name: string;
  69419. shader: string;
  69420. };
  69421. }
  69422. declare module BABYLON {
  69423. /** @hidden */
  69424. export var kernelBlurVertexShader: {
  69425. name: string;
  69426. shader: string;
  69427. };
  69428. }
  69429. declare module BABYLON {
  69430. /**
  69431. * The Blur Post Process which blurs an image based on a kernel and direction.
  69432. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69433. */
  69434. export class BlurPostProcess extends PostProcess {
  69435. /** The direction in which to blur the image. */
  69436. direction: Vector2;
  69437. private blockCompilation;
  69438. protected _kernel: number;
  69439. protected _idealKernel: number;
  69440. protected _packedFloat: boolean;
  69441. private _staticDefines;
  69442. /**
  69443. * Sets the length in pixels of the blur sample region
  69444. */
  69445. /**
  69446. * Gets the length in pixels of the blur sample region
  69447. */
  69448. kernel: number;
  69449. /**
  69450. * Sets wether or not the blur needs to unpack/repack floats
  69451. */
  69452. /**
  69453. * Gets wether or not the blur is unpacking/repacking floats
  69454. */
  69455. packedFloat: boolean;
  69456. /**
  69457. * Creates a new instance BlurPostProcess
  69458. * @param name The name of the effect.
  69459. * @param direction The direction in which to blur the image.
  69460. * @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.
  69461. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69462. * @param camera The camera to apply the render pass to.
  69463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69464. * @param engine The engine which the post process will be applied. (default: current engine)
  69465. * @param reusable If the post process can be reused on the same frame. (default: false)
  69466. * @param textureType Type of textures used when performing the post process. (default: 0)
  69467. * @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)
  69468. */
  69469. constructor(name: string,
  69470. /** The direction in which to blur the image. */
  69471. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69472. /**
  69473. * Updates the effect with the current post process compile time values and recompiles the shader.
  69474. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69475. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69476. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69477. * @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
  69478. * @param onCompiled Called when the shader has been compiled.
  69479. * @param onError Called if there is an error when compiling a shader.
  69480. */
  69481. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69482. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69483. /**
  69484. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69485. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69486. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69487. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69488. * The gaps between physical kernels are compensated for in the weighting of the samples
  69489. * @param idealKernel Ideal blur kernel.
  69490. * @return Nearest best kernel.
  69491. */
  69492. protected _nearestBestKernel(idealKernel: number): number;
  69493. /**
  69494. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69495. * @param x The point on the Gaussian distribution to sample.
  69496. * @return the value of the Gaussian function at x.
  69497. */
  69498. protected _gaussianWeight(x: number): number;
  69499. /**
  69500. * Generates a string that can be used as a floating point number in GLSL.
  69501. * @param x Value to print.
  69502. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69503. * @return GLSL float string.
  69504. */
  69505. protected _glslFloat(x: number, decimalFigures?: number): string;
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /** @hidden */
  69510. export var shadowMapPixelShader: {
  69511. name: string;
  69512. shader: string;
  69513. };
  69514. }
  69515. declare module BABYLON {
  69516. /** @hidden */
  69517. export var bonesDeclaration: {
  69518. name: string;
  69519. shader: string;
  69520. };
  69521. }
  69522. declare module BABYLON {
  69523. /** @hidden */
  69524. export var morphTargetsVertexGlobalDeclaration: {
  69525. name: string;
  69526. shader: string;
  69527. };
  69528. }
  69529. declare module BABYLON {
  69530. /** @hidden */
  69531. export var morphTargetsVertexDeclaration: {
  69532. name: string;
  69533. shader: string;
  69534. };
  69535. }
  69536. declare module BABYLON {
  69537. /** @hidden */
  69538. export var instancesDeclaration: {
  69539. name: string;
  69540. shader: string;
  69541. };
  69542. }
  69543. declare module BABYLON {
  69544. /** @hidden */
  69545. export var helperFunctions: {
  69546. name: string;
  69547. shader: string;
  69548. };
  69549. }
  69550. declare module BABYLON {
  69551. /** @hidden */
  69552. export var morphTargetsVertex: {
  69553. name: string;
  69554. shader: string;
  69555. };
  69556. }
  69557. declare module BABYLON {
  69558. /** @hidden */
  69559. export var instancesVertex: {
  69560. name: string;
  69561. shader: string;
  69562. };
  69563. }
  69564. declare module BABYLON {
  69565. /** @hidden */
  69566. export var bonesVertex: {
  69567. name: string;
  69568. shader: string;
  69569. };
  69570. }
  69571. declare module BABYLON {
  69572. /** @hidden */
  69573. export var shadowMapVertexShader: {
  69574. name: string;
  69575. shader: string;
  69576. };
  69577. }
  69578. declare module BABYLON {
  69579. /** @hidden */
  69580. export var depthBoxBlurPixelShader: {
  69581. name: string;
  69582. shader: string;
  69583. };
  69584. }
  69585. declare module BABYLON {
  69586. /**
  69587. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69588. */
  69589. export interface ICustomShaderOptions {
  69590. /**
  69591. * Gets or sets the custom shader name to use
  69592. */
  69593. shaderName: string;
  69594. /**
  69595. * The list of attribute names used in the shader
  69596. */
  69597. attributes?: string[];
  69598. /**
  69599. * The list of unifrom names used in the shader
  69600. */
  69601. uniforms?: string[];
  69602. /**
  69603. * The list of sampler names used in the shader
  69604. */
  69605. samplers?: string[];
  69606. /**
  69607. * The list of defines used in the shader
  69608. */
  69609. defines?: string[];
  69610. }
  69611. /**
  69612. * Interface to implement to create a shadow generator compatible with BJS.
  69613. */
  69614. export interface IShadowGenerator {
  69615. /**
  69616. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69617. * @returns The render target texture if present otherwise, null
  69618. */
  69619. getShadowMap(): Nullable<RenderTargetTexture>;
  69620. /**
  69621. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69622. * @returns The render target texture if the shadow map is present otherwise, null
  69623. */
  69624. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69625. /**
  69626. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69627. * @param subMesh The submesh we want to render in the shadow map
  69628. * @param useInstances Defines wether will draw in the map using instances
  69629. * @returns true if ready otherwise, false
  69630. */
  69631. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69632. /**
  69633. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69634. * @param defines Defines of the material we want to update
  69635. * @param lightIndex Index of the light in the enabled light list of the material
  69636. */
  69637. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69638. /**
  69639. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69640. * defined in the generator but impacting the effect).
  69641. * It implies the unifroms available on the materials are the standard BJS ones.
  69642. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69643. * @param effect The effect we are binfing the information for
  69644. */
  69645. bindShadowLight(lightIndex: string, effect: Effect): void;
  69646. /**
  69647. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69648. * (eq to shadow prjection matrix * light transform matrix)
  69649. * @returns The transform matrix used to create the shadow map
  69650. */
  69651. getTransformMatrix(): Matrix;
  69652. /**
  69653. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69654. * Cube and 2D textures for instance.
  69655. */
  69656. recreateShadowMap(): void;
  69657. /**
  69658. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69659. * @param onCompiled Callback triggered at the and of the effects compilation
  69660. * @param options Sets of optional options forcing the compilation with different modes
  69661. */
  69662. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69663. useInstances: boolean;
  69664. }>): void;
  69665. /**
  69666. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69667. * @param options Sets of optional options forcing the compilation with different modes
  69668. * @returns A promise that resolves when the compilation completes
  69669. */
  69670. forceCompilationAsync(options?: Partial<{
  69671. useInstances: boolean;
  69672. }>): Promise<void>;
  69673. /**
  69674. * Serializes the shadow generator setup to a json object.
  69675. * @returns The serialized JSON object
  69676. */
  69677. serialize(): any;
  69678. /**
  69679. * Disposes the Shadow map and related Textures and effects.
  69680. */
  69681. dispose(): void;
  69682. }
  69683. /**
  69684. * Default implementation IShadowGenerator.
  69685. * This is the main object responsible of generating shadows in the framework.
  69686. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69687. */
  69688. export class ShadowGenerator implements IShadowGenerator {
  69689. /**
  69690. * Shadow generator mode None: no filtering applied.
  69691. */
  69692. static readonly FILTER_NONE: number;
  69693. /**
  69694. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69695. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69696. */
  69697. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69698. /**
  69699. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69700. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69701. */
  69702. static readonly FILTER_POISSONSAMPLING: number;
  69703. /**
  69704. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69705. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69706. */
  69707. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69708. /**
  69709. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69710. * edge artifacts on steep falloff.
  69711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69712. */
  69713. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69714. /**
  69715. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69716. * edge artifacts on steep falloff.
  69717. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69718. */
  69719. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69720. /**
  69721. * Shadow generator mode PCF: Percentage Closer Filtering
  69722. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69723. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69724. */
  69725. static readonly FILTER_PCF: number;
  69726. /**
  69727. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69728. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69729. * Contact Hardening
  69730. */
  69731. static readonly FILTER_PCSS: number;
  69732. /**
  69733. * Reserved for PCF and PCSS
  69734. * Highest Quality.
  69735. *
  69736. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69737. *
  69738. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69739. */
  69740. static readonly QUALITY_HIGH: number;
  69741. /**
  69742. * Reserved for PCF and PCSS
  69743. * Good tradeoff for quality/perf cross devices
  69744. *
  69745. * Execute PCF on a 3*3 kernel.
  69746. *
  69747. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69748. */
  69749. static readonly QUALITY_MEDIUM: number;
  69750. /**
  69751. * Reserved for PCF and PCSS
  69752. * The lowest quality but the fastest.
  69753. *
  69754. * Execute PCF on a 1*1 kernel.
  69755. *
  69756. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69757. */
  69758. static readonly QUALITY_LOW: number;
  69759. /** Gets or sets the custom shader name to use */
  69760. customShaderOptions: ICustomShaderOptions;
  69761. /**
  69762. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69763. */
  69764. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69765. /**
  69766. * Observable triggered before a mesh is rendered in the shadow map.
  69767. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69768. */
  69769. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69770. private _bias;
  69771. /**
  69772. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69773. */
  69774. /**
  69775. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69776. */
  69777. bias: number;
  69778. private _normalBias;
  69779. /**
  69780. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69781. */
  69782. /**
  69783. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69784. */
  69785. normalBias: number;
  69786. private _blurBoxOffset;
  69787. /**
  69788. * Gets the blur box offset: offset applied during the blur pass.
  69789. * Only useful if useKernelBlur = false
  69790. */
  69791. /**
  69792. * Sets the blur box offset: offset applied during the blur pass.
  69793. * Only useful if useKernelBlur = false
  69794. */
  69795. blurBoxOffset: number;
  69796. private _blurScale;
  69797. /**
  69798. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69799. * 2 means half of the size.
  69800. */
  69801. /**
  69802. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69803. * 2 means half of the size.
  69804. */
  69805. blurScale: number;
  69806. private _blurKernel;
  69807. /**
  69808. * Gets the blur kernel: kernel size of the blur pass.
  69809. * Only useful if useKernelBlur = true
  69810. */
  69811. /**
  69812. * Sets the blur kernel: kernel size of the blur pass.
  69813. * Only useful if useKernelBlur = true
  69814. */
  69815. blurKernel: number;
  69816. private _useKernelBlur;
  69817. /**
  69818. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69819. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69820. */
  69821. /**
  69822. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69823. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69824. */
  69825. useKernelBlur: boolean;
  69826. private _depthScale;
  69827. /**
  69828. * Gets the depth scale used in ESM mode.
  69829. */
  69830. /**
  69831. * Sets the depth scale used in ESM mode.
  69832. * This can override the scale stored on the light.
  69833. */
  69834. depthScale: number;
  69835. private _filter;
  69836. /**
  69837. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69838. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69839. */
  69840. /**
  69841. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69842. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69843. */
  69844. filter: number;
  69845. /**
  69846. * Gets if the current filter is set to Poisson Sampling.
  69847. */
  69848. /**
  69849. * Sets the current filter to Poisson Sampling.
  69850. */
  69851. usePoissonSampling: boolean;
  69852. /**
  69853. * Gets if the current filter is set to ESM.
  69854. */
  69855. /**
  69856. * Sets the current filter is to ESM.
  69857. */
  69858. useExponentialShadowMap: boolean;
  69859. /**
  69860. * Gets if the current filter is set to filtered ESM.
  69861. */
  69862. /**
  69863. * Gets if the current filter is set to filtered ESM.
  69864. */
  69865. useBlurExponentialShadowMap: boolean;
  69866. /**
  69867. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69868. * exponential to prevent steep falloff artifacts).
  69869. */
  69870. /**
  69871. * Sets the current filter to "close ESM" (using the inverse of the
  69872. * exponential to prevent steep falloff artifacts).
  69873. */
  69874. useCloseExponentialShadowMap: boolean;
  69875. /**
  69876. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69877. * exponential to prevent steep falloff artifacts).
  69878. */
  69879. /**
  69880. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69881. * exponential to prevent steep falloff artifacts).
  69882. */
  69883. useBlurCloseExponentialShadowMap: boolean;
  69884. /**
  69885. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69886. */
  69887. /**
  69888. * Sets the current filter to "PCF" (percentage closer filtering).
  69889. */
  69890. usePercentageCloserFiltering: boolean;
  69891. private _filteringQuality;
  69892. /**
  69893. * Gets the PCF or PCSS Quality.
  69894. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69895. */
  69896. /**
  69897. * Sets the PCF or PCSS Quality.
  69898. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69899. */
  69900. filteringQuality: number;
  69901. /**
  69902. * Gets if the current filter is set to "PCSS" (contact hardening).
  69903. */
  69904. /**
  69905. * Sets the current filter to "PCSS" (contact hardening).
  69906. */
  69907. useContactHardeningShadow: boolean;
  69908. private _contactHardeningLightSizeUVRatio;
  69909. /**
  69910. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69911. * Using a ratio helps keeping shape stability independently of the map size.
  69912. *
  69913. * It does not account for the light projection as it was having too much
  69914. * instability during the light setup or during light position changes.
  69915. *
  69916. * Only valid if useContactHardeningShadow is true.
  69917. */
  69918. /**
  69919. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69920. * Using a ratio helps keeping shape stability independently of the map size.
  69921. *
  69922. * It does not account for the light projection as it was having too much
  69923. * instability during the light setup or during light position changes.
  69924. *
  69925. * Only valid if useContactHardeningShadow is true.
  69926. */
  69927. contactHardeningLightSizeUVRatio: number;
  69928. private _darkness;
  69929. /**
  69930. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69931. * 0 means strongest and 1 would means no shadow.
  69932. * @returns the darkness.
  69933. */
  69934. getDarkness(): number;
  69935. /**
  69936. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69937. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69938. * @returns the shadow generator allowing fluent coding.
  69939. */
  69940. setDarkness(darkness: number): ShadowGenerator;
  69941. private _transparencyShadow;
  69942. /**
  69943. * Sets the ability to have transparent shadow (boolean).
  69944. * @param transparent True if transparent else False
  69945. * @returns the shadow generator allowing fluent coding
  69946. */
  69947. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69948. private _shadowMap;
  69949. private _shadowMap2;
  69950. /**
  69951. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69952. * @returns The render target texture if present otherwise, null
  69953. */
  69954. getShadowMap(): Nullable<RenderTargetTexture>;
  69955. /**
  69956. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69957. * @returns The render target texture if the shadow map is present otherwise, null
  69958. */
  69959. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69960. /**
  69961. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69962. * @param mesh Mesh to add
  69963. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69964. * @returns the Shadow Generator itself
  69965. */
  69966. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69967. /**
  69968. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69969. * @param mesh Mesh to remove
  69970. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69971. * @returns the Shadow Generator itself
  69972. */
  69973. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69974. /**
  69975. * Controls the extent to which the shadows fade out at the edge of the frustum
  69976. * Used only by directionals and spots
  69977. */
  69978. frustumEdgeFalloff: number;
  69979. private _light;
  69980. /**
  69981. * Returns the associated light object.
  69982. * @returns the light generating the shadow
  69983. */
  69984. getLight(): IShadowLight;
  69985. /**
  69986. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69987. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69988. * It might on the other hand introduce peter panning.
  69989. */
  69990. forceBackFacesOnly: boolean;
  69991. private _scene;
  69992. private _lightDirection;
  69993. private _effect;
  69994. private _viewMatrix;
  69995. private _projectionMatrix;
  69996. private _transformMatrix;
  69997. private _cachedPosition;
  69998. private _cachedDirection;
  69999. private _cachedDefines;
  70000. private _currentRenderID;
  70001. private _boxBlurPostprocess;
  70002. private _kernelBlurXPostprocess;
  70003. private _kernelBlurYPostprocess;
  70004. private _blurPostProcesses;
  70005. private _mapSize;
  70006. private _currentFaceIndex;
  70007. private _currentFaceIndexCache;
  70008. private _textureType;
  70009. private _defaultTextureMatrix;
  70010. /** @hidden */
  70011. static _SceneComponentInitialization: (scene: Scene) => void;
  70012. /**
  70013. * Creates a ShadowGenerator object.
  70014. * A ShadowGenerator is the required tool to use the shadows.
  70015. * Each light casting shadows needs to use its own ShadowGenerator.
  70016. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70017. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70018. * @param light The light object generating the shadows.
  70019. * @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.
  70020. */
  70021. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70022. private _initializeGenerator;
  70023. private _initializeShadowMap;
  70024. private _initializeBlurRTTAndPostProcesses;
  70025. private _renderForShadowMap;
  70026. private _renderSubMeshForShadowMap;
  70027. private _applyFilterValues;
  70028. /**
  70029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70030. * @param onCompiled Callback triggered at the and of the effects compilation
  70031. * @param options Sets of optional options forcing the compilation with different modes
  70032. */
  70033. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70034. useInstances: boolean;
  70035. }>): void;
  70036. /**
  70037. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70038. * @param options Sets of optional options forcing the compilation with different modes
  70039. * @returns A promise that resolves when the compilation completes
  70040. */
  70041. forceCompilationAsync(options?: Partial<{
  70042. useInstances: boolean;
  70043. }>): Promise<void>;
  70044. /**
  70045. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70046. * @param subMesh The submesh we want to render in the shadow map
  70047. * @param useInstances Defines wether will draw in the map using instances
  70048. * @returns true if ready otherwise, false
  70049. */
  70050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70051. /**
  70052. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70053. * @param defines Defines of the material we want to update
  70054. * @param lightIndex Index of the light in the enabled light list of the material
  70055. */
  70056. prepareDefines(defines: any, lightIndex: number): void;
  70057. /**
  70058. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70059. * defined in the generator but impacting the effect).
  70060. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70061. * @param effect The effect we are binfing the information for
  70062. */
  70063. bindShadowLight(lightIndex: string, effect: Effect): void;
  70064. /**
  70065. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70066. * (eq to shadow prjection matrix * light transform matrix)
  70067. * @returns The transform matrix used to create the shadow map
  70068. */
  70069. getTransformMatrix(): Matrix;
  70070. /**
  70071. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70072. * Cube and 2D textures for instance.
  70073. */
  70074. recreateShadowMap(): void;
  70075. private _disposeBlurPostProcesses;
  70076. private _disposeRTTandPostProcesses;
  70077. /**
  70078. * Disposes the ShadowGenerator.
  70079. * Returns nothing.
  70080. */
  70081. dispose(): void;
  70082. /**
  70083. * Serializes the shadow generator setup to a json object.
  70084. * @returns The serialized JSON object
  70085. */
  70086. serialize(): any;
  70087. /**
  70088. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70089. * @param parsedShadowGenerator The JSON object to parse
  70090. * @param scene The scene to create the shadow map for
  70091. * @returns The parsed shadow generator
  70092. */
  70093. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70094. }
  70095. }
  70096. declare module BABYLON {
  70097. /**
  70098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70100. * 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.
  70101. */
  70102. export abstract class Light extends Node {
  70103. /**
  70104. * Falloff Default: light is falling off following the material specification:
  70105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70106. */
  70107. static readonly FALLOFF_DEFAULT: number;
  70108. /**
  70109. * Falloff Physical: light is falling off following the inverse squared distance law.
  70110. */
  70111. static readonly FALLOFF_PHYSICAL: number;
  70112. /**
  70113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70114. * to enhance interoperability with other engines.
  70115. */
  70116. static readonly FALLOFF_GLTF: number;
  70117. /**
  70118. * Falloff Standard: light is falling off like in the standard material
  70119. * to enhance interoperability with other materials.
  70120. */
  70121. static readonly FALLOFF_STANDARD: number;
  70122. /**
  70123. * If every light affecting the material is in this lightmapMode,
  70124. * material.lightmapTexture adds or multiplies
  70125. * (depends on material.useLightmapAsShadowmap)
  70126. * after every other light calculations.
  70127. */
  70128. static readonly LIGHTMAP_DEFAULT: number;
  70129. /**
  70130. * material.lightmapTexture as only diffuse lighting from this light
  70131. * adds only specular lighting from this light
  70132. * adds dynamic shadows
  70133. */
  70134. static readonly LIGHTMAP_SPECULAR: number;
  70135. /**
  70136. * material.lightmapTexture as only lighting
  70137. * no light calculation from this light
  70138. * only adds dynamic shadows from this light
  70139. */
  70140. static readonly LIGHTMAP_SHADOWSONLY: number;
  70141. /**
  70142. * Each light type uses the default quantity according to its type:
  70143. * point/spot lights use luminous intensity
  70144. * directional lights use illuminance
  70145. */
  70146. static readonly INTENSITYMODE_AUTOMATIC: number;
  70147. /**
  70148. * lumen (lm)
  70149. */
  70150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70151. /**
  70152. * candela (lm/sr)
  70153. */
  70154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70155. /**
  70156. * lux (lm/m^2)
  70157. */
  70158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70159. /**
  70160. * nit (cd/m^2)
  70161. */
  70162. static readonly INTENSITYMODE_LUMINANCE: number;
  70163. /**
  70164. * Light type const id of the point light.
  70165. */
  70166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70167. /**
  70168. * Light type const id of the directional light.
  70169. */
  70170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70171. /**
  70172. * Light type const id of the spot light.
  70173. */
  70174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70175. /**
  70176. * Light type const id of the hemispheric light.
  70177. */
  70178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70179. /**
  70180. * Diffuse gives the basic color to an object.
  70181. */
  70182. diffuse: Color3;
  70183. /**
  70184. * Specular produces a highlight color on an object.
  70185. * Note: This is note affecting PBR materials.
  70186. */
  70187. specular: Color3;
  70188. /**
  70189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70190. * falling off base on range or angle.
  70191. * This can be set to any values in Light.FALLOFF_x.
  70192. *
  70193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70194. * other types of materials.
  70195. */
  70196. falloffType: number;
  70197. /**
  70198. * Strength of the light.
  70199. * Note: By default it is define in the framework own unit.
  70200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70201. */
  70202. intensity: number;
  70203. private _range;
  70204. protected _inverseSquaredRange: number;
  70205. /**
  70206. * Defines how far from the source the light is impacting in scene units.
  70207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70208. */
  70209. /**
  70210. * Defines how far from the source the light is impacting in scene units.
  70211. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70212. */
  70213. range: number;
  70214. /**
  70215. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70216. * of light.
  70217. */
  70218. private _photometricScale;
  70219. private _intensityMode;
  70220. /**
  70221. * Gets the photometric scale used to interpret the intensity.
  70222. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70223. */
  70224. /**
  70225. * Sets the photometric scale used to interpret the intensity.
  70226. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70227. */
  70228. intensityMode: number;
  70229. private _radius;
  70230. /**
  70231. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70232. */
  70233. /**
  70234. * sets the light radius used by PBR Materials to simulate soft area lights.
  70235. */
  70236. radius: number;
  70237. private _renderPriority;
  70238. /**
  70239. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70240. * exceeding the number allowed of the materials.
  70241. */
  70242. renderPriority: number;
  70243. private _shadowEnabled;
  70244. /**
  70245. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70246. * the current shadow generator.
  70247. */
  70248. /**
  70249. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70250. * the current shadow generator.
  70251. */
  70252. shadowEnabled: boolean;
  70253. private _includedOnlyMeshes;
  70254. /**
  70255. * Gets the only meshes impacted by this light.
  70256. */
  70257. /**
  70258. * Sets the only meshes impacted by this light.
  70259. */
  70260. includedOnlyMeshes: AbstractMesh[];
  70261. private _excludedMeshes;
  70262. /**
  70263. * Gets the meshes not impacted by this light.
  70264. */
  70265. /**
  70266. * Sets the meshes not impacted by this light.
  70267. */
  70268. excludedMeshes: AbstractMesh[];
  70269. private _excludeWithLayerMask;
  70270. /**
  70271. * Gets the layer id use to find what meshes are not impacted by the light.
  70272. * Inactive if 0
  70273. */
  70274. /**
  70275. * Sets the layer id use to find what meshes are not impacted by the light.
  70276. * Inactive if 0
  70277. */
  70278. excludeWithLayerMask: number;
  70279. private _includeOnlyWithLayerMask;
  70280. /**
  70281. * Gets the layer id use to find what meshes are impacted by the light.
  70282. * Inactive if 0
  70283. */
  70284. /**
  70285. * Sets the layer id use to find what meshes are impacted by the light.
  70286. * Inactive if 0
  70287. */
  70288. includeOnlyWithLayerMask: number;
  70289. private _lightmapMode;
  70290. /**
  70291. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70292. */
  70293. /**
  70294. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70295. */
  70296. lightmapMode: number;
  70297. /**
  70298. * Shadow generator associted to the light.
  70299. * @hidden Internal use only.
  70300. */
  70301. _shadowGenerator: Nullable<IShadowGenerator>;
  70302. /**
  70303. * @hidden Internal use only.
  70304. */
  70305. _excludedMeshesIds: string[];
  70306. /**
  70307. * @hidden Internal use only.
  70308. */
  70309. _includedOnlyMeshesIds: string[];
  70310. /**
  70311. * The current light unifom buffer.
  70312. * @hidden Internal use only.
  70313. */
  70314. _uniformBuffer: UniformBuffer;
  70315. /**
  70316. * Creates a Light object in the scene.
  70317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70318. * @param name The firendly name of the light
  70319. * @param scene The scene the light belongs too
  70320. */
  70321. constructor(name: string, scene: Scene);
  70322. protected abstract _buildUniformLayout(): void;
  70323. /**
  70324. * Sets the passed Effect "effect" with the Light information.
  70325. * @param effect The effect to update
  70326. * @param lightIndex The index of the light in the effect to update
  70327. * @returns The light
  70328. */
  70329. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70330. /**
  70331. * Returns the string "Light".
  70332. * @returns the class name
  70333. */
  70334. getClassName(): string;
  70335. /** @hidden */
  70336. readonly _isLight: boolean;
  70337. /**
  70338. * Converts the light information to a readable string for debug purpose.
  70339. * @param fullDetails Supports for multiple levels of logging within scene loading
  70340. * @returns the human readable light info
  70341. */
  70342. toString(fullDetails?: boolean): string;
  70343. /** @hidden */
  70344. protected _syncParentEnabledState(): void;
  70345. /**
  70346. * Set the enabled state of this node.
  70347. * @param value - the new enabled state
  70348. */
  70349. setEnabled(value: boolean): void;
  70350. /**
  70351. * Returns the Light associated shadow generator if any.
  70352. * @return the associated shadow generator.
  70353. */
  70354. getShadowGenerator(): Nullable<IShadowGenerator>;
  70355. /**
  70356. * Returns a Vector3, the absolute light position in the World.
  70357. * @returns the world space position of the light
  70358. */
  70359. getAbsolutePosition(): Vector3;
  70360. /**
  70361. * Specifies if the light will affect the passed mesh.
  70362. * @param mesh The mesh to test against the light
  70363. * @return true the mesh is affected otherwise, false.
  70364. */
  70365. canAffectMesh(mesh: AbstractMesh): boolean;
  70366. /**
  70367. * Sort function to order lights for rendering.
  70368. * @param a First Light object to compare to second.
  70369. * @param b Second Light object to compare first.
  70370. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70371. */
  70372. static CompareLightsPriority(a: Light, b: Light): number;
  70373. /**
  70374. * Releases resources associated with this node.
  70375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70377. */
  70378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70379. /**
  70380. * Returns the light type ID (integer).
  70381. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70382. */
  70383. getTypeID(): number;
  70384. /**
  70385. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70386. * @returns the scaled intensity in intensity mode unit
  70387. */
  70388. getScaledIntensity(): number;
  70389. /**
  70390. * Returns a new Light object, named "name", from the current one.
  70391. * @param name The name of the cloned light
  70392. * @returns the new created light
  70393. */
  70394. clone(name: string): Nullable<Light>;
  70395. /**
  70396. * Serializes the current light into a Serialization object.
  70397. * @returns the serialized object.
  70398. */
  70399. serialize(): any;
  70400. /**
  70401. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70402. * This new light is named "name" and added to the passed scene.
  70403. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70404. * @param name The friendly name of the light
  70405. * @param scene The scene the new light will belong to
  70406. * @returns the constructor function
  70407. */
  70408. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70409. /**
  70410. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70411. * @param parsedLight The JSON representation of the light
  70412. * @param scene The scene to create the parsed light in
  70413. * @returns the created light after parsing
  70414. */
  70415. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70416. private _hookArrayForExcluded;
  70417. private _hookArrayForIncludedOnly;
  70418. private _resyncMeshes;
  70419. /**
  70420. * Forces the meshes to update their light related information in their rendering used effects
  70421. * @hidden Internal Use Only
  70422. */
  70423. _markMeshesAsLightDirty(): void;
  70424. /**
  70425. * Recomputes the cached photometric scale if needed.
  70426. */
  70427. private _computePhotometricScale;
  70428. /**
  70429. * Returns the Photometric Scale according to the light type and intensity mode.
  70430. */
  70431. private _getPhotometricScale;
  70432. /**
  70433. * Reorder the light in the scene according to their defined priority.
  70434. * @hidden Internal Use Only
  70435. */
  70436. _reorderLightsInScene(): void;
  70437. /**
  70438. * Prepares the list of defines specific to the light type.
  70439. * @param defines the list of defines
  70440. * @param lightIndex defines the index of the light for the effect
  70441. */
  70442. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70443. }
  70444. }
  70445. declare module BABYLON {
  70446. /**
  70447. * Interface used to define Action
  70448. */
  70449. export interface IAction {
  70450. /**
  70451. * Trigger for the action
  70452. */
  70453. trigger: number;
  70454. /** Options of the trigger */
  70455. triggerOptions: any;
  70456. /**
  70457. * Gets the trigger parameters
  70458. * @returns the trigger parameters
  70459. */
  70460. getTriggerParameter(): any;
  70461. /**
  70462. * Internal only - executes current action event
  70463. * @hidden
  70464. */
  70465. _executeCurrent(evt?: ActionEvent): void;
  70466. /**
  70467. * Serialize placeholder for child classes
  70468. * @param parent of child
  70469. * @returns the serialized object
  70470. */
  70471. serialize(parent: any): any;
  70472. /**
  70473. * Internal only
  70474. * @hidden
  70475. */
  70476. _prepare(): void;
  70477. /**
  70478. * Internal only - manager for action
  70479. * @hidden
  70480. */
  70481. _actionManager: AbstractActionManager;
  70482. }
  70483. /**
  70484. * The action to be carried out following a trigger
  70485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70486. */
  70487. export class Action implements IAction {
  70488. /** the trigger, with or without parameters, for the action */
  70489. triggerOptions: any;
  70490. /**
  70491. * Trigger for the action
  70492. */
  70493. trigger: number;
  70494. /**
  70495. * Internal only - manager for action
  70496. * @hidden
  70497. */
  70498. _actionManager: ActionManager;
  70499. private _nextActiveAction;
  70500. private _child;
  70501. private _condition?;
  70502. private _triggerParameter;
  70503. /**
  70504. * An event triggered prior to action being executed.
  70505. */
  70506. onBeforeExecuteObservable: Observable<Action>;
  70507. /**
  70508. * Creates a new Action
  70509. * @param triggerOptions the trigger, with or without parameters, for the action
  70510. * @param condition an optional determinant of action
  70511. */
  70512. constructor(
  70513. /** the trigger, with or without parameters, for the action */
  70514. triggerOptions: any, condition?: Condition);
  70515. /**
  70516. * Internal only
  70517. * @hidden
  70518. */
  70519. _prepare(): void;
  70520. /**
  70521. * Gets the trigger parameters
  70522. * @returns the trigger parameters
  70523. */
  70524. getTriggerParameter(): any;
  70525. /**
  70526. * Internal only - executes current action event
  70527. * @hidden
  70528. */
  70529. _executeCurrent(evt?: ActionEvent): void;
  70530. /**
  70531. * Execute placeholder for child classes
  70532. * @param evt optional action event
  70533. */
  70534. execute(evt?: ActionEvent): void;
  70535. /**
  70536. * Skips to next active action
  70537. */
  70538. skipToNextActiveAction(): void;
  70539. /**
  70540. * Adds action to chain of actions, may be a DoNothingAction
  70541. * @param action defines the next action to execute
  70542. * @returns The action passed in
  70543. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70544. */
  70545. then(action: Action): Action;
  70546. /**
  70547. * Internal only
  70548. * @hidden
  70549. */
  70550. _getProperty(propertyPath: string): string;
  70551. /**
  70552. * Internal only
  70553. * @hidden
  70554. */
  70555. _getEffectiveTarget(target: any, propertyPath: string): any;
  70556. /**
  70557. * Serialize placeholder for child classes
  70558. * @param parent of child
  70559. * @returns the serialized object
  70560. */
  70561. serialize(parent: any): any;
  70562. /**
  70563. * Internal only called by serialize
  70564. * @hidden
  70565. */
  70566. protected _serialize(serializedAction: any, parent?: any): any;
  70567. /**
  70568. * Internal only
  70569. * @hidden
  70570. */
  70571. static _SerializeValueAsString: (value: any) => string;
  70572. /**
  70573. * Internal only
  70574. * @hidden
  70575. */
  70576. static _GetTargetProperty: (target: Scene | Node) => {
  70577. name: string;
  70578. targetType: string;
  70579. value: string;
  70580. };
  70581. }
  70582. }
  70583. declare module BABYLON {
  70584. /**
  70585. * A Condition applied to an Action
  70586. */
  70587. export class Condition {
  70588. /**
  70589. * Internal only - manager for action
  70590. * @hidden
  70591. */
  70592. _actionManager: ActionManager;
  70593. /**
  70594. * Internal only
  70595. * @hidden
  70596. */
  70597. _evaluationId: number;
  70598. /**
  70599. * Internal only
  70600. * @hidden
  70601. */
  70602. _currentResult: boolean;
  70603. /**
  70604. * Creates a new Condition
  70605. * @param actionManager the manager of the action the condition is applied to
  70606. */
  70607. constructor(actionManager: ActionManager);
  70608. /**
  70609. * Check if the current condition is valid
  70610. * @returns a boolean
  70611. */
  70612. isValid(): boolean;
  70613. /**
  70614. * Internal only
  70615. * @hidden
  70616. */
  70617. _getProperty(propertyPath: string): string;
  70618. /**
  70619. * Internal only
  70620. * @hidden
  70621. */
  70622. _getEffectiveTarget(target: any, propertyPath: string): any;
  70623. /**
  70624. * Serialize placeholder for child classes
  70625. * @returns the serialized object
  70626. */
  70627. serialize(): any;
  70628. /**
  70629. * Internal only
  70630. * @hidden
  70631. */
  70632. protected _serialize(serializedCondition: any): any;
  70633. }
  70634. /**
  70635. * Defines specific conditional operators as extensions of Condition
  70636. */
  70637. export class ValueCondition extends Condition {
  70638. /** path to specify the property of the target the conditional operator uses */
  70639. propertyPath: string;
  70640. /** the value compared by the conditional operator against the current value of the property */
  70641. value: any;
  70642. /** the conditional operator, default ValueCondition.IsEqual */
  70643. operator: number;
  70644. /**
  70645. * Internal only
  70646. * @hidden
  70647. */
  70648. private static _IsEqual;
  70649. /**
  70650. * Internal only
  70651. * @hidden
  70652. */
  70653. private static _IsDifferent;
  70654. /**
  70655. * Internal only
  70656. * @hidden
  70657. */
  70658. private static _IsGreater;
  70659. /**
  70660. * Internal only
  70661. * @hidden
  70662. */
  70663. private static _IsLesser;
  70664. /**
  70665. * returns the number for IsEqual
  70666. */
  70667. static readonly IsEqual: number;
  70668. /**
  70669. * Returns the number for IsDifferent
  70670. */
  70671. static readonly IsDifferent: number;
  70672. /**
  70673. * Returns the number for IsGreater
  70674. */
  70675. static readonly IsGreater: number;
  70676. /**
  70677. * Returns the number for IsLesser
  70678. */
  70679. static readonly IsLesser: number;
  70680. /**
  70681. * Internal only The action manager for the condition
  70682. * @hidden
  70683. */
  70684. _actionManager: ActionManager;
  70685. /**
  70686. * Internal only
  70687. * @hidden
  70688. */
  70689. private _target;
  70690. /**
  70691. * Internal only
  70692. * @hidden
  70693. */
  70694. private _effectiveTarget;
  70695. /**
  70696. * Internal only
  70697. * @hidden
  70698. */
  70699. private _property;
  70700. /**
  70701. * Creates a new ValueCondition
  70702. * @param actionManager manager for the action the condition applies to
  70703. * @param target for the action
  70704. * @param propertyPath path to specify the property of the target the conditional operator uses
  70705. * @param value the value compared by the conditional operator against the current value of the property
  70706. * @param operator the conditional operator, default ValueCondition.IsEqual
  70707. */
  70708. constructor(actionManager: ActionManager, target: any,
  70709. /** path to specify the property of the target the conditional operator uses */
  70710. propertyPath: string,
  70711. /** the value compared by the conditional operator against the current value of the property */
  70712. value: any,
  70713. /** the conditional operator, default ValueCondition.IsEqual */
  70714. operator?: number);
  70715. /**
  70716. * Compares the given value with the property value for the specified conditional operator
  70717. * @returns the result of the comparison
  70718. */
  70719. isValid(): boolean;
  70720. /**
  70721. * Serialize the ValueCondition into a JSON compatible object
  70722. * @returns serialization object
  70723. */
  70724. serialize(): any;
  70725. /**
  70726. * Gets the name of the conditional operator for the ValueCondition
  70727. * @param operator the conditional operator
  70728. * @returns the name
  70729. */
  70730. static GetOperatorName(operator: number): string;
  70731. }
  70732. /**
  70733. * Defines a predicate condition as an extension of Condition
  70734. */
  70735. export class PredicateCondition extends Condition {
  70736. /** defines the predicate function used to validate the condition */
  70737. predicate: () => boolean;
  70738. /**
  70739. * Internal only - manager for action
  70740. * @hidden
  70741. */
  70742. _actionManager: ActionManager;
  70743. /**
  70744. * Creates a new PredicateCondition
  70745. * @param actionManager manager for the action the condition applies to
  70746. * @param predicate defines the predicate function used to validate the condition
  70747. */
  70748. constructor(actionManager: ActionManager,
  70749. /** defines the predicate function used to validate the condition */
  70750. predicate: () => boolean);
  70751. /**
  70752. * @returns the validity of the predicate condition
  70753. */
  70754. isValid(): boolean;
  70755. }
  70756. /**
  70757. * Defines a state condition as an extension of Condition
  70758. */
  70759. export class StateCondition extends Condition {
  70760. /** Value to compare with target state */
  70761. value: string;
  70762. /**
  70763. * Internal only - manager for action
  70764. * @hidden
  70765. */
  70766. _actionManager: ActionManager;
  70767. /**
  70768. * Internal only
  70769. * @hidden
  70770. */
  70771. private _target;
  70772. /**
  70773. * Creates a new StateCondition
  70774. * @param actionManager manager for the action the condition applies to
  70775. * @param target of the condition
  70776. * @param value to compare with target state
  70777. */
  70778. constructor(actionManager: ActionManager, target: any,
  70779. /** Value to compare with target state */
  70780. value: string);
  70781. /**
  70782. * Gets a boolean indicating if the current condition is met
  70783. * @returns the validity of the state
  70784. */
  70785. isValid(): boolean;
  70786. /**
  70787. * Serialize the StateCondition into a JSON compatible object
  70788. * @returns serialization object
  70789. */
  70790. serialize(): any;
  70791. }
  70792. }
  70793. declare module BABYLON {
  70794. /**
  70795. * This defines an action responsible to toggle a boolean once triggered.
  70796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70797. */
  70798. export class SwitchBooleanAction extends Action {
  70799. /**
  70800. * The path to the boolean property in the target object
  70801. */
  70802. propertyPath: string;
  70803. private _target;
  70804. private _effectiveTarget;
  70805. private _property;
  70806. /**
  70807. * Instantiate the action
  70808. * @param triggerOptions defines the trigger options
  70809. * @param target defines the object containing the boolean
  70810. * @param propertyPath defines the path to the boolean property in the target object
  70811. * @param condition defines the trigger related conditions
  70812. */
  70813. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70814. /** @hidden */
  70815. _prepare(): void;
  70816. /**
  70817. * Execute the action toggle the boolean value.
  70818. */
  70819. execute(): void;
  70820. /**
  70821. * Serializes the actions and its related information.
  70822. * @param parent defines the object to serialize in
  70823. * @returns the serialized object
  70824. */
  70825. serialize(parent: any): any;
  70826. }
  70827. /**
  70828. * This defines an action responsible to set a the state field of the target
  70829. * to a desired value once triggered.
  70830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70831. */
  70832. export class SetStateAction extends Action {
  70833. /**
  70834. * The value to store in the state field.
  70835. */
  70836. value: string;
  70837. private _target;
  70838. /**
  70839. * Instantiate the action
  70840. * @param triggerOptions defines the trigger options
  70841. * @param target defines the object containing the state property
  70842. * @param value defines the value to store in the state field
  70843. * @param condition defines the trigger related conditions
  70844. */
  70845. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70846. /**
  70847. * Execute the action and store the value on the target state property.
  70848. */
  70849. execute(): void;
  70850. /**
  70851. * Serializes the actions and its related information.
  70852. * @param parent defines the object to serialize in
  70853. * @returns the serialized object
  70854. */
  70855. serialize(parent: any): any;
  70856. }
  70857. /**
  70858. * This defines an action responsible to set a property of the target
  70859. * to a desired value once triggered.
  70860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70861. */
  70862. export class SetValueAction extends Action {
  70863. /**
  70864. * The path of the property to set in the target.
  70865. */
  70866. propertyPath: string;
  70867. /**
  70868. * The value to set in the property
  70869. */
  70870. value: any;
  70871. private _target;
  70872. private _effectiveTarget;
  70873. private _property;
  70874. /**
  70875. * Instantiate the action
  70876. * @param triggerOptions defines the trigger options
  70877. * @param target defines the object containing the property
  70878. * @param propertyPath defines the path of the property to set in the target
  70879. * @param value defines the value to set in the property
  70880. * @param condition defines the trigger related conditions
  70881. */
  70882. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70883. /** @hidden */
  70884. _prepare(): void;
  70885. /**
  70886. * Execute the action and set the targetted property to the desired value.
  70887. */
  70888. execute(): void;
  70889. /**
  70890. * Serializes the actions and its related information.
  70891. * @param parent defines the object to serialize in
  70892. * @returns the serialized object
  70893. */
  70894. serialize(parent: any): any;
  70895. }
  70896. /**
  70897. * This defines an action responsible to increment the target value
  70898. * to a desired value once triggered.
  70899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70900. */
  70901. export class IncrementValueAction extends Action {
  70902. /**
  70903. * The path of the property to increment in the target.
  70904. */
  70905. propertyPath: string;
  70906. /**
  70907. * The value we should increment the property by.
  70908. */
  70909. value: any;
  70910. private _target;
  70911. private _effectiveTarget;
  70912. private _property;
  70913. /**
  70914. * Instantiate the action
  70915. * @param triggerOptions defines the trigger options
  70916. * @param target defines the object containing the property
  70917. * @param propertyPath defines the path of the property to increment in the target
  70918. * @param value defines the value value we should increment the property by
  70919. * @param condition defines the trigger related conditions
  70920. */
  70921. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70922. /** @hidden */
  70923. _prepare(): void;
  70924. /**
  70925. * Execute the action and increment the target of the value amount.
  70926. */
  70927. execute(): void;
  70928. /**
  70929. * Serializes the actions and its related information.
  70930. * @param parent defines the object to serialize in
  70931. * @returns the serialized object
  70932. */
  70933. serialize(parent: any): any;
  70934. }
  70935. /**
  70936. * This defines an action responsible to start an animation once triggered.
  70937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70938. */
  70939. export class PlayAnimationAction extends Action {
  70940. /**
  70941. * Where the animation should start (animation frame)
  70942. */
  70943. from: number;
  70944. /**
  70945. * Where the animation should stop (animation frame)
  70946. */
  70947. to: number;
  70948. /**
  70949. * Define if the animation should loop or stop after the first play.
  70950. */
  70951. loop?: boolean;
  70952. private _target;
  70953. /**
  70954. * Instantiate the action
  70955. * @param triggerOptions defines the trigger options
  70956. * @param target defines the target animation or animation name
  70957. * @param from defines from where the animation should start (animation frame)
  70958. * @param end defines where the animation should stop (animation frame)
  70959. * @param loop defines if the animation should loop or stop after the first play
  70960. * @param condition defines the trigger related conditions
  70961. */
  70962. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70963. /** @hidden */
  70964. _prepare(): void;
  70965. /**
  70966. * Execute the action and play the animation.
  70967. */
  70968. execute(): void;
  70969. /**
  70970. * Serializes the actions and its related information.
  70971. * @param parent defines the object to serialize in
  70972. * @returns the serialized object
  70973. */
  70974. serialize(parent: any): any;
  70975. }
  70976. /**
  70977. * This defines an action responsible to stop an animation once triggered.
  70978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70979. */
  70980. export class StopAnimationAction extends Action {
  70981. private _target;
  70982. /**
  70983. * Instantiate the action
  70984. * @param triggerOptions defines the trigger options
  70985. * @param target defines the target animation or animation name
  70986. * @param condition defines the trigger related conditions
  70987. */
  70988. constructor(triggerOptions: any, target: any, condition?: Condition);
  70989. /** @hidden */
  70990. _prepare(): void;
  70991. /**
  70992. * Execute the action and stop the animation.
  70993. */
  70994. execute(): void;
  70995. /**
  70996. * Serializes the actions and its related information.
  70997. * @param parent defines the object to serialize in
  70998. * @returns the serialized object
  70999. */
  71000. serialize(parent: any): any;
  71001. }
  71002. /**
  71003. * This defines an action responsible that does nothing once triggered.
  71004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71005. */
  71006. export class DoNothingAction extends Action {
  71007. /**
  71008. * Instantiate the action
  71009. * @param triggerOptions defines the trigger options
  71010. * @param condition defines the trigger related conditions
  71011. */
  71012. constructor(triggerOptions?: any, condition?: Condition);
  71013. /**
  71014. * Execute the action and do nothing.
  71015. */
  71016. execute(): void;
  71017. /**
  71018. * Serializes the actions and its related information.
  71019. * @param parent defines the object to serialize in
  71020. * @returns the serialized object
  71021. */
  71022. serialize(parent: any): any;
  71023. }
  71024. /**
  71025. * This defines an action responsible to trigger several actions once triggered.
  71026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71027. */
  71028. export class CombineAction extends Action {
  71029. /**
  71030. * The list of aggregated animations to run.
  71031. */
  71032. children: Action[];
  71033. /**
  71034. * Instantiate the action
  71035. * @param triggerOptions defines the trigger options
  71036. * @param children defines the list of aggregated animations to run
  71037. * @param condition defines the trigger related conditions
  71038. */
  71039. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71040. /** @hidden */
  71041. _prepare(): void;
  71042. /**
  71043. * Execute the action and executes all the aggregated actions.
  71044. */
  71045. execute(evt: ActionEvent): void;
  71046. /**
  71047. * Serializes the actions and its related information.
  71048. * @param parent defines the object to serialize in
  71049. * @returns the serialized object
  71050. */
  71051. serialize(parent: any): any;
  71052. }
  71053. /**
  71054. * This defines an action responsible to run code (external event) once triggered.
  71055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71056. */
  71057. export class ExecuteCodeAction extends Action {
  71058. /**
  71059. * The callback function to run.
  71060. */
  71061. func: (evt: ActionEvent) => void;
  71062. /**
  71063. * Instantiate the action
  71064. * @param triggerOptions defines the trigger options
  71065. * @param func defines the callback function to run
  71066. * @param condition defines the trigger related conditions
  71067. */
  71068. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71069. /**
  71070. * Execute the action and run the attached code.
  71071. */
  71072. execute(evt: ActionEvent): void;
  71073. }
  71074. /**
  71075. * This defines an action responsible to set the parent property of the target once triggered.
  71076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71077. */
  71078. export class SetParentAction extends Action {
  71079. private _parent;
  71080. private _target;
  71081. /**
  71082. * Instantiate the action
  71083. * @param triggerOptions defines the trigger options
  71084. * @param target defines the target containing the parent property
  71085. * @param parent defines from where the animation should start (animation frame)
  71086. * @param condition defines the trigger related conditions
  71087. */
  71088. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71089. /** @hidden */
  71090. _prepare(): void;
  71091. /**
  71092. * Execute the action and set the parent property.
  71093. */
  71094. execute(): void;
  71095. /**
  71096. * Serializes the actions and its related information.
  71097. * @param parent defines the object to serialize in
  71098. * @returns the serialized object
  71099. */
  71100. serialize(parent: any): any;
  71101. }
  71102. }
  71103. declare module BABYLON {
  71104. /**
  71105. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71106. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71108. */
  71109. export class ActionManager extends AbstractActionManager {
  71110. /**
  71111. * Nothing
  71112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71113. */
  71114. static readonly NothingTrigger: number;
  71115. /**
  71116. * On pick
  71117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71118. */
  71119. static readonly OnPickTrigger: number;
  71120. /**
  71121. * On left pick
  71122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71123. */
  71124. static readonly OnLeftPickTrigger: number;
  71125. /**
  71126. * On right pick
  71127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71128. */
  71129. static readonly OnRightPickTrigger: number;
  71130. /**
  71131. * On center pick
  71132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71133. */
  71134. static readonly OnCenterPickTrigger: number;
  71135. /**
  71136. * On pick down
  71137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71138. */
  71139. static readonly OnPickDownTrigger: number;
  71140. /**
  71141. * On double pick
  71142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71143. */
  71144. static readonly OnDoublePickTrigger: number;
  71145. /**
  71146. * On pick up
  71147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71148. */
  71149. static readonly OnPickUpTrigger: number;
  71150. /**
  71151. * On pick out.
  71152. * This trigger will only be raised if you also declared a OnPickDown
  71153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71154. */
  71155. static readonly OnPickOutTrigger: number;
  71156. /**
  71157. * On long press
  71158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71159. */
  71160. static readonly OnLongPressTrigger: number;
  71161. /**
  71162. * On pointer over
  71163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71164. */
  71165. static readonly OnPointerOverTrigger: number;
  71166. /**
  71167. * On pointer out
  71168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71169. */
  71170. static readonly OnPointerOutTrigger: number;
  71171. /**
  71172. * On every frame
  71173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71174. */
  71175. static readonly OnEveryFrameTrigger: number;
  71176. /**
  71177. * On intersection enter
  71178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71179. */
  71180. static readonly OnIntersectionEnterTrigger: number;
  71181. /**
  71182. * On intersection exit
  71183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71184. */
  71185. static readonly OnIntersectionExitTrigger: number;
  71186. /**
  71187. * On key down
  71188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71189. */
  71190. static readonly OnKeyDownTrigger: number;
  71191. /**
  71192. * On key up
  71193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71194. */
  71195. static readonly OnKeyUpTrigger: number;
  71196. private _scene;
  71197. /**
  71198. * Creates a new action manager
  71199. * @param scene defines the hosting scene
  71200. */
  71201. constructor(scene: Scene);
  71202. /**
  71203. * Releases all associated resources
  71204. */
  71205. dispose(): void;
  71206. /**
  71207. * Gets hosting scene
  71208. * @returns the hosting scene
  71209. */
  71210. getScene(): Scene;
  71211. /**
  71212. * Does this action manager handles actions of any of the given triggers
  71213. * @param triggers defines the triggers to be tested
  71214. * @return a boolean indicating whether one (or more) of the triggers is handled
  71215. */
  71216. hasSpecificTriggers(triggers: number[]): boolean;
  71217. /**
  71218. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71219. * speed.
  71220. * @param triggerA defines the trigger to be tested
  71221. * @param triggerB defines the trigger to be tested
  71222. * @return a boolean indicating whether one (or more) of the triggers is handled
  71223. */
  71224. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71225. /**
  71226. * Does this action manager handles actions of a given trigger
  71227. * @param trigger defines the trigger to be tested
  71228. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71229. * @return whether the trigger is handled
  71230. */
  71231. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71232. /**
  71233. * Does this action manager has pointer triggers
  71234. */
  71235. readonly hasPointerTriggers: boolean;
  71236. /**
  71237. * Does this action manager has pick triggers
  71238. */
  71239. readonly hasPickTriggers: boolean;
  71240. /**
  71241. * Registers an action to this action manager
  71242. * @param action defines the action to be registered
  71243. * @return the action amended (prepared) after registration
  71244. */
  71245. registerAction(action: IAction): Nullable<IAction>;
  71246. /**
  71247. * Unregisters an action to this action manager
  71248. * @param action defines the action to be unregistered
  71249. * @return a boolean indicating whether the action has been unregistered
  71250. */
  71251. unregisterAction(action: IAction): Boolean;
  71252. /**
  71253. * Process a specific trigger
  71254. * @param trigger defines the trigger to process
  71255. * @param evt defines the event details to be processed
  71256. */
  71257. processTrigger(trigger: number, evt?: IActionEvent): void;
  71258. /** @hidden */
  71259. _getEffectiveTarget(target: any, propertyPath: string): any;
  71260. /** @hidden */
  71261. _getProperty(propertyPath: string): string;
  71262. /**
  71263. * Serialize this manager to a JSON object
  71264. * @param name defines the property name to store this manager
  71265. * @returns a JSON representation of this manager
  71266. */
  71267. serialize(name: string): any;
  71268. /**
  71269. * Creates a new ActionManager from a JSON data
  71270. * @param parsedActions defines the JSON data to read from
  71271. * @param object defines the hosting mesh
  71272. * @param scene defines the hosting scene
  71273. */
  71274. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71275. /**
  71276. * Get a trigger name by index
  71277. * @param trigger defines the trigger index
  71278. * @returns a trigger name
  71279. */
  71280. static GetTriggerName(trigger: number): string;
  71281. }
  71282. }
  71283. declare module BABYLON {
  71284. /**
  71285. * Class representing a ray with position and direction
  71286. */
  71287. export class Ray {
  71288. /** origin point */
  71289. origin: Vector3;
  71290. /** direction */
  71291. direction: Vector3;
  71292. /** length of the ray */
  71293. length: number;
  71294. private static readonly TmpVector3;
  71295. private _tmpRay;
  71296. /**
  71297. * Creates a new ray
  71298. * @param origin origin point
  71299. * @param direction direction
  71300. * @param length length of the ray
  71301. */
  71302. constructor(
  71303. /** origin point */
  71304. origin: Vector3,
  71305. /** direction */
  71306. direction: Vector3,
  71307. /** length of the ray */
  71308. length?: number);
  71309. /**
  71310. * Checks if the ray intersects a box
  71311. * @param minimum bound of the box
  71312. * @param maximum bound of the box
  71313. * @param intersectionTreshold extra extend to be added to the box in all direction
  71314. * @returns if the box was hit
  71315. */
  71316. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71317. /**
  71318. * Checks if the ray intersects a box
  71319. * @param box the bounding box to check
  71320. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71321. * @returns if the box was hit
  71322. */
  71323. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71324. /**
  71325. * If the ray hits a sphere
  71326. * @param sphere the bounding sphere to check
  71327. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71328. * @returns true if it hits the sphere
  71329. */
  71330. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71331. /**
  71332. * If the ray hits a triange
  71333. * @param vertex0 triangle vertex
  71334. * @param vertex1 triangle vertex
  71335. * @param vertex2 triangle vertex
  71336. * @returns intersection information if hit
  71337. */
  71338. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71339. /**
  71340. * Checks if ray intersects a plane
  71341. * @param plane the plane to check
  71342. * @returns the distance away it was hit
  71343. */
  71344. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71345. /**
  71346. * Checks if ray intersects a mesh
  71347. * @param mesh the mesh to check
  71348. * @param fastCheck if only the bounding box should checked
  71349. * @returns picking info of the intersecton
  71350. */
  71351. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71352. /**
  71353. * Checks if ray intersects a mesh
  71354. * @param meshes the meshes to check
  71355. * @param fastCheck if only the bounding box should checked
  71356. * @param results array to store result in
  71357. * @returns Array of picking infos
  71358. */
  71359. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71360. private _comparePickingInfo;
  71361. private static smallnum;
  71362. private static rayl;
  71363. /**
  71364. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71365. * @param sega the first point of the segment to test the intersection against
  71366. * @param segb the second point of the segment to test the intersection against
  71367. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71368. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71369. */
  71370. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71371. /**
  71372. * Update the ray from viewport position
  71373. * @param x position
  71374. * @param y y position
  71375. * @param viewportWidth viewport width
  71376. * @param viewportHeight viewport height
  71377. * @param world world matrix
  71378. * @param view view matrix
  71379. * @param projection projection matrix
  71380. * @returns this ray updated
  71381. */
  71382. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71383. /**
  71384. * Creates a ray with origin and direction of 0,0,0
  71385. * @returns the new ray
  71386. */
  71387. static Zero(): Ray;
  71388. /**
  71389. * Creates a new ray from screen space and viewport
  71390. * @param x position
  71391. * @param y y position
  71392. * @param viewportWidth viewport width
  71393. * @param viewportHeight viewport height
  71394. * @param world world matrix
  71395. * @param view view matrix
  71396. * @param projection projection matrix
  71397. * @returns new ray
  71398. */
  71399. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71400. /**
  71401. * 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
  71402. * transformed to the given world matrix.
  71403. * @param origin The origin point
  71404. * @param end The end point
  71405. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71406. * @returns the new ray
  71407. */
  71408. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71409. /**
  71410. * Transforms a ray by a matrix
  71411. * @param ray ray to transform
  71412. * @param matrix matrix to apply
  71413. * @returns the resulting new ray
  71414. */
  71415. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71416. /**
  71417. * Transforms a ray by a matrix
  71418. * @param ray ray to transform
  71419. * @param matrix matrix to apply
  71420. * @param result ray to store result in
  71421. */
  71422. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71423. /**
  71424. * Unproject a ray from screen space to object space
  71425. * @param sourceX defines the screen space x coordinate to use
  71426. * @param sourceY defines the screen space y coordinate to use
  71427. * @param viewportWidth defines the current width of the viewport
  71428. * @param viewportHeight defines the current height of the viewport
  71429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71430. * @param view defines the view matrix to use
  71431. * @param projection defines the projection matrix to use
  71432. */
  71433. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71434. }
  71435. /**
  71436. * Type used to define predicate used to select faces when a mesh intersection is detected
  71437. */
  71438. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71439. interface Scene {
  71440. /** @hidden */
  71441. _tempPickingRay: Nullable<Ray>;
  71442. /** @hidden */
  71443. _cachedRayForTransform: Ray;
  71444. /** @hidden */
  71445. _pickWithRayInverseMatrix: Matrix;
  71446. /** @hidden */
  71447. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71448. /** @hidden */
  71449. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71450. }
  71451. }
  71452. declare module BABYLON {
  71453. /**
  71454. * Groups all the scene component constants in one place to ease maintenance.
  71455. * @hidden
  71456. */
  71457. export class SceneComponentConstants {
  71458. static readonly NAME_EFFECTLAYER: string;
  71459. static readonly NAME_LAYER: string;
  71460. static readonly NAME_LENSFLARESYSTEM: string;
  71461. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71462. static readonly NAME_PARTICLESYSTEM: string;
  71463. static readonly NAME_GAMEPAD: string;
  71464. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71465. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71466. static readonly NAME_DEPTHRENDERER: string;
  71467. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71468. static readonly NAME_SPRITE: string;
  71469. static readonly NAME_OUTLINERENDERER: string;
  71470. static readonly NAME_PROCEDURALTEXTURE: string;
  71471. static readonly NAME_SHADOWGENERATOR: string;
  71472. static readonly NAME_OCTREE: string;
  71473. static readonly NAME_PHYSICSENGINE: string;
  71474. static readonly NAME_AUDIO: string;
  71475. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71476. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71477. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71478. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71479. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71480. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71481. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71482. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71483. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71484. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71485. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71486. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71487. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71488. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71489. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71490. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71491. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71492. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71493. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71494. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71495. static readonly STEP_AFTERRENDER_AUDIO: number;
  71496. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71497. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71498. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71499. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71500. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71501. static readonly STEP_POINTERMOVE_SPRITE: number;
  71502. static readonly STEP_POINTERDOWN_SPRITE: number;
  71503. static readonly STEP_POINTERUP_SPRITE: number;
  71504. }
  71505. /**
  71506. * This represents a scene component.
  71507. *
  71508. * This is used to decouple the dependency the scene is having on the different workloads like
  71509. * layers, post processes...
  71510. */
  71511. export interface ISceneComponent {
  71512. /**
  71513. * The name of the component. Each component must have a unique name.
  71514. */
  71515. name: string;
  71516. /**
  71517. * The scene the component belongs to.
  71518. */
  71519. scene: Scene;
  71520. /**
  71521. * Register the component to one instance of a scene.
  71522. */
  71523. register(): void;
  71524. /**
  71525. * Rebuilds the elements related to this component in case of
  71526. * context lost for instance.
  71527. */
  71528. rebuild(): void;
  71529. /**
  71530. * Disposes the component and the associated ressources.
  71531. */
  71532. dispose(): void;
  71533. }
  71534. /**
  71535. * This represents a SERIALIZABLE scene component.
  71536. *
  71537. * This extends Scene Component to add Serialization methods on top.
  71538. */
  71539. export interface ISceneSerializableComponent extends ISceneComponent {
  71540. /**
  71541. * Adds all the element from the container to the scene
  71542. * @param container the container holding the elements
  71543. */
  71544. addFromContainer(container: AbstractScene): void;
  71545. /**
  71546. * Removes all the elements in the container from the scene
  71547. * @param container contains the elements to remove
  71548. * @param dispose if the removed element should be disposed (default: false)
  71549. */
  71550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71551. /**
  71552. * Serializes the component data to the specified json object
  71553. * @param serializationObject The object to serialize to
  71554. */
  71555. serialize(serializationObject: any): void;
  71556. }
  71557. /**
  71558. * Strong typing of a Mesh related stage step action
  71559. */
  71560. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71561. /**
  71562. * Strong typing of a Evaluate Sub Mesh related stage step action
  71563. */
  71564. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71565. /**
  71566. * Strong typing of a Active Mesh related stage step action
  71567. */
  71568. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71569. /**
  71570. * Strong typing of a Camera related stage step action
  71571. */
  71572. export type CameraStageAction = (camera: Camera) => void;
  71573. /**
  71574. * Strong typing of a Camera Frame buffer related stage step action
  71575. */
  71576. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71577. /**
  71578. * Strong typing of a Render Target related stage step action
  71579. */
  71580. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71581. /**
  71582. * Strong typing of a RenderingGroup related stage step action
  71583. */
  71584. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71585. /**
  71586. * Strong typing of a Mesh Render related stage step action
  71587. */
  71588. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71589. /**
  71590. * Strong typing of a simple stage step action
  71591. */
  71592. export type SimpleStageAction = () => void;
  71593. /**
  71594. * Strong typing of a render target action.
  71595. */
  71596. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71597. /**
  71598. * Strong typing of a pointer move action.
  71599. */
  71600. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71601. /**
  71602. * Strong typing of a pointer up/down action.
  71603. */
  71604. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71605. /**
  71606. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71607. * @hidden
  71608. */
  71609. export class Stage<T extends Function> extends Array<{
  71610. index: number;
  71611. component: ISceneComponent;
  71612. action: T;
  71613. }> {
  71614. /**
  71615. * Hide ctor from the rest of the world.
  71616. * @param items The items to add.
  71617. */
  71618. private constructor();
  71619. /**
  71620. * Creates a new Stage.
  71621. * @returns A new instance of a Stage
  71622. */
  71623. static Create<T extends Function>(): Stage<T>;
  71624. /**
  71625. * Registers a step in an ordered way in the targeted stage.
  71626. * @param index Defines the position to register the step in
  71627. * @param component Defines the component attached to the step
  71628. * @param action Defines the action to launch during the step
  71629. */
  71630. registerStep(index: number, component: ISceneComponent, action: T): void;
  71631. /**
  71632. * Clears all the steps from the stage.
  71633. */
  71634. clear(): void;
  71635. }
  71636. }
  71637. declare module BABYLON {
  71638. interface Scene {
  71639. /** @hidden */
  71640. _pointerOverSprite: Nullable<Sprite>;
  71641. /** @hidden */
  71642. _pickedDownSprite: Nullable<Sprite>;
  71643. /** @hidden */
  71644. _tempSpritePickingRay: Nullable<Ray>;
  71645. /**
  71646. * All of the sprite managers added to this scene
  71647. * @see http://doc.babylonjs.com/babylon101/sprites
  71648. */
  71649. spriteManagers: Array<ISpriteManager>;
  71650. /**
  71651. * An event triggered when sprites rendering is about to start
  71652. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71653. */
  71654. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71655. /**
  71656. * An event triggered when sprites rendering is done
  71657. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71658. */
  71659. onAfterSpritesRenderingObservable: Observable<Scene>;
  71660. /** @hidden */
  71661. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71662. /** Launch a ray to try to pick a sprite in the scene
  71663. * @param x position on screen
  71664. * @param y position on screen
  71665. * @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
  71666. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71667. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71668. * @returns a PickingInfo
  71669. */
  71670. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71671. /** Use the given ray to pick a sprite in the scene
  71672. * @param ray The ray (in world space) to use to pick meshes
  71673. * @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
  71674. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71675. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71676. * @returns a PickingInfo
  71677. */
  71678. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71679. /**
  71680. * Force the sprite under the pointer
  71681. * @param sprite defines the sprite to use
  71682. */
  71683. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71684. /**
  71685. * Gets the sprite under the pointer
  71686. * @returns a Sprite or null if no sprite is under the pointer
  71687. */
  71688. getPointerOverSprite(): Nullable<Sprite>;
  71689. }
  71690. /**
  71691. * Defines the sprite scene component responsible to manage sprites
  71692. * in a given scene.
  71693. */
  71694. export class SpriteSceneComponent implements ISceneComponent {
  71695. /**
  71696. * The component name helpfull to identify the component in the list of scene components.
  71697. */
  71698. readonly name: string;
  71699. /**
  71700. * The scene the component belongs to.
  71701. */
  71702. scene: Scene;
  71703. /** @hidden */
  71704. private _spritePredicate;
  71705. /**
  71706. * Creates a new instance of the component for the given scene
  71707. * @param scene Defines the scene to register the component in
  71708. */
  71709. constructor(scene: Scene);
  71710. /**
  71711. * Registers the component in a given scene
  71712. */
  71713. register(): void;
  71714. /**
  71715. * Rebuilds the elements related to this component in case of
  71716. * context lost for instance.
  71717. */
  71718. rebuild(): void;
  71719. /**
  71720. * Disposes the component and the associated ressources.
  71721. */
  71722. dispose(): void;
  71723. private _pickSpriteButKeepRay;
  71724. private _pointerMove;
  71725. private _pointerDown;
  71726. private _pointerUp;
  71727. }
  71728. }
  71729. declare module BABYLON {
  71730. /** @hidden */
  71731. export var fogFragmentDeclaration: {
  71732. name: string;
  71733. shader: string;
  71734. };
  71735. }
  71736. declare module BABYLON {
  71737. /** @hidden */
  71738. export var fogFragment: {
  71739. name: string;
  71740. shader: string;
  71741. };
  71742. }
  71743. declare module BABYLON {
  71744. /** @hidden */
  71745. export var spritesPixelShader: {
  71746. name: string;
  71747. shader: string;
  71748. };
  71749. }
  71750. declare module BABYLON {
  71751. /** @hidden */
  71752. export var fogVertexDeclaration: {
  71753. name: string;
  71754. shader: string;
  71755. };
  71756. }
  71757. declare module BABYLON {
  71758. /** @hidden */
  71759. export var spritesVertexShader: {
  71760. name: string;
  71761. shader: string;
  71762. };
  71763. }
  71764. declare module BABYLON {
  71765. /**
  71766. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71767. */
  71768. export interface ISpriteManager extends IDisposable {
  71769. /**
  71770. * Restricts the camera to viewing objects with the same layerMask.
  71771. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71772. */
  71773. layerMask: number;
  71774. /**
  71775. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71776. */
  71777. isPickable: boolean;
  71778. /**
  71779. * Specifies the rendering group id for this mesh (0 by default)
  71780. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71781. */
  71782. renderingGroupId: number;
  71783. /**
  71784. * Defines the list of sprites managed by the manager.
  71785. */
  71786. sprites: Array<Sprite>;
  71787. /**
  71788. * Tests the intersection of a sprite with a specific ray.
  71789. * @param ray The ray we are sending to test the collision
  71790. * @param camera The camera space we are sending rays in
  71791. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71792. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71793. * @returns picking info or null.
  71794. */
  71795. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71796. /**
  71797. * Renders the list of sprites on screen.
  71798. */
  71799. render(): void;
  71800. }
  71801. /**
  71802. * Class used to manage multiple sprites on the same spritesheet
  71803. * @see http://doc.babylonjs.com/babylon101/sprites
  71804. */
  71805. export class SpriteManager implements ISpriteManager {
  71806. /** defines the manager's name */
  71807. name: string;
  71808. /** Gets the list of sprites */
  71809. sprites: Sprite[];
  71810. /** Gets or sets the rendering group id (0 by default) */
  71811. renderingGroupId: number;
  71812. /** Gets or sets camera layer mask */
  71813. layerMask: number;
  71814. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71815. fogEnabled: boolean;
  71816. /** Gets or sets a boolean indicating if the sprites are pickable */
  71817. isPickable: boolean;
  71818. /** Defines the default width of a cell in the spritesheet */
  71819. cellWidth: number;
  71820. /** Defines the default height of a cell in the spritesheet */
  71821. cellHeight: number;
  71822. /**
  71823. * An event triggered when the manager is disposed.
  71824. */
  71825. onDisposeObservable: Observable<SpriteManager>;
  71826. private _onDisposeObserver;
  71827. /**
  71828. * Callback called when the manager is disposed
  71829. */
  71830. onDispose: () => void;
  71831. private _capacity;
  71832. private _spriteTexture;
  71833. private _epsilon;
  71834. private _scene;
  71835. private _vertexData;
  71836. private _buffer;
  71837. private _vertexBuffers;
  71838. private _indexBuffer;
  71839. private _effectBase;
  71840. private _effectFog;
  71841. /**
  71842. * Gets or sets the spritesheet texture
  71843. */
  71844. texture: Texture;
  71845. /**
  71846. * Creates a new sprite manager
  71847. * @param name defines the manager's name
  71848. * @param imgUrl defines the sprite sheet url
  71849. * @param capacity defines the maximum allowed number of sprites
  71850. * @param cellSize defines the size of a sprite cell
  71851. * @param scene defines the hosting scene
  71852. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71853. * @param samplingMode defines the smapling mode to use with spritesheet
  71854. */
  71855. constructor(
  71856. /** defines the manager's name */
  71857. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71858. private _appendSpriteVertex;
  71859. /**
  71860. * Intersects the sprites with a ray
  71861. * @param ray defines the ray to intersect with
  71862. * @param camera defines the current active camera
  71863. * @param predicate defines a predicate used to select candidate sprites
  71864. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71865. * @returns null if no hit or a PickingInfo
  71866. */
  71867. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71868. /**
  71869. * Render all child sprites
  71870. */
  71871. render(): void;
  71872. /**
  71873. * Release associated resources
  71874. */
  71875. dispose(): void;
  71876. }
  71877. }
  71878. declare module BABYLON {
  71879. /**
  71880. * Class used to represent a sprite
  71881. * @see http://doc.babylonjs.com/babylon101/sprites
  71882. */
  71883. export class Sprite {
  71884. /** defines the name */
  71885. name: string;
  71886. /** Gets or sets the current world position */
  71887. position: Vector3;
  71888. /** Gets or sets the main color */
  71889. color: Color4;
  71890. /** Gets or sets the width */
  71891. width: number;
  71892. /** Gets or sets the height */
  71893. height: number;
  71894. /** Gets or sets rotation angle */
  71895. angle: number;
  71896. /** Gets or sets the cell index in the sprite sheet */
  71897. cellIndex: number;
  71898. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71899. invertU: number;
  71900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71901. invertV: number;
  71902. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71903. disposeWhenFinishedAnimating: boolean;
  71904. /** Gets the list of attached animations */
  71905. animations: Animation[];
  71906. /** Gets or sets a boolean indicating if the sprite can be picked */
  71907. isPickable: boolean;
  71908. /**
  71909. * Gets or sets the associated action manager
  71910. */
  71911. actionManager: Nullable<ActionManager>;
  71912. private _animationStarted;
  71913. private _loopAnimation;
  71914. private _fromIndex;
  71915. private _toIndex;
  71916. private _delay;
  71917. private _direction;
  71918. private _manager;
  71919. private _time;
  71920. private _onAnimationEnd;
  71921. /**
  71922. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71923. */
  71924. isVisible: boolean;
  71925. /**
  71926. * Gets or sets the sprite size
  71927. */
  71928. size: number;
  71929. /**
  71930. * Creates a new Sprite
  71931. * @param name defines the name
  71932. * @param manager defines the manager
  71933. */
  71934. constructor(
  71935. /** defines the name */
  71936. name: string, manager: ISpriteManager);
  71937. /**
  71938. * Starts an animation
  71939. * @param from defines the initial key
  71940. * @param to defines the end key
  71941. * @param loop defines if the animation must loop
  71942. * @param delay defines the start delay (in ms)
  71943. * @param onAnimationEnd defines a callback to call when animation ends
  71944. */
  71945. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71946. /** Stops current animation (if any) */
  71947. stopAnimation(): void;
  71948. /** @hidden */
  71949. _animate(deltaTime: number): void;
  71950. /** Release associated resources */
  71951. dispose(): void;
  71952. }
  71953. }
  71954. declare module BABYLON {
  71955. /**
  71956. * Information about the result of picking within a scene
  71957. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71958. */
  71959. export class PickingInfo {
  71960. /** @hidden */
  71961. _pickingUnavailable: boolean;
  71962. /**
  71963. * If the pick collided with an object
  71964. */
  71965. hit: boolean;
  71966. /**
  71967. * Distance away where the pick collided
  71968. */
  71969. distance: number;
  71970. /**
  71971. * The location of pick collision
  71972. */
  71973. pickedPoint: Nullable<Vector3>;
  71974. /**
  71975. * The mesh corresponding the the pick collision
  71976. */
  71977. pickedMesh: Nullable<AbstractMesh>;
  71978. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71979. bu: number;
  71980. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71981. bv: number;
  71982. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71983. faceId: number;
  71984. /** Id of the the submesh that was picked */
  71985. subMeshId: number;
  71986. /** If a sprite was picked, this will be the sprite the pick collided with */
  71987. pickedSprite: Nullable<Sprite>;
  71988. /**
  71989. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71990. */
  71991. originMesh: Nullable<AbstractMesh>;
  71992. /**
  71993. * The ray that was used to perform the picking.
  71994. */
  71995. ray: Nullable<Ray>;
  71996. /**
  71997. * Gets the normal correspodning to the face the pick collided with
  71998. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71999. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72000. * @returns The normal correspodning to the face the pick collided with
  72001. */
  72002. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72003. /**
  72004. * Gets the texture coordinates of where the pick occured
  72005. * @returns the vector containing the coordnates of the texture
  72006. */
  72007. getTextureCoordinates(): Nullable<Vector2>;
  72008. }
  72009. }
  72010. declare module BABYLON {
  72011. /**
  72012. * Gather the list of pointer event types as constants.
  72013. */
  72014. export class PointerEventTypes {
  72015. /**
  72016. * 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.
  72017. */
  72018. static readonly POINTERDOWN: number;
  72019. /**
  72020. * The pointerup event is fired when a pointer is no longer active.
  72021. */
  72022. static readonly POINTERUP: number;
  72023. /**
  72024. * The pointermove event is fired when a pointer changes coordinates.
  72025. */
  72026. static readonly POINTERMOVE: number;
  72027. /**
  72028. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72029. */
  72030. static readonly POINTERWHEEL: number;
  72031. /**
  72032. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72033. */
  72034. static readonly POINTERPICK: number;
  72035. /**
  72036. * The pointertap event is fired when a the object has been touched and released without drag.
  72037. */
  72038. static readonly POINTERTAP: number;
  72039. /**
  72040. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72041. */
  72042. static readonly POINTERDOUBLETAP: number;
  72043. }
  72044. /**
  72045. * Base class of pointer info types.
  72046. */
  72047. export class PointerInfoBase {
  72048. /**
  72049. * Defines the type of event (PointerEventTypes)
  72050. */
  72051. type: number;
  72052. /**
  72053. * Defines the related dom event
  72054. */
  72055. event: PointerEvent | MouseWheelEvent;
  72056. /**
  72057. * Instantiates the base class of pointers info.
  72058. * @param type Defines the type of event (PointerEventTypes)
  72059. * @param event Defines the related dom event
  72060. */
  72061. constructor(
  72062. /**
  72063. * Defines the type of event (PointerEventTypes)
  72064. */
  72065. type: number,
  72066. /**
  72067. * Defines the related dom event
  72068. */
  72069. event: PointerEvent | MouseWheelEvent);
  72070. }
  72071. /**
  72072. * This class is used to store pointer related info for the onPrePointerObservable event.
  72073. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72074. */
  72075. export class PointerInfoPre extends PointerInfoBase {
  72076. /**
  72077. * Ray from a pointer if availible (eg. 6dof controller)
  72078. */
  72079. ray: Nullable<Ray>;
  72080. /**
  72081. * Defines the local position of the pointer on the canvas.
  72082. */
  72083. localPosition: Vector2;
  72084. /**
  72085. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72086. */
  72087. skipOnPointerObservable: boolean;
  72088. /**
  72089. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72090. * @param type Defines the type of event (PointerEventTypes)
  72091. * @param event Defines the related dom event
  72092. * @param localX Defines the local x coordinates of the pointer when the event occured
  72093. * @param localY Defines the local y coordinates of the pointer when the event occured
  72094. */
  72095. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72096. }
  72097. /**
  72098. * This type contains all the data related to a pointer event in Babylon.js.
  72099. * 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.
  72100. */
  72101. export class PointerInfo extends PointerInfoBase {
  72102. /**
  72103. * Defines the picking info associated to the info (if any)\
  72104. */
  72105. pickInfo: Nullable<PickingInfo>;
  72106. /**
  72107. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72108. * @param type Defines the type of event (PointerEventTypes)
  72109. * @param event Defines the related dom event
  72110. * @param pickInfo Defines the picking info associated to the info (if any)\
  72111. */
  72112. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72113. /**
  72114. * Defines the picking info associated to the info (if any)\
  72115. */
  72116. pickInfo: Nullable<PickingInfo>);
  72117. }
  72118. /**
  72119. * Data relating to a touch event on the screen.
  72120. */
  72121. export interface PointerTouch {
  72122. /**
  72123. * X coordinate of touch.
  72124. */
  72125. x: number;
  72126. /**
  72127. * Y coordinate of touch.
  72128. */
  72129. y: number;
  72130. /**
  72131. * Id of touch. Unique for each finger.
  72132. */
  72133. pointerId: number;
  72134. /**
  72135. * Event type passed from DOM.
  72136. */
  72137. type: any;
  72138. }
  72139. }
  72140. declare module BABYLON {
  72141. /**
  72142. * Manage the mouse inputs to control the movement of a free camera.
  72143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72144. */
  72145. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72146. /**
  72147. * Define if touch is enabled in the mouse input
  72148. */
  72149. touchEnabled: boolean;
  72150. /**
  72151. * Defines the camera the input is attached to.
  72152. */
  72153. camera: FreeCamera;
  72154. /**
  72155. * Defines the buttons associated with the input to handle camera move.
  72156. */
  72157. buttons: number[];
  72158. /**
  72159. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72160. */
  72161. angularSensibility: number;
  72162. private _pointerInput;
  72163. private _onMouseMove;
  72164. private _observer;
  72165. private previousPosition;
  72166. /**
  72167. * Observable for when a pointer move event occurs containing the move offset
  72168. */
  72169. onPointerMovedObservable: Observable<{
  72170. offsetX: number;
  72171. offsetY: number;
  72172. }>;
  72173. /**
  72174. * @hidden
  72175. * If the camera should be rotated automatically based on pointer movement
  72176. */
  72177. _allowCameraRotation: boolean;
  72178. /**
  72179. * Manage the mouse inputs to control the movement of a free camera.
  72180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72181. * @param touchEnabled Defines if touch is enabled or not
  72182. */
  72183. constructor(
  72184. /**
  72185. * Define if touch is enabled in the mouse input
  72186. */
  72187. touchEnabled?: boolean);
  72188. /**
  72189. * Attach the input controls to a specific dom element to get the input from.
  72190. * @param element Defines the element the controls should be listened from
  72191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72192. */
  72193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72194. /**
  72195. * Called on JS contextmenu event.
  72196. * Override this method to provide functionality.
  72197. */
  72198. protected onContextMenu(evt: PointerEvent): void;
  72199. /**
  72200. * Detach the current controls from the specified dom element.
  72201. * @param element Defines the element to stop listening the inputs from
  72202. */
  72203. detachControl(element: Nullable<HTMLElement>): void;
  72204. /**
  72205. * Gets the class name of the current intput.
  72206. * @returns the class name
  72207. */
  72208. getClassName(): string;
  72209. /**
  72210. * Get the friendly name associated with the input class.
  72211. * @returns the input friendly name
  72212. */
  72213. getSimpleName(): string;
  72214. }
  72215. }
  72216. declare module BABYLON {
  72217. /**
  72218. * Manage the touch inputs to control the movement of a free camera.
  72219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72220. */
  72221. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72222. /**
  72223. * Defines the camera the input is attached to.
  72224. */
  72225. camera: FreeCamera;
  72226. /**
  72227. * Defines the touch sensibility for rotation.
  72228. * The higher the faster.
  72229. */
  72230. touchAngularSensibility: number;
  72231. /**
  72232. * Defines the touch sensibility for move.
  72233. * The higher the faster.
  72234. */
  72235. touchMoveSensibility: number;
  72236. private _offsetX;
  72237. private _offsetY;
  72238. private _pointerPressed;
  72239. private _pointerInput;
  72240. private _observer;
  72241. private _onLostFocus;
  72242. /**
  72243. * Attach the input controls to a specific dom element to get the input from.
  72244. * @param element Defines the element the controls should be listened from
  72245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72246. */
  72247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72248. /**
  72249. * Detach the current controls from the specified dom element.
  72250. * @param element Defines the element to stop listening the inputs from
  72251. */
  72252. detachControl(element: Nullable<HTMLElement>): void;
  72253. /**
  72254. * Update the current camera state depending on the inputs that have been used this frame.
  72255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72256. */
  72257. checkInputs(): void;
  72258. /**
  72259. * Gets the class name of the current intput.
  72260. * @returns the class name
  72261. */
  72262. getClassName(): string;
  72263. /**
  72264. * Get the friendly name associated with the input class.
  72265. * @returns the input friendly name
  72266. */
  72267. getSimpleName(): string;
  72268. }
  72269. }
  72270. declare module BABYLON {
  72271. /**
  72272. * Default Inputs manager for the FreeCamera.
  72273. * It groups all the default supported inputs for ease of use.
  72274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72275. */
  72276. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72277. /**
  72278. * @hidden
  72279. */
  72280. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72281. /**
  72282. * @hidden
  72283. */
  72284. _mouseInput: Nullable<FreeCameraMouseInput>;
  72285. /**
  72286. * Instantiates a new FreeCameraInputsManager.
  72287. * @param camera Defines the camera the inputs belong to
  72288. */
  72289. constructor(camera: FreeCamera);
  72290. /**
  72291. * Add keyboard input support to the input manager.
  72292. * @returns the current input manager
  72293. */
  72294. addKeyboard(): FreeCameraInputsManager;
  72295. /**
  72296. * Add mouse input support to the input manager.
  72297. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72298. * @returns the current input manager
  72299. */
  72300. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72301. /**
  72302. * Removes the mouse input support from the manager
  72303. * @returns the current input manager
  72304. */
  72305. removeMouse(): FreeCameraInputsManager;
  72306. /**
  72307. * Add touch input support to the input manager.
  72308. * @returns the current input manager
  72309. */
  72310. addTouch(): FreeCameraInputsManager;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72316. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72318. */
  72319. export class FreeCamera extends TargetCamera {
  72320. /**
  72321. * Define the collision ellipsoid of the camera.
  72322. * This is helpful to simulate a camera body like the player body around the camera
  72323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72324. */
  72325. ellipsoid: Vector3;
  72326. /**
  72327. * Define an offset for the position of the ellipsoid around the camera.
  72328. * This can be helpful to determine the center of the body near the gravity center of the body
  72329. * instead of its head.
  72330. */
  72331. ellipsoidOffset: Vector3;
  72332. /**
  72333. * Enable or disable collisions of the camera with the rest of the scene objects.
  72334. */
  72335. checkCollisions: boolean;
  72336. /**
  72337. * Enable or disable gravity on the camera.
  72338. */
  72339. applyGravity: boolean;
  72340. /**
  72341. * Define the input manager associated to the camera.
  72342. */
  72343. inputs: FreeCameraInputsManager;
  72344. /**
  72345. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72346. * Higher values reduce sensitivity.
  72347. */
  72348. /**
  72349. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72350. * Higher values reduce sensitivity.
  72351. */
  72352. angularSensibility: number;
  72353. /**
  72354. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72355. */
  72356. keysUp: number[];
  72357. /**
  72358. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72359. */
  72360. keysDown: number[];
  72361. /**
  72362. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72363. */
  72364. keysLeft: number[];
  72365. /**
  72366. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72367. */
  72368. keysRight: number[];
  72369. /**
  72370. * Event raised when the camera collide with a mesh in the scene.
  72371. */
  72372. onCollide: (collidedMesh: AbstractMesh) => void;
  72373. private _collider;
  72374. private _needMoveForGravity;
  72375. private _oldPosition;
  72376. private _diffPosition;
  72377. private _newPosition;
  72378. /** @hidden */
  72379. _localDirection: Vector3;
  72380. /** @hidden */
  72381. _transformedDirection: Vector3;
  72382. /**
  72383. * Instantiates a Free Camera.
  72384. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72385. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72386. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72387. * @param name Define the name of the camera in the scene
  72388. * @param position Define the start position of the camera in the scene
  72389. * @param scene Define the scene the camera belongs to
  72390. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72391. */
  72392. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72393. /**
  72394. * Attached controls to the current camera.
  72395. * @param element Defines the element the controls should be listened from
  72396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72397. */
  72398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72399. /**
  72400. * Detach the current controls from the camera.
  72401. * The camera will stop reacting to inputs.
  72402. * @param element Defines the element to stop listening the inputs from
  72403. */
  72404. detachControl(element: HTMLElement): void;
  72405. private _collisionMask;
  72406. /**
  72407. * Define a collision mask to limit the list of object the camera can collide with
  72408. */
  72409. collisionMask: number;
  72410. /** @hidden */
  72411. _collideWithWorld(displacement: Vector3): void;
  72412. private _onCollisionPositionChange;
  72413. /** @hidden */
  72414. _checkInputs(): void;
  72415. /** @hidden */
  72416. _decideIfNeedsToMove(): boolean;
  72417. /** @hidden */
  72418. _updatePosition(): void;
  72419. /**
  72420. * Destroy the camera and release the current resources hold by it.
  72421. */
  72422. dispose(): void;
  72423. /**
  72424. * Gets the current object class name.
  72425. * @return the class name
  72426. */
  72427. getClassName(): string;
  72428. }
  72429. }
  72430. declare module BABYLON {
  72431. /**
  72432. * Represents a gamepad control stick position
  72433. */
  72434. export class StickValues {
  72435. /**
  72436. * The x component of the control stick
  72437. */
  72438. x: number;
  72439. /**
  72440. * The y component of the control stick
  72441. */
  72442. y: number;
  72443. /**
  72444. * Initializes the gamepad x and y control stick values
  72445. * @param x The x component of the gamepad control stick value
  72446. * @param y The y component of the gamepad control stick value
  72447. */
  72448. constructor(
  72449. /**
  72450. * The x component of the control stick
  72451. */
  72452. x: number,
  72453. /**
  72454. * The y component of the control stick
  72455. */
  72456. y: number);
  72457. }
  72458. /**
  72459. * An interface which manages callbacks for gamepad button changes
  72460. */
  72461. export interface GamepadButtonChanges {
  72462. /**
  72463. * Called when a gamepad has been changed
  72464. */
  72465. changed: boolean;
  72466. /**
  72467. * Called when a gamepad press event has been triggered
  72468. */
  72469. pressChanged: boolean;
  72470. /**
  72471. * Called when a touch event has been triggered
  72472. */
  72473. touchChanged: boolean;
  72474. /**
  72475. * Called when a value has changed
  72476. */
  72477. valueChanged: boolean;
  72478. }
  72479. /**
  72480. * Represents a gamepad
  72481. */
  72482. export class Gamepad {
  72483. /**
  72484. * The id of the gamepad
  72485. */
  72486. id: string;
  72487. /**
  72488. * The index of the gamepad
  72489. */
  72490. index: number;
  72491. /**
  72492. * The browser gamepad
  72493. */
  72494. browserGamepad: any;
  72495. /**
  72496. * Specifies what type of gamepad this represents
  72497. */
  72498. type: number;
  72499. private _leftStick;
  72500. private _rightStick;
  72501. /** @hidden */
  72502. _isConnected: boolean;
  72503. private _leftStickAxisX;
  72504. private _leftStickAxisY;
  72505. private _rightStickAxisX;
  72506. private _rightStickAxisY;
  72507. /**
  72508. * Triggered when the left control stick has been changed
  72509. */
  72510. private _onleftstickchanged;
  72511. /**
  72512. * Triggered when the right control stick has been changed
  72513. */
  72514. private _onrightstickchanged;
  72515. /**
  72516. * Represents a gamepad controller
  72517. */
  72518. static GAMEPAD: number;
  72519. /**
  72520. * Represents a generic controller
  72521. */
  72522. static GENERIC: number;
  72523. /**
  72524. * Represents an XBox controller
  72525. */
  72526. static XBOX: number;
  72527. /**
  72528. * Represents a pose-enabled controller
  72529. */
  72530. static POSE_ENABLED: number;
  72531. /**
  72532. * Specifies whether the left control stick should be Y-inverted
  72533. */
  72534. protected _invertLeftStickY: boolean;
  72535. /**
  72536. * Specifies if the gamepad has been connected
  72537. */
  72538. readonly isConnected: boolean;
  72539. /**
  72540. * Initializes the gamepad
  72541. * @param id The id of the gamepad
  72542. * @param index The index of the gamepad
  72543. * @param browserGamepad The browser gamepad
  72544. * @param leftStickX The x component of the left joystick
  72545. * @param leftStickY The y component of the left joystick
  72546. * @param rightStickX The x component of the right joystick
  72547. * @param rightStickY The y component of the right joystick
  72548. */
  72549. constructor(
  72550. /**
  72551. * The id of the gamepad
  72552. */
  72553. id: string,
  72554. /**
  72555. * The index of the gamepad
  72556. */
  72557. index: number,
  72558. /**
  72559. * The browser gamepad
  72560. */
  72561. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72562. /**
  72563. * Callback triggered when the left joystick has changed
  72564. * @param callback
  72565. */
  72566. onleftstickchanged(callback: (values: StickValues) => void): void;
  72567. /**
  72568. * Callback triggered when the right joystick has changed
  72569. * @param callback
  72570. */
  72571. onrightstickchanged(callback: (values: StickValues) => void): void;
  72572. /**
  72573. * Gets the left joystick
  72574. */
  72575. /**
  72576. * Sets the left joystick values
  72577. */
  72578. leftStick: StickValues;
  72579. /**
  72580. * Gets the right joystick
  72581. */
  72582. /**
  72583. * Sets the right joystick value
  72584. */
  72585. rightStick: StickValues;
  72586. /**
  72587. * Updates the gamepad joystick positions
  72588. */
  72589. update(): void;
  72590. /**
  72591. * Disposes the gamepad
  72592. */
  72593. dispose(): void;
  72594. }
  72595. /**
  72596. * Represents a generic gamepad
  72597. */
  72598. export class GenericPad extends Gamepad {
  72599. private _buttons;
  72600. private _onbuttondown;
  72601. private _onbuttonup;
  72602. /**
  72603. * Observable triggered when a button has been pressed
  72604. */
  72605. onButtonDownObservable: Observable<number>;
  72606. /**
  72607. * Observable triggered when a button has been released
  72608. */
  72609. onButtonUpObservable: Observable<number>;
  72610. /**
  72611. * Callback triggered when a button has been pressed
  72612. * @param callback Called when a button has been pressed
  72613. */
  72614. onbuttondown(callback: (buttonPressed: number) => void): void;
  72615. /**
  72616. * Callback triggered when a button has been released
  72617. * @param callback Called when a button has been released
  72618. */
  72619. onbuttonup(callback: (buttonReleased: number) => void): void;
  72620. /**
  72621. * Initializes the generic gamepad
  72622. * @param id The id of the generic gamepad
  72623. * @param index The index of the generic gamepad
  72624. * @param browserGamepad The browser gamepad
  72625. */
  72626. constructor(id: string, index: number, browserGamepad: any);
  72627. private _setButtonValue;
  72628. /**
  72629. * Updates the generic gamepad
  72630. */
  72631. update(): void;
  72632. /**
  72633. * Disposes the generic gamepad
  72634. */
  72635. dispose(): void;
  72636. }
  72637. }
  72638. declare module BABYLON {
  72639. /**
  72640. * Defines the types of pose enabled controllers that are supported
  72641. */
  72642. export enum PoseEnabledControllerType {
  72643. /**
  72644. * HTC Vive
  72645. */
  72646. VIVE = 0,
  72647. /**
  72648. * Oculus Rift
  72649. */
  72650. OCULUS = 1,
  72651. /**
  72652. * Windows mixed reality
  72653. */
  72654. WINDOWS = 2,
  72655. /**
  72656. * Samsung gear VR
  72657. */
  72658. GEAR_VR = 3,
  72659. /**
  72660. * Google Daydream
  72661. */
  72662. DAYDREAM = 4,
  72663. /**
  72664. * Generic
  72665. */
  72666. GENERIC = 5
  72667. }
  72668. /**
  72669. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72670. */
  72671. export interface MutableGamepadButton {
  72672. /**
  72673. * Value of the button/trigger
  72674. */
  72675. value: number;
  72676. /**
  72677. * If the button/trigger is currently touched
  72678. */
  72679. touched: boolean;
  72680. /**
  72681. * If the button/trigger is currently pressed
  72682. */
  72683. pressed: boolean;
  72684. }
  72685. /**
  72686. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72687. * @hidden
  72688. */
  72689. export interface ExtendedGamepadButton extends GamepadButton {
  72690. /**
  72691. * If the button/trigger is currently pressed
  72692. */
  72693. readonly pressed: boolean;
  72694. /**
  72695. * If the button/trigger is currently touched
  72696. */
  72697. readonly touched: boolean;
  72698. /**
  72699. * Value of the button/trigger
  72700. */
  72701. readonly value: number;
  72702. }
  72703. /** @hidden */
  72704. export interface _GamePadFactory {
  72705. /**
  72706. * Returns wether or not the current gamepad can be created for this type of controller.
  72707. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72708. * @returns true if it can be created, otherwise false
  72709. */
  72710. canCreate(gamepadInfo: any): boolean;
  72711. /**
  72712. * Creates a new instance of the Gamepad.
  72713. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72714. * @returns the new gamepad instance
  72715. */
  72716. create(gamepadInfo: any): Gamepad;
  72717. }
  72718. /**
  72719. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72720. */
  72721. export class PoseEnabledControllerHelper {
  72722. /** @hidden */
  72723. static _ControllerFactories: _GamePadFactory[];
  72724. /** @hidden */
  72725. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72726. /**
  72727. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72728. * @param vrGamepad the gamepad to initialized
  72729. * @returns a vr controller of the type the gamepad identified as
  72730. */
  72731. static InitiateController(vrGamepad: any): Gamepad;
  72732. }
  72733. /**
  72734. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72735. */
  72736. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72737. private _deviceRoomPosition;
  72738. private _deviceRoomRotationQuaternion;
  72739. /**
  72740. * The device position in babylon space
  72741. */
  72742. devicePosition: Vector3;
  72743. /**
  72744. * The device rotation in babylon space
  72745. */
  72746. deviceRotationQuaternion: Quaternion;
  72747. /**
  72748. * The scale factor of the device in babylon space
  72749. */
  72750. deviceScaleFactor: number;
  72751. /**
  72752. * (Likely devicePosition should be used instead) The device position in its room space
  72753. */
  72754. position: Vector3;
  72755. /**
  72756. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72757. */
  72758. rotationQuaternion: Quaternion;
  72759. /**
  72760. * The type of controller (Eg. Windows mixed reality)
  72761. */
  72762. controllerType: PoseEnabledControllerType;
  72763. protected _calculatedPosition: Vector3;
  72764. private _calculatedRotation;
  72765. /**
  72766. * The raw pose from the device
  72767. */
  72768. rawPose: DevicePose;
  72769. private _trackPosition;
  72770. private _maxRotationDistFromHeadset;
  72771. private _draggedRoomRotation;
  72772. /**
  72773. * @hidden
  72774. */
  72775. _disableTrackPosition(fixedPosition: Vector3): void;
  72776. /**
  72777. * Internal, the mesh attached to the controller
  72778. * @hidden
  72779. */
  72780. _mesh: Nullable<AbstractMesh>;
  72781. private _poseControlledCamera;
  72782. private _leftHandSystemQuaternion;
  72783. /**
  72784. * Internal, matrix used to convert room space to babylon space
  72785. * @hidden
  72786. */
  72787. _deviceToWorld: Matrix;
  72788. /**
  72789. * Node to be used when casting a ray from the controller
  72790. * @hidden
  72791. */
  72792. _pointingPoseNode: Nullable<TransformNode>;
  72793. /**
  72794. * Name of the child mesh that can be used to cast a ray from the controller
  72795. */
  72796. static readonly POINTING_POSE: string;
  72797. /**
  72798. * Creates a new PoseEnabledController from a gamepad
  72799. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72800. */
  72801. constructor(browserGamepad: any);
  72802. private _workingMatrix;
  72803. /**
  72804. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72805. */
  72806. update(): void;
  72807. /**
  72808. * Updates only the pose device and mesh without doing any button event checking
  72809. */
  72810. protected _updatePoseAndMesh(): void;
  72811. /**
  72812. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72813. * @param poseData raw pose fromthe device
  72814. */
  72815. updateFromDevice(poseData: DevicePose): void;
  72816. /**
  72817. * @hidden
  72818. */
  72819. _meshAttachedObservable: Observable<AbstractMesh>;
  72820. /**
  72821. * Attaches a mesh to the controller
  72822. * @param mesh the mesh to be attached
  72823. */
  72824. attachToMesh(mesh: AbstractMesh): void;
  72825. /**
  72826. * Attaches the controllers mesh to a camera
  72827. * @param camera the camera the mesh should be attached to
  72828. */
  72829. attachToPoseControlledCamera(camera: TargetCamera): void;
  72830. /**
  72831. * Disposes of the controller
  72832. */
  72833. dispose(): void;
  72834. /**
  72835. * The mesh that is attached to the controller
  72836. */
  72837. readonly mesh: Nullable<AbstractMesh>;
  72838. /**
  72839. * Gets the ray of the controller in the direction the controller is pointing
  72840. * @param length the length the resulting ray should be
  72841. * @returns a ray in the direction the controller is pointing
  72842. */
  72843. getForwardRay(length?: number): Ray;
  72844. }
  72845. }
  72846. declare module BABYLON {
  72847. /**
  72848. * Defines the WebVRController object that represents controllers tracked in 3D space
  72849. */
  72850. export abstract class WebVRController extends PoseEnabledController {
  72851. /**
  72852. * Internal, the default controller model for the controller
  72853. */
  72854. protected _defaultModel: AbstractMesh;
  72855. /**
  72856. * Fired when the trigger state has changed
  72857. */
  72858. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72859. /**
  72860. * Fired when the main button state has changed
  72861. */
  72862. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72863. /**
  72864. * Fired when the secondary button state has changed
  72865. */
  72866. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72867. /**
  72868. * Fired when the pad state has changed
  72869. */
  72870. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72871. /**
  72872. * Fired when controllers stick values have changed
  72873. */
  72874. onPadValuesChangedObservable: Observable<StickValues>;
  72875. /**
  72876. * Array of button availible on the controller
  72877. */
  72878. protected _buttons: Array<MutableGamepadButton>;
  72879. private _onButtonStateChange;
  72880. /**
  72881. * Fired when a controller button's state has changed
  72882. * @param callback the callback containing the button that was modified
  72883. */
  72884. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72885. /**
  72886. * X and Y axis corrisponding to the controllers joystick
  72887. */
  72888. pad: StickValues;
  72889. /**
  72890. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72891. */
  72892. hand: string;
  72893. /**
  72894. * The default controller model for the controller
  72895. */
  72896. readonly defaultModel: AbstractMesh;
  72897. /**
  72898. * Creates a new WebVRController from a gamepad
  72899. * @param vrGamepad the gamepad that the WebVRController should be created from
  72900. */
  72901. constructor(vrGamepad: any);
  72902. /**
  72903. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72904. */
  72905. update(): void;
  72906. /**
  72907. * Function to be called when a button is modified
  72908. */
  72909. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72910. /**
  72911. * Loads a mesh and attaches it to the controller
  72912. * @param scene the scene the mesh should be added to
  72913. * @param meshLoaded callback for when the mesh has been loaded
  72914. */
  72915. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72916. private _setButtonValue;
  72917. private _changes;
  72918. private _checkChanges;
  72919. /**
  72920. * Disposes of th webVRCOntroller
  72921. */
  72922. dispose(): void;
  72923. }
  72924. }
  72925. declare module BABYLON {
  72926. /**
  72927. * The HemisphericLight simulates the ambient environment light,
  72928. * so the passed direction is the light reflection direction, not the incoming direction.
  72929. */
  72930. export class HemisphericLight extends Light {
  72931. /**
  72932. * The groundColor is the light in the opposite direction to the one specified during creation.
  72933. * 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.
  72934. */
  72935. groundColor: Color3;
  72936. /**
  72937. * The light reflection direction, not the incoming direction.
  72938. */
  72939. direction: Vector3;
  72940. /**
  72941. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72942. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72943. * The HemisphericLight can't cast shadows.
  72944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72945. * @param name The friendly name of the light
  72946. * @param direction The direction of the light reflection
  72947. * @param scene The scene the light belongs to
  72948. */
  72949. constructor(name: string, direction: Vector3, scene: Scene);
  72950. protected _buildUniformLayout(): void;
  72951. /**
  72952. * Returns the string "HemisphericLight".
  72953. * @return The class name
  72954. */
  72955. getClassName(): string;
  72956. /**
  72957. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72958. * Returns the updated direction.
  72959. * @param target The target the direction should point to
  72960. * @return The computed direction
  72961. */
  72962. setDirectionToTarget(target: Vector3): Vector3;
  72963. /**
  72964. * Returns the shadow generator associated to the light.
  72965. * @returns Always null for hemispheric lights because it does not support shadows.
  72966. */
  72967. getShadowGenerator(): Nullable<IShadowGenerator>;
  72968. /**
  72969. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72970. * @param effect The effect to update
  72971. * @param lightIndex The index of the light in the effect to update
  72972. * @returns The hemispheric light
  72973. */
  72974. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72975. /**
  72976. * Computes the world matrix of the node
  72977. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72978. * @param useWasUpdatedFlag defines a reserved property
  72979. * @returns the world matrix
  72980. */
  72981. computeWorldMatrix(): Matrix;
  72982. /**
  72983. * Returns the integer 3.
  72984. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72985. */
  72986. getTypeID(): number;
  72987. /**
  72988. * Prepares the list of defines specific to the light type.
  72989. * @param defines the list of defines
  72990. * @param lightIndex defines the index of the light for the effect
  72991. */
  72992. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72993. }
  72994. }
  72995. declare module BABYLON {
  72996. /** @hidden */
  72997. export var vrMultiviewToSingleviewPixelShader: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module BABYLON {
  73003. /**
  73004. * Renders to multiple views with a single draw call
  73005. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73006. */
  73007. export class MultiviewRenderTarget extends RenderTargetTexture {
  73008. /**
  73009. * Creates a multiview render target
  73010. * @param scene scene used with the render target
  73011. * @param size the size of the render target (used for each view)
  73012. */
  73013. constructor(scene: Scene, size?: number | {
  73014. width: number;
  73015. height: number;
  73016. } | {
  73017. ratio: number;
  73018. });
  73019. /**
  73020. * @hidden
  73021. * @param faceIndex the face index, if its a cube texture
  73022. */
  73023. _bindFrameBuffer(faceIndex?: number): void;
  73024. /**
  73025. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73026. * @returns the view count
  73027. */
  73028. getViewCount(): number;
  73029. }
  73030. }
  73031. declare module BABYLON {
  73032. interface Engine {
  73033. /**
  73034. * Creates a new multiview render target
  73035. * @param width defines the width of the texture
  73036. * @param height defines the height of the texture
  73037. * @returns the created multiview texture
  73038. */
  73039. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73040. /**
  73041. * Binds a multiview framebuffer to be drawn to
  73042. * @param multiviewTexture texture to bind
  73043. */
  73044. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73045. }
  73046. interface Camera {
  73047. /**
  73048. * @hidden
  73049. * 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)
  73050. */
  73051. _useMultiviewToSingleView: boolean;
  73052. /**
  73053. * @hidden
  73054. * 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)
  73055. */
  73056. _multiviewTexture: Nullable<RenderTargetTexture>;
  73057. /**
  73058. * @hidden
  73059. * ensures the multiview texture of the camera exists and has the specified width/height
  73060. * @param width height to set on the multiview texture
  73061. * @param height width to set on the multiview texture
  73062. */
  73063. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73064. }
  73065. interface Scene {
  73066. /** @hidden */
  73067. _transformMatrixR: Matrix;
  73068. /** @hidden */
  73069. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73070. /** @hidden */
  73071. _createMultiviewUbo(): void;
  73072. /** @hidden */
  73073. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73074. /** @hidden */
  73075. _renderMultiviewToSingleView(camera: Camera): void;
  73076. }
  73077. }
  73078. declare module BABYLON {
  73079. /**
  73080. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73081. * This will not be used for webXR as it supports displaying texture arrays directly
  73082. */
  73083. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73084. /**
  73085. * Initializes a VRMultiviewToSingleview
  73086. * @param name name of the post process
  73087. * @param camera camera to be applied to
  73088. * @param scaleFactor scaling factor to the size of the output texture
  73089. */
  73090. constructor(name: string, camera: Camera, scaleFactor: number);
  73091. }
  73092. }
  73093. declare module BABYLON {
  73094. /**
  73095. * Defines the interface used by display changed events
  73096. */
  73097. interface IDisplayChangedEventArgs {
  73098. /** Gets the vrDisplay object (if any) */
  73099. vrDisplay: Nullable<any>;
  73100. /** Gets a boolean indicating if webVR is supported */
  73101. vrSupported: boolean;
  73102. }
  73103. interface Engine {
  73104. /** @hidden */
  73105. _vrDisplay: any;
  73106. /** @hidden */
  73107. _vrSupported: boolean;
  73108. /** @hidden */
  73109. _oldSize: Size;
  73110. /** @hidden */
  73111. _oldHardwareScaleFactor: number;
  73112. /** @hidden */
  73113. _vrExclusivePointerMode: boolean;
  73114. /** @hidden */
  73115. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73116. /** @hidden */
  73117. _onVRDisplayPointerRestricted: () => void;
  73118. /** @hidden */
  73119. _onVRDisplayPointerUnrestricted: () => void;
  73120. /** @hidden */
  73121. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73122. /** @hidden */
  73123. _onVrDisplayDisconnect: Nullable<() => void>;
  73124. /** @hidden */
  73125. _onVrDisplayPresentChange: Nullable<() => void>;
  73126. /**
  73127. * Observable signaled when VR display mode changes
  73128. */
  73129. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73130. /**
  73131. * Observable signaled when VR request present is complete
  73132. */
  73133. onVRRequestPresentComplete: Observable<boolean>;
  73134. /**
  73135. * Observable signaled when VR request present starts
  73136. */
  73137. onVRRequestPresentStart: Observable<Engine>;
  73138. /**
  73139. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73140. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73141. */
  73142. isInVRExclusivePointerMode: boolean;
  73143. /**
  73144. * Gets a boolean indicating if a webVR device was detected
  73145. * @returns true if a webVR device was detected
  73146. */
  73147. isVRDevicePresent(): boolean;
  73148. /**
  73149. * Gets the current webVR device
  73150. * @returns the current webVR device (or null)
  73151. */
  73152. getVRDevice(): any;
  73153. /**
  73154. * Initializes a webVR display and starts listening to display change events
  73155. * The onVRDisplayChangedObservable will be notified upon these changes
  73156. * @returns A promise containing a VRDisplay and if vr is supported
  73157. */
  73158. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73159. /** @hidden */
  73160. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73161. /**
  73162. * Call this function to switch to webVR mode
  73163. * Will do nothing if webVR is not supported or if there is no webVR device
  73164. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73165. */
  73166. enableVR(): void;
  73167. /** @hidden */
  73168. _onVRFullScreenTriggered(): void;
  73169. }
  73170. }
  73171. declare module BABYLON {
  73172. /**
  73173. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73174. * IMPORTANT!! The data is right-hand data.
  73175. * @export
  73176. * @interface DevicePose
  73177. */
  73178. export interface DevicePose {
  73179. /**
  73180. * The position of the device, values in array are [x,y,z].
  73181. */
  73182. readonly position: Nullable<Float32Array>;
  73183. /**
  73184. * The linearVelocity of the device, values in array are [x,y,z].
  73185. */
  73186. readonly linearVelocity: Nullable<Float32Array>;
  73187. /**
  73188. * The linearAcceleration of the device, values in array are [x,y,z].
  73189. */
  73190. readonly linearAcceleration: Nullable<Float32Array>;
  73191. /**
  73192. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73193. */
  73194. readonly orientation: Nullable<Float32Array>;
  73195. /**
  73196. * The angularVelocity of the device, values in array are [x,y,z].
  73197. */
  73198. readonly angularVelocity: Nullable<Float32Array>;
  73199. /**
  73200. * The angularAcceleration of the device, values in array are [x,y,z].
  73201. */
  73202. readonly angularAcceleration: Nullable<Float32Array>;
  73203. }
  73204. /**
  73205. * Interface representing a pose controlled object in Babylon.
  73206. * A pose controlled object has both regular pose values as well as pose values
  73207. * from an external device such as a VR head mounted display
  73208. */
  73209. export interface PoseControlled {
  73210. /**
  73211. * The position of the object in babylon space.
  73212. */
  73213. position: Vector3;
  73214. /**
  73215. * The rotation quaternion of the object in babylon space.
  73216. */
  73217. rotationQuaternion: Quaternion;
  73218. /**
  73219. * The position of the device in babylon space.
  73220. */
  73221. devicePosition?: Vector3;
  73222. /**
  73223. * The rotation quaternion of the device in babylon space.
  73224. */
  73225. deviceRotationQuaternion: Quaternion;
  73226. /**
  73227. * The raw pose coming from the device.
  73228. */
  73229. rawPose: Nullable<DevicePose>;
  73230. /**
  73231. * The scale of the device to be used when translating from device space to babylon space.
  73232. */
  73233. deviceScaleFactor: number;
  73234. /**
  73235. * Updates the poseControlled values based on the input device pose.
  73236. * @param poseData the pose data to update the object with
  73237. */
  73238. updateFromDevice(poseData: DevicePose): void;
  73239. }
  73240. /**
  73241. * Set of options to customize the webVRCamera
  73242. */
  73243. export interface WebVROptions {
  73244. /**
  73245. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73246. */
  73247. trackPosition?: boolean;
  73248. /**
  73249. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73250. */
  73251. positionScale?: number;
  73252. /**
  73253. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73254. */
  73255. displayName?: string;
  73256. /**
  73257. * Should the native controller meshes be initialized. (default: true)
  73258. */
  73259. controllerMeshes?: boolean;
  73260. /**
  73261. * Creating a default HemiLight only on controllers. (default: true)
  73262. */
  73263. defaultLightingOnControllers?: boolean;
  73264. /**
  73265. * If you don't want to use the default VR button of the helper. (default: false)
  73266. */
  73267. useCustomVRButton?: boolean;
  73268. /**
  73269. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73270. */
  73271. customVRButton?: HTMLButtonElement;
  73272. /**
  73273. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73274. */
  73275. rayLength?: number;
  73276. /**
  73277. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73278. */
  73279. defaultHeight?: number;
  73280. /**
  73281. * If multiview should be used if availible (default: false)
  73282. */
  73283. useMultiview?: boolean;
  73284. }
  73285. /**
  73286. * This represents a WebVR camera.
  73287. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73288. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73289. */
  73290. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73291. private webVROptions;
  73292. /**
  73293. * @hidden
  73294. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73295. */
  73296. _vrDevice: any;
  73297. /**
  73298. * The rawPose of the vrDevice.
  73299. */
  73300. rawPose: Nullable<DevicePose>;
  73301. private _onVREnabled;
  73302. private _specsVersion;
  73303. private _attached;
  73304. private _frameData;
  73305. protected _descendants: Array<Node>;
  73306. private _deviceRoomPosition;
  73307. /** @hidden */
  73308. _deviceRoomRotationQuaternion: Quaternion;
  73309. private _standingMatrix;
  73310. /**
  73311. * Represents device position in babylon space.
  73312. */
  73313. devicePosition: Vector3;
  73314. /**
  73315. * Represents device rotation in babylon space.
  73316. */
  73317. deviceRotationQuaternion: Quaternion;
  73318. /**
  73319. * The scale of the device to be used when translating from device space to babylon space.
  73320. */
  73321. deviceScaleFactor: number;
  73322. private _deviceToWorld;
  73323. private _worldToDevice;
  73324. /**
  73325. * References to the webVR controllers for the vrDevice.
  73326. */
  73327. controllers: Array<WebVRController>;
  73328. /**
  73329. * Emits an event when a controller is attached.
  73330. */
  73331. onControllersAttachedObservable: Observable<WebVRController[]>;
  73332. /**
  73333. * Emits an event when a controller's mesh has been loaded;
  73334. */
  73335. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73336. /**
  73337. * Emits an event when the HMD's pose has been updated.
  73338. */
  73339. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73340. private _poseSet;
  73341. /**
  73342. * If the rig cameras be used as parent instead of this camera.
  73343. */
  73344. rigParenting: boolean;
  73345. private _lightOnControllers;
  73346. private _defaultHeight?;
  73347. /**
  73348. * Instantiates a WebVRFreeCamera.
  73349. * @param name The name of the WebVRFreeCamera
  73350. * @param position The starting anchor position for the camera
  73351. * @param scene The scene the camera belongs to
  73352. * @param webVROptions a set of customizable options for the webVRCamera
  73353. */
  73354. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73355. /**
  73356. * Gets the device distance from the ground in meters.
  73357. * @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.
  73358. */
  73359. deviceDistanceToRoomGround(): number;
  73360. /**
  73361. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73362. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73363. */
  73364. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73365. /**
  73366. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73367. * @returns A promise with a boolean set to if the standing matrix is supported.
  73368. */
  73369. useStandingMatrixAsync(): Promise<boolean>;
  73370. /**
  73371. * Disposes the camera
  73372. */
  73373. dispose(): void;
  73374. /**
  73375. * Gets a vrController by name.
  73376. * @param name The name of the controller to retreive
  73377. * @returns the controller matching the name specified or null if not found
  73378. */
  73379. getControllerByName(name: string): Nullable<WebVRController>;
  73380. private _leftController;
  73381. /**
  73382. * The controller corrisponding to the users left hand.
  73383. */
  73384. readonly leftController: Nullable<WebVRController>;
  73385. private _rightController;
  73386. /**
  73387. * The controller corrisponding to the users right hand.
  73388. */
  73389. readonly rightController: Nullable<WebVRController>;
  73390. /**
  73391. * Casts a ray forward from the vrCamera's gaze.
  73392. * @param length Length of the ray (default: 100)
  73393. * @returns the ray corrisponding to the gaze
  73394. */
  73395. getForwardRay(length?: number): Ray;
  73396. /**
  73397. * @hidden
  73398. * Updates the camera based on device's frame data
  73399. */
  73400. _checkInputs(): void;
  73401. /**
  73402. * Updates the poseControlled values based on the input device pose.
  73403. * @param poseData Pose coming from the device
  73404. */
  73405. updateFromDevice(poseData: DevicePose): void;
  73406. private _htmlElementAttached;
  73407. private _detachIfAttached;
  73408. /**
  73409. * WebVR's attach control will start broadcasting frames to the device.
  73410. * Note that in certain browsers (chrome for example) this function must be called
  73411. * within a user-interaction callback. Example:
  73412. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73413. *
  73414. * @param element html element to attach the vrDevice to
  73415. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73416. */
  73417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73418. /**
  73419. * Detaches the camera from the html element and disables VR
  73420. *
  73421. * @param element html element to detach from
  73422. */
  73423. detachControl(element: HTMLElement): void;
  73424. /**
  73425. * @returns the name of this class
  73426. */
  73427. getClassName(): string;
  73428. /**
  73429. * Calls resetPose on the vrDisplay
  73430. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73431. */
  73432. resetToCurrentRotation(): void;
  73433. /**
  73434. * @hidden
  73435. * Updates the rig cameras (left and right eye)
  73436. */
  73437. _updateRigCameras(): void;
  73438. private _workingVector;
  73439. private _oneVector;
  73440. private _workingMatrix;
  73441. private updateCacheCalled;
  73442. private _correctPositionIfNotTrackPosition;
  73443. /**
  73444. * @hidden
  73445. * Updates the cached values of the camera
  73446. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73447. */
  73448. _updateCache(ignoreParentClass?: boolean): void;
  73449. /**
  73450. * @hidden
  73451. * Get current device position in babylon world
  73452. */
  73453. _computeDevicePosition(): void;
  73454. /**
  73455. * Updates the current device position and rotation in the babylon world
  73456. */
  73457. update(): void;
  73458. /**
  73459. * @hidden
  73460. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73461. * @returns an identity matrix
  73462. */
  73463. _getViewMatrix(): Matrix;
  73464. private _tmpMatrix;
  73465. /**
  73466. * This function is called by the two RIG cameras.
  73467. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73468. * @hidden
  73469. */
  73470. _getWebVRViewMatrix(): Matrix;
  73471. /** @hidden */
  73472. _getWebVRProjectionMatrix(): Matrix;
  73473. private _onGamepadConnectedObserver;
  73474. private _onGamepadDisconnectedObserver;
  73475. private _updateCacheWhenTrackingDisabledObserver;
  73476. /**
  73477. * Initializes the controllers and their meshes
  73478. */
  73479. initControllers(): void;
  73480. }
  73481. }
  73482. declare module BABYLON {
  73483. /**
  73484. * Size options for a post process
  73485. */
  73486. export type PostProcessOptions = {
  73487. width: number;
  73488. height: number;
  73489. };
  73490. /**
  73491. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73492. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73493. */
  73494. export class PostProcess {
  73495. /** Name of the PostProcess. */
  73496. name: string;
  73497. /**
  73498. * Gets or sets the unique id of the post process
  73499. */
  73500. uniqueId: number;
  73501. /**
  73502. * Width of the texture to apply the post process on
  73503. */
  73504. width: number;
  73505. /**
  73506. * Height of the texture to apply the post process on
  73507. */
  73508. height: number;
  73509. /**
  73510. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73511. * @hidden
  73512. */
  73513. _outputTexture: Nullable<InternalTexture>;
  73514. /**
  73515. * Sampling mode used by the shader
  73516. * See https://doc.babylonjs.com/classes/3.1/texture
  73517. */
  73518. renderTargetSamplingMode: number;
  73519. /**
  73520. * Clear color to use when screen clearing
  73521. */
  73522. clearColor: Color4;
  73523. /**
  73524. * If the buffer needs to be cleared before applying the post process. (default: true)
  73525. * Should be set to false if shader will overwrite all previous pixels.
  73526. */
  73527. autoClear: boolean;
  73528. /**
  73529. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73530. */
  73531. alphaMode: number;
  73532. /**
  73533. * Sets the setAlphaBlendConstants of the babylon engine
  73534. */
  73535. alphaConstants: Color4;
  73536. /**
  73537. * Animations to be used for the post processing
  73538. */
  73539. animations: Animation[];
  73540. /**
  73541. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73542. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73543. */
  73544. enablePixelPerfectMode: boolean;
  73545. /**
  73546. * Force the postprocess to be applied without taking in account viewport
  73547. */
  73548. forceFullscreenViewport: boolean;
  73549. /**
  73550. * List of inspectable custom properties (used by the Inspector)
  73551. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73552. */
  73553. inspectableCustomProperties: IInspectable[];
  73554. /**
  73555. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73556. *
  73557. * | Value | Type | Description |
  73558. * | ----- | ----------------------------------- | ----------- |
  73559. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73560. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73561. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73562. *
  73563. */
  73564. scaleMode: number;
  73565. /**
  73566. * Force textures to be a power of two (default: false)
  73567. */
  73568. alwaysForcePOT: boolean;
  73569. private _samples;
  73570. /**
  73571. * Number of sample textures (default: 1)
  73572. */
  73573. samples: number;
  73574. /**
  73575. * Modify the scale of the post process to be the same as the viewport (default: false)
  73576. */
  73577. adaptScaleToCurrentViewport: boolean;
  73578. private _camera;
  73579. private _scene;
  73580. private _engine;
  73581. private _options;
  73582. private _reusable;
  73583. private _textureType;
  73584. /**
  73585. * Smart array of input and output textures for the post process.
  73586. * @hidden
  73587. */
  73588. _textures: SmartArray<InternalTexture>;
  73589. /**
  73590. * The index in _textures that corresponds to the output texture.
  73591. * @hidden
  73592. */
  73593. _currentRenderTextureInd: number;
  73594. private _effect;
  73595. private _samplers;
  73596. private _fragmentUrl;
  73597. private _vertexUrl;
  73598. private _parameters;
  73599. private _scaleRatio;
  73600. protected _indexParameters: any;
  73601. private _shareOutputWithPostProcess;
  73602. private _texelSize;
  73603. private _forcedOutputTexture;
  73604. /**
  73605. * Returns the fragment url or shader name used in the post process.
  73606. * @returns the fragment url or name in the shader store.
  73607. */
  73608. getEffectName(): string;
  73609. /**
  73610. * An event triggered when the postprocess is activated.
  73611. */
  73612. onActivateObservable: Observable<Camera>;
  73613. private _onActivateObserver;
  73614. /**
  73615. * A function that is added to the onActivateObservable
  73616. */
  73617. onActivate: Nullable<(camera: Camera) => void>;
  73618. /**
  73619. * An event triggered when the postprocess changes its size.
  73620. */
  73621. onSizeChangedObservable: Observable<PostProcess>;
  73622. private _onSizeChangedObserver;
  73623. /**
  73624. * A function that is added to the onSizeChangedObservable
  73625. */
  73626. onSizeChanged: (postProcess: PostProcess) => void;
  73627. /**
  73628. * An event triggered when the postprocess applies its effect.
  73629. */
  73630. onApplyObservable: Observable<Effect>;
  73631. private _onApplyObserver;
  73632. /**
  73633. * A function that is added to the onApplyObservable
  73634. */
  73635. onApply: (effect: Effect) => void;
  73636. /**
  73637. * An event triggered before rendering the postprocess
  73638. */
  73639. onBeforeRenderObservable: Observable<Effect>;
  73640. private _onBeforeRenderObserver;
  73641. /**
  73642. * A function that is added to the onBeforeRenderObservable
  73643. */
  73644. onBeforeRender: (effect: Effect) => void;
  73645. /**
  73646. * An event triggered after rendering the postprocess
  73647. */
  73648. onAfterRenderObservable: Observable<Effect>;
  73649. private _onAfterRenderObserver;
  73650. /**
  73651. * A function that is added to the onAfterRenderObservable
  73652. */
  73653. onAfterRender: (efect: Effect) => void;
  73654. /**
  73655. * 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
  73656. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73657. */
  73658. inputTexture: InternalTexture;
  73659. /**
  73660. * Gets the camera which post process is applied to.
  73661. * @returns The camera the post process is applied to.
  73662. */
  73663. getCamera(): Camera;
  73664. /**
  73665. * Gets the texel size of the postprocess.
  73666. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73667. */
  73668. readonly texelSize: Vector2;
  73669. /**
  73670. * Creates a new instance PostProcess
  73671. * @param name The name of the PostProcess.
  73672. * @param fragmentUrl The url of the fragment shader to be used.
  73673. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73674. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73675. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73676. * @param camera The camera to apply the render pass to.
  73677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73678. * @param engine The engine which the post process will be applied. (default: current engine)
  73679. * @param reusable If the post process can be reused on the same frame. (default: false)
  73680. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73681. * @param textureType Type of textures used when performing the post process. (default: 0)
  73682. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73683. * @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
  73684. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73685. */
  73686. constructor(
  73687. /** Name of the PostProcess. */
  73688. 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);
  73689. /**
  73690. * Gets a string idenfifying the name of the class
  73691. * @returns "PostProcess" string
  73692. */
  73693. getClassName(): string;
  73694. /**
  73695. * Gets the engine which this post process belongs to.
  73696. * @returns The engine the post process was enabled with.
  73697. */
  73698. getEngine(): Engine;
  73699. /**
  73700. * The effect that is created when initializing the post process.
  73701. * @returns The created effect corrisponding the the postprocess.
  73702. */
  73703. getEffect(): Effect;
  73704. /**
  73705. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73706. * @param postProcess The post process to share the output with.
  73707. * @returns This post process.
  73708. */
  73709. shareOutputWith(postProcess: PostProcess): PostProcess;
  73710. /**
  73711. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73712. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73713. */
  73714. useOwnOutput(): void;
  73715. /**
  73716. * Updates the effect with the current post process compile time values and recompiles the shader.
  73717. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73718. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73719. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73720. * @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
  73721. * @param onCompiled Called when the shader has been compiled.
  73722. * @param onError Called if there is an error when compiling a shader.
  73723. */
  73724. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73725. /**
  73726. * The post process is reusable if it can be used multiple times within one frame.
  73727. * @returns If the post process is reusable
  73728. */
  73729. isReusable(): boolean;
  73730. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73731. markTextureDirty(): void;
  73732. /**
  73733. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73734. * 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.
  73735. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73736. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73737. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73738. * @returns The target texture that was bound to be written to.
  73739. */
  73740. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73741. /**
  73742. * If the post process is supported.
  73743. */
  73744. readonly isSupported: boolean;
  73745. /**
  73746. * The aspect ratio of the output texture.
  73747. */
  73748. readonly aspectRatio: number;
  73749. /**
  73750. * Get a value indicating if the post-process is ready to be used
  73751. * @returns true if the post-process is ready (shader is compiled)
  73752. */
  73753. isReady(): boolean;
  73754. /**
  73755. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73756. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73757. */
  73758. apply(): Nullable<Effect>;
  73759. private _disposeTextures;
  73760. /**
  73761. * Disposes the post process.
  73762. * @param camera The camera to dispose the post process on.
  73763. */
  73764. dispose(camera?: Camera): void;
  73765. }
  73766. }
  73767. declare module BABYLON {
  73768. /**
  73769. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73770. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73771. */
  73772. export class PostProcessManager {
  73773. private _scene;
  73774. private _indexBuffer;
  73775. private _vertexBuffers;
  73776. /**
  73777. * Creates a new instance PostProcess
  73778. * @param scene The scene that the post process is associated with.
  73779. */
  73780. constructor(scene: Scene);
  73781. private _prepareBuffers;
  73782. private _buildIndexBuffer;
  73783. /**
  73784. * Rebuilds the vertex buffers of the manager.
  73785. * @hidden
  73786. */
  73787. _rebuild(): void;
  73788. /**
  73789. * Prepares a frame to be run through a post process.
  73790. * @param sourceTexture The input texture to the post procesess. (default: null)
  73791. * @param postProcesses An array of post processes to be run. (default: null)
  73792. * @returns True if the post processes were able to be run.
  73793. * @hidden
  73794. */
  73795. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73796. /**
  73797. * Manually render a set of post processes to a texture.
  73798. * @param postProcesses An array of post processes to be run.
  73799. * @param targetTexture The target texture to render to.
  73800. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73801. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73802. * @param lodLevel defines which lod of the texture to render to
  73803. */
  73804. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73805. /**
  73806. * Finalize the result of the output of the postprocesses.
  73807. * @param doNotPresent If true the result will not be displayed to the screen.
  73808. * @param targetTexture The target texture to render to.
  73809. * @param faceIndex The index of the face to bind the target texture to.
  73810. * @param postProcesses The array of post processes to render.
  73811. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73812. * @hidden
  73813. */
  73814. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73815. /**
  73816. * Disposes of the post process manager.
  73817. */
  73818. dispose(): void;
  73819. }
  73820. }
  73821. declare module BABYLON {
  73822. interface AbstractScene {
  73823. /**
  73824. * The list of layers (background and foreground) of the scene
  73825. */
  73826. layers: Array<Layer>;
  73827. }
  73828. /**
  73829. * Defines the layer scene component responsible to manage any layers
  73830. * in a given scene.
  73831. */
  73832. export class LayerSceneComponent implements ISceneComponent {
  73833. /**
  73834. * The component name helpfull to identify the component in the list of scene components.
  73835. */
  73836. readonly name: string;
  73837. /**
  73838. * The scene the component belongs to.
  73839. */
  73840. scene: Scene;
  73841. private _engine;
  73842. /**
  73843. * Creates a new instance of the component for the given scene
  73844. * @param scene Defines the scene to register the component in
  73845. */
  73846. constructor(scene: Scene);
  73847. /**
  73848. * Registers the component in a given scene
  73849. */
  73850. register(): void;
  73851. /**
  73852. * Rebuilds the elements related to this component in case of
  73853. * context lost for instance.
  73854. */
  73855. rebuild(): void;
  73856. /**
  73857. * Disposes the component and the associated ressources.
  73858. */
  73859. dispose(): void;
  73860. private _draw;
  73861. private _drawCameraPredicate;
  73862. private _drawCameraBackground;
  73863. private _drawCameraForeground;
  73864. private _drawRenderTargetPredicate;
  73865. private _drawRenderTargetBackground;
  73866. private _drawRenderTargetForeground;
  73867. }
  73868. }
  73869. declare module BABYLON {
  73870. /** @hidden */
  73871. export var layerPixelShader: {
  73872. name: string;
  73873. shader: string;
  73874. };
  73875. }
  73876. declare module BABYLON {
  73877. /** @hidden */
  73878. export var layerVertexShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * This represents a full screen 2d layer.
  73886. * This can be useful to display a picture in the background of your scene for instance.
  73887. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73888. */
  73889. export class Layer {
  73890. /**
  73891. * Define the name of the layer.
  73892. */
  73893. name: string;
  73894. /**
  73895. * Define the texture the layer should display.
  73896. */
  73897. texture: Nullable<Texture>;
  73898. /**
  73899. * Is the layer in background or foreground.
  73900. */
  73901. isBackground: boolean;
  73902. /**
  73903. * Define the color of the layer (instead of texture).
  73904. */
  73905. color: Color4;
  73906. /**
  73907. * Define the scale of the layer in order to zoom in out of the texture.
  73908. */
  73909. scale: Vector2;
  73910. /**
  73911. * Define an offset for the layer in order to shift the texture.
  73912. */
  73913. offset: Vector2;
  73914. /**
  73915. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73916. */
  73917. alphaBlendingMode: number;
  73918. /**
  73919. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73920. * Alpha test will not mix with the background color in case of transparency.
  73921. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73922. */
  73923. alphaTest: boolean;
  73924. /**
  73925. * Define a mask to restrict the layer to only some of the scene cameras.
  73926. */
  73927. layerMask: number;
  73928. /**
  73929. * Define the list of render target the layer is visible into.
  73930. */
  73931. renderTargetTextures: RenderTargetTexture[];
  73932. /**
  73933. * Define if the layer is only used in renderTarget or if it also
  73934. * renders in the main frame buffer of the canvas.
  73935. */
  73936. renderOnlyInRenderTargetTextures: boolean;
  73937. private _scene;
  73938. private _vertexBuffers;
  73939. private _indexBuffer;
  73940. private _effect;
  73941. private _alphaTestEffect;
  73942. /**
  73943. * An event triggered when the layer is disposed.
  73944. */
  73945. onDisposeObservable: Observable<Layer>;
  73946. private _onDisposeObserver;
  73947. /**
  73948. * Back compatibility with callback before the onDisposeObservable existed.
  73949. * The set callback will be triggered when the layer has been disposed.
  73950. */
  73951. onDispose: () => void;
  73952. /**
  73953. * An event triggered before rendering the scene
  73954. */
  73955. onBeforeRenderObservable: Observable<Layer>;
  73956. private _onBeforeRenderObserver;
  73957. /**
  73958. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73959. * The set callback will be triggered just before rendering the layer.
  73960. */
  73961. onBeforeRender: () => void;
  73962. /**
  73963. * An event triggered after rendering the scene
  73964. */
  73965. onAfterRenderObservable: Observable<Layer>;
  73966. private _onAfterRenderObserver;
  73967. /**
  73968. * Back compatibility with callback before the onAfterRenderObservable existed.
  73969. * The set callback will be triggered just after rendering the layer.
  73970. */
  73971. onAfterRender: () => void;
  73972. /**
  73973. * Instantiates a new layer.
  73974. * This represents a full screen 2d layer.
  73975. * This can be useful to display a picture in the background of your scene for instance.
  73976. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73977. * @param name Define the name of the layer in the scene
  73978. * @param imgUrl Define the url of the texture to display in the layer
  73979. * @param scene Define the scene the layer belongs to
  73980. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73981. * @param color Defines a color for the layer
  73982. */
  73983. constructor(
  73984. /**
  73985. * Define the name of the layer.
  73986. */
  73987. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73988. private _createIndexBuffer;
  73989. /** @hidden */
  73990. _rebuild(): void;
  73991. /**
  73992. * Renders the layer in the scene.
  73993. */
  73994. render(): void;
  73995. /**
  73996. * Disposes and releases the associated ressources.
  73997. */
  73998. dispose(): void;
  73999. }
  74000. }
  74001. declare module BABYLON {
  74002. interface AbstractScene {
  74003. /**
  74004. * The list of procedural textures added to the scene
  74005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74006. */
  74007. proceduralTextures: Array<ProceduralTexture>;
  74008. }
  74009. /**
  74010. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74011. * in a given scene.
  74012. */
  74013. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74014. /**
  74015. * The component name helpfull to identify the component in the list of scene components.
  74016. */
  74017. readonly name: string;
  74018. /**
  74019. * The scene the component belongs to.
  74020. */
  74021. scene: Scene;
  74022. /**
  74023. * Creates a new instance of the component for the given scene
  74024. * @param scene Defines the scene to register the component in
  74025. */
  74026. constructor(scene: Scene);
  74027. /**
  74028. * Registers the component in a given scene
  74029. */
  74030. register(): void;
  74031. /**
  74032. * Rebuilds the elements related to this component in case of
  74033. * context lost for instance.
  74034. */
  74035. rebuild(): void;
  74036. /**
  74037. * Disposes the component and the associated ressources.
  74038. */
  74039. dispose(): void;
  74040. private _beforeClear;
  74041. }
  74042. }
  74043. declare module BABYLON {
  74044. interface Engine {
  74045. /**
  74046. * Creates a new render target cube texture
  74047. * @param size defines the size of the texture
  74048. * @param options defines the options used to create the texture
  74049. * @returns a new render target cube texture stored in an InternalTexture
  74050. */
  74051. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74052. }
  74053. }
  74054. declare module BABYLON {
  74055. /** @hidden */
  74056. export var proceduralVertexShader: {
  74057. name: string;
  74058. shader: string;
  74059. };
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * 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.
  74064. * This is the base class of any Procedural texture and contains most of the shareable code.
  74065. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74066. */
  74067. export class ProceduralTexture extends Texture {
  74068. isCube: boolean;
  74069. /**
  74070. * Define if the texture is enabled or not (disabled texture will not render)
  74071. */
  74072. isEnabled: boolean;
  74073. /**
  74074. * Define if the texture must be cleared before rendering (default is true)
  74075. */
  74076. autoClear: boolean;
  74077. /**
  74078. * Callback called when the texture is generated
  74079. */
  74080. onGenerated: () => void;
  74081. /**
  74082. * Event raised when the texture is generated
  74083. */
  74084. onGeneratedObservable: Observable<ProceduralTexture>;
  74085. /** @hidden */
  74086. _generateMipMaps: boolean;
  74087. /** @hidden **/
  74088. _effect: Effect;
  74089. /** @hidden */
  74090. _textures: {
  74091. [key: string]: Texture;
  74092. };
  74093. private _size;
  74094. private _currentRefreshId;
  74095. private _refreshRate;
  74096. private _vertexBuffers;
  74097. private _indexBuffer;
  74098. private _uniforms;
  74099. private _samplers;
  74100. private _fragment;
  74101. private _floats;
  74102. private _ints;
  74103. private _floatsArrays;
  74104. private _colors3;
  74105. private _colors4;
  74106. private _vectors2;
  74107. private _vectors3;
  74108. private _matrices;
  74109. private _fallbackTexture;
  74110. private _fallbackTextureUsed;
  74111. private _engine;
  74112. private _cachedDefines;
  74113. private _contentUpdateId;
  74114. private _contentData;
  74115. /**
  74116. * Instantiates a new procedural texture.
  74117. * 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.
  74118. * This is the base class of any Procedural texture and contains most of the shareable code.
  74119. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74120. * @param name Define the name of the texture
  74121. * @param size Define the size of the texture to create
  74122. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74123. * @param scene Define the scene the texture belongs to
  74124. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74125. * @param generateMipMaps Define if the texture should creates mip maps or not
  74126. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74127. */
  74128. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74129. /**
  74130. * The effect that is created when initializing the post process.
  74131. * @returns The created effect corrisponding the the postprocess.
  74132. */
  74133. getEffect(): Effect;
  74134. /**
  74135. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74136. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74137. */
  74138. getContent(): Nullable<ArrayBufferView>;
  74139. private _createIndexBuffer;
  74140. /** @hidden */
  74141. _rebuild(): void;
  74142. /**
  74143. * Resets the texture in order to recreate its associated resources.
  74144. * This can be called in case of context loss
  74145. */
  74146. reset(): void;
  74147. protected _getDefines(): string;
  74148. /**
  74149. * Is the texture ready to be used ? (rendered at least once)
  74150. * @returns true if ready, otherwise, false.
  74151. */
  74152. isReady(): boolean;
  74153. /**
  74154. * Resets the refresh counter of the texture and start bak from scratch.
  74155. * Could be useful to regenerate the texture if it is setup to render only once.
  74156. */
  74157. resetRefreshCounter(): void;
  74158. /**
  74159. * Set the fragment shader to use in order to render the texture.
  74160. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74161. */
  74162. setFragment(fragment: any): void;
  74163. /**
  74164. * Define the refresh rate of the texture or the rendering frequency.
  74165. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74166. */
  74167. refreshRate: number;
  74168. /** @hidden */
  74169. _shouldRender(): boolean;
  74170. /**
  74171. * Get the size the texture is rendering at.
  74172. * @returns the size (texture is always squared)
  74173. */
  74174. getRenderSize(): number;
  74175. /**
  74176. * Resize the texture to new value.
  74177. * @param size Define the new size the texture should have
  74178. * @param generateMipMaps Define whether the new texture should create mip maps
  74179. */
  74180. resize(size: number, generateMipMaps: boolean): void;
  74181. private _checkUniform;
  74182. /**
  74183. * Set a texture in the shader program used to render.
  74184. * @param name Define the name of the uniform samplers as defined in the shader
  74185. * @param texture Define the texture to bind to this sampler
  74186. * @return the texture itself allowing "fluent" like uniform updates
  74187. */
  74188. setTexture(name: string, texture: Texture): ProceduralTexture;
  74189. /**
  74190. * Set a float in the shader.
  74191. * @param name Define the name of the uniform as defined in the shader
  74192. * @param value Define the value to give to the uniform
  74193. * @return the texture itself allowing "fluent" like uniform updates
  74194. */
  74195. setFloat(name: string, value: number): ProceduralTexture;
  74196. /**
  74197. * Set a int in the shader.
  74198. * @param name Define the name of the uniform as defined in the shader
  74199. * @param value Define the value to give to the uniform
  74200. * @return the texture itself allowing "fluent" like uniform updates
  74201. */
  74202. setInt(name: string, value: number): ProceduralTexture;
  74203. /**
  74204. * Set an array of floats in the shader.
  74205. * @param name Define the name of the uniform as defined in the shader
  74206. * @param value Define the value to give to the uniform
  74207. * @return the texture itself allowing "fluent" like uniform updates
  74208. */
  74209. setFloats(name: string, value: number[]): ProceduralTexture;
  74210. /**
  74211. * Set a vec3 in the shader from a Color3.
  74212. * @param name Define the name of the uniform as defined in the shader
  74213. * @param value Define the value to give to the uniform
  74214. * @return the texture itself allowing "fluent" like uniform updates
  74215. */
  74216. setColor3(name: string, value: Color3): ProceduralTexture;
  74217. /**
  74218. * Set a vec4 in the shader from a Color4.
  74219. * @param name Define the name of the uniform as defined in the shader
  74220. * @param value Define the value to give to the uniform
  74221. * @return the texture itself allowing "fluent" like uniform updates
  74222. */
  74223. setColor4(name: string, value: Color4): ProceduralTexture;
  74224. /**
  74225. * Set a vec2 in the shader from a Vector2.
  74226. * @param name Define the name of the uniform as defined in the shader
  74227. * @param value Define the value to give to the uniform
  74228. * @return the texture itself allowing "fluent" like uniform updates
  74229. */
  74230. setVector2(name: string, value: Vector2): ProceduralTexture;
  74231. /**
  74232. * Set a vec3 in the shader from a Vector3.
  74233. * @param name Define the name of the uniform as defined in the shader
  74234. * @param value Define the value to give to the uniform
  74235. * @return the texture itself allowing "fluent" like uniform updates
  74236. */
  74237. setVector3(name: string, value: Vector3): ProceduralTexture;
  74238. /**
  74239. * Set a mat4 in the shader from a MAtrix.
  74240. * @param name Define the name of the uniform as defined in the shader
  74241. * @param value Define the value to give to the uniform
  74242. * @return the texture itself allowing "fluent" like uniform updates
  74243. */
  74244. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74245. /**
  74246. * Render the texture to its associated render target.
  74247. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74248. */
  74249. render(useCameraPostProcess?: boolean): void;
  74250. /**
  74251. * Clone the texture.
  74252. * @returns the cloned texture
  74253. */
  74254. clone(): ProceduralTexture;
  74255. /**
  74256. * Dispose the texture and release its asoociated resources.
  74257. */
  74258. dispose(): void;
  74259. }
  74260. }
  74261. declare module BABYLON {
  74262. /**
  74263. * This represents the base class for particle system in Babylon.
  74264. * 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.
  74265. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74266. * @example https://doc.babylonjs.com/babylon101/particles
  74267. */
  74268. export class BaseParticleSystem {
  74269. /**
  74270. * Source color is added to the destination color without alpha affecting the result
  74271. */
  74272. static BLENDMODE_ONEONE: number;
  74273. /**
  74274. * Blend current color and particle color using particle’s alpha
  74275. */
  74276. static BLENDMODE_STANDARD: number;
  74277. /**
  74278. * Add current color and particle color multiplied by particle’s alpha
  74279. */
  74280. static BLENDMODE_ADD: number;
  74281. /**
  74282. * Multiply current color with particle color
  74283. */
  74284. static BLENDMODE_MULTIPLY: number;
  74285. /**
  74286. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74287. */
  74288. static BLENDMODE_MULTIPLYADD: number;
  74289. /**
  74290. * List of animations used by the particle system.
  74291. */
  74292. animations: Animation[];
  74293. /**
  74294. * The id of the Particle system.
  74295. */
  74296. id: string;
  74297. /**
  74298. * The friendly name of the Particle system.
  74299. */
  74300. name: string;
  74301. /**
  74302. * The rendering group used by the Particle system to chose when to render.
  74303. */
  74304. renderingGroupId: number;
  74305. /**
  74306. * The emitter represents the Mesh or position we are attaching the particle system to.
  74307. */
  74308. emitter: Nullable<AbstractMesh | Vector3>;
  74309. /**
  74310. * The maximum number of particles to emit per frame
  74311. */
  74312. emitRate: number;
  74313. /**
  74314. * If you want to launch only a few particles at once, that can be done, as well.
  74315. */
  74316. manualEmitCount: number;
  74317. /**
  74318. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74319. */
  74320. updateSpeed: number;
  74321. /**
  74322. * The amount of time the particle system is running (depends of the overall update speed).
  74323. */
  74324. targetStopDuration: number;
  74325. /**
  74326. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74327. */
  74328. disposeOnStop: boolean;
  74329. /**
  74330. * Minimum power of emitting particles.
  74331. */
  74332. minEmitPower: number;
  74333. /**
  74334. * Maximum power of emitting particles.
  74335. */
  74336. maxEmitPower: number;
  74337. /**
  74338. * Minimum life time of emitting particles.
  74339. */
  74340. minLifeTime: number;
  74341. /**
  74342. * Maximum life time of emitting particles.
  74343. */
  74344. maxLifeTime: number;
  74345. /**
  74346. * Minimum Size of emitting particles.
  74347. */
  74348. minSize: number;
  74349. /**
  74350. * Maximum Size of emitting particles.
  74351. */
  74352. maxSize: number;
  74353. /**
  74354. * Minimum scale of emitting particles on X axis.
  74355. */
  74356. minScaleX: number;
  74357. /**
  74358. * Maximum scale of emitting particles on X axis.
  74359. */
  74360. maxScaleX: number;
  74361. /**
  74362. * Minimum scale of emitting particles on Y axis.
  74363. */
  74364. minScaleY: number;
  74365. /**
  74366. * Maximum scale of emitting particles on Y axis.
  74367. */
  74368. maxScaleY: number;
  74369. /**
  74370. * Gets or sets the minimal initial rotation in radians.
  74371. */
  74372. minInitialRotation: number;
  74373. /**
  74374. * Gets or sets the maximal initial rotation in radians.
  74375. */
  74376. maxInitialRotation: number;
  74377. /**
  74378. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74379. */
  74380. minAngularSpeed: number;
  74381. /**
  74382. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74383. */
  74384. maxAngularSpeed: number;
  74385. /**
  74386. * The texture used to render each particle. (this can be a spritesheet)
  74387. */
  74388. particleTexture: Nullable<Texture>;
  74389. /**
  74390. * The layer mask we are rendering the particles through.
  74391. */
  74392. layerMask: number;
  74393. /**
  74394. * This can help using your own shader to render the particle system.
  74395. * The according effect will be created
  74396. */
  74397. customShader: any;
  74398. /**
  74399. * By default particle system starts as soon as they are created. This prevents the
  74400. * automatic start to happen and let you decide when to start emitting particles.
  74401. */
  74402. preventAutoStart: boolean;
  74403. private _noiseTexture;
  74404. /**
  74405. * Gets or sets a texture used to add random noise to particle positions
  74406. */
  74407. noiseTexture: Nullable<ProceduralTexture>;
  74408. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74409. noiseStrength: Vector3;
  74410. /**
  74411. * Callback triggered when the particle animation is ending.
  74412. */
  74413. onAnimationEnd: Nullable<() => void>;
  74414. /**
  74415. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74416. */
  74417. blendMode: number;
  74418. /**
  74419. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74420. * to override the particles.
  74421. */
  74422. forceDepthWrite: boolean;
  74423. /** 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 */
  74424. preWarmCycles: number;
  74425. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74426. preWarmStepOffset: number;
  74427. /**
  74428. * 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)
  74429. */
  74430. spriteCellChangeSpeed: number;
  74431. /**
  74432. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74433. */
  74434. startSpriteCellID: number;
  74435. /**
  74436. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74437. */
  74438. endSpriteCellID: number;
  74439. /**
  74440. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74441. */
  74442. spriteCellWidth: number;
  74443. /**
  74444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74445. */
  74446. spriteCellHeight: number;
  74447. /**
  74448. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74449. */
  74450. spriteRandomStartCell: boolean;
  74451. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74452. translationPivot: Vector2;
  74453. /** @hidden */
  74454. protected _isAnimationSheetEnabled: boolean;
  74455. /**
  74456. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74457. */
  74458. beginAnimationOnStart: boolean;
  74459. /**
  74460. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74461. */
  74462. beginAnimationFrom: number;
  74463. /**
  74464. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74465. */
  74466. beginAnimationTo: number;
  74467. /**
  74468. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74469. */
  74470. beginAnimationLoop: boolean;
  74471. /**
  74472. * Gets or sets a world offset applied to all particles
  74473. */
  74474. worldOffset: Vector3;
  74475. /**
  74476. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74477. */
  74478. isAnimationSheetEnabled: boolean;
  74479. /**
  74480. * Get hosting scene
  74481. * @returns the scene
  74482. */
  74483. getScene(): Scene;
  74484. /**
  74485. * You can use gravity if you want to give an orientation to your particles.
  74486. */
  74487. gravity: Vector3;
  74488. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74489. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74490. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74491. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74492. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74493. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74494. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74495. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74496. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74497. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74498. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74499. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74500. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74501. /**
  74502. * Defines the delay in milliseconds before starting the system (0 by default)
  74503. */
  74504. startDelay: number;
  74505. /**
  74506. * Gets the current list of drag gradients.
  74507. * You must use addDragGradient and removeDragGradient to udpate this list
  74508. * @returns the list of drag gradients
  74509. */
  74510. getDragGradients(): Nullable<Array<FactorGradient>>;
  74511. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74512. limitVelocityDamping: number;
  74513. /**
  74514. * Gets the current list of limit velocity gradients.
  74515. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74516. * @returns the list of limit velocity gradients
  74517. */
  74518. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74519. /**
  74520. * Gets the current list of color gradients.
  74521. * You must use addColorGradient and removeColorGradient to udpate this list
  74522. * @returns the list of color gradients
  74523. */
  74524. getColorGradients(): Nullable<Array<ColorGradient>>;
  74525. /**
  74526. * Gets the current list of size gradients.
  74527. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74528. * @returns the list of size gradients
  74529. */
  74530. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74531. /**
  74532. * Gets the current list of color remap gradients.
  74533. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74534. * @returns the list of color remap gradients
  74535. */
  74536. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74537. /**
  74538. * Gets the current list of alpha remap gradients.
  74539. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74540. * @returns the list of alpha remap gradients
  74541. */
  74542. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74543. /**
  74544. * Gets the current list of life time gradients.
  74545. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74546. * @returns the list of life time gradients
  74547. */
  74548. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74549. /**
  74550. * Gets the current list of angular speed gradients.
  74551. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74552. * @returns the list of angular speed gradients
  74553. */
  74554. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74555. /**
  74556. * Gets the current list of velocity gradients.
  74557. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74558. * @returns the list of velocity gradients
  74559. */
  74560. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74561. /**
  74562. * Gets the current list of start size gradients.
  74563. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74564. * @returns the list of start size gradients
  74565. */
  74566. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74567. /**
  74568. * Gets the current list of emit rate gradients.
  74569. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74570. * @returns the list of emit rate gradients
  74571. */
  74572. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74573. /**
  74574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74576. */
  74577. direction1: Vector3;
  74578. /**
  74579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74581. */
  74582. direction2: Vector3;
  74583. /**
  74584. * 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.
  74585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74586. */
  74587. minEmitBox: Vector3;
  74588. /**
  74589. * 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.
  74590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74591. */
  74592. maxEmitBox: Vector3;
  74593. /**
  74594. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74595. */
  74596. color1: Color4;
  74597. /**
  74598. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74599. */
  74600. color2: Color4;
  74601. /**
  74602. * Color the particle will have at the end of its lifetime
  74603. */
  74604. colorDead: Color4;
  74605. /**
  74606. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74607. */
  74608. textureMask: Color4;
  74609. /**
  74610. * The particle emitter type defines the emitter used by the particle system.
  74611. * It can be for example box, sphere, or cone...
  74612. */
  74613. particleEmitterType: IParticleEmitterType;
  74614. /** @hidden */
  74615. _isSubEmitter: boolean;
  74616. /**
  74617. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74618. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74619. */
  74620. billboardMode: number;
  74621. protected _isBillboardBased: boolean;
  74622. /**
  74623. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74624. */
  74625. isBillboardBased: boolean;
  74626. /**
  74627. * The scene the particle system belongs to.
  74628. */
  74629. protected _scene: Scene;
  74630. /**
  74631. * Local cache of defines for image processing.
  74632. */
  74633. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74634. /**
  74635. * Default configuration related to image processing available in the standard Material.
  74636. */
  74637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74638. /**
  74639. * Gets the image processing configuration used either in this material.
  74640. */
  74641. /**
  74642. * Sets the Default image processing configuration used either in the this material.
  74643. *
  74644. * If sets to null, the scene one is in use.
  74645. */
  74646. imageProcessingConfiguration: ImageProcessingConfiguration;
  74647. /**
  74648. * Attaches a new image processing configuration to the Standard Material.
  74649. * @param configuration
  74650. */
  74651. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74652. /** @hidden */
  74653. protected _reset(): void;
  74654. /** @hidden */
  74655. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74656. /**
  74657. * Instantiates a particle system.
  74658. * 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.
  74659. * @param name The name of the particle system
  74660. */
  74661. constructor(name: string);
  74662. /**
  74663. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74666. * @returns the emitter
  74667. */
  74668. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74669. /**
  74670. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74671. * @param radius The radius of the hemisphere to emit from
  74672. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74673. * @returns the emitter
  74674. */
  74675. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74676. /**
  74677. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74678. * @param radius The radius of the sphere to emit from
  74679. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74680. * @returns the emitter
  74681. */
  74682. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74683. /**
  74684. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74685. * @param radius The radius of the sphere to emit from
  74686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74688. * @returns the emitter
  74689. */
  74690. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74691. /**
  74692. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74693. * @param radius The radius of the emission cylinder
  74694. * @param height The height of the emission cylinder
  74695. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74696. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74697. * @returns the emitter
  74698. */
  74699. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74700. /**
  74701. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74702. * @param radius The radius of the cylinder to emit from
  74703. * @param height The height of the emission cylinder
  74704. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74705. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74706. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74707. * @returns the emitter
  74708. */
  74709. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74710. /**
  74711. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74712. * @param radius The radius of the cone to emit from
  74713. * @param angle The base angle of the cone
  74714. * @returns the emitter
  74715. */
  74716. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74717. /**
  74718. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74721. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74722. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74723. * @returns the emitter
  74724. */
  74725. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * Type of sub emitter
  74731. */
  74732. export enum SubEmitterType {
  74733. /**
  74734. * Attached to the particle over it's lifetime
  74735. */
  74736. ATTACHED = 0,
  74737. /**
  74738. * Created when the particle dies
  74739. */
  74740. END = 1
  74741. }
  74742. /**
  74743. * Sub emitter class used to emit particles from an existing particle
  74744. */
  74745. export class SubEmitter {
  74746. /**
  74747. * the particle system to be used by the sub emitter
  74748. */
  74749. particleSystem: ParticleSystem;
  74750. /**
  74751. * Type of the submitter (Default: END)
  74752. */
  74753. type: SubEmitterType;
  74754. /**
  74755. * 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)
  74756. * Note: This only is supported when using an emitter of type Mesh
  74757. */
  74758. inheritDirection: boolean;
  74759. /**
  74760. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74761. */
  74762. inheritedVelocityAmount: number;
  74763. /**
  74764. * Creates a sub emitter
  74765. * @param particleSystem the particle system to be used by the sub emitter
  74766. */
  74767. constructor(
  74768. /**
  74769. * the particle system to be used by the sub emitter
  74770. */
  74771. particleSystem: ParticleSystem);
  74772. /**
  74773. * Clones the sub emitter
  74774. * @returns the cloned sub emitter
  74775. */
  74776. clone(): SubEmitter;
  74777. /**
  74778. * Serialize current object to a JSON object
  74779. * @returns the serialized object
  74780. */
  74781. serialize(): any;
  74782. /** @hidden */
  74783. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74784. /**
  74785. * Creates a new SubEmitter from a serialized JSON version
  74786. * @param serializationObject defines the JSON object to read from
  74787. * @param scene defines the hosting scene
  74788. * @param rootUrl defines the rootUrl for data loading
  74789. * @returns a new SubEmitter
  74790. */
  74791. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74792. /** Release associated resources */
  74793. dispose(): void;
  74794. }
  74795. }
  74796. declare module BABYLON {
  74797. /** @hidden */
  74798. export var clipPlaneFragmentDeclaration: {
  74799. name: string;
  74800. shader: string;
  74801. };
  74802. }
  74803. declare module BABYLON {
  74804. /** @hidden */
  74805. export var imageProcessingDeclaration: {
  74806. name: string;
  74807. shader: string;
  74808. };
  74809. }
  74810. declare module BABYLON {
  74811. /** @hidden */
  74812. export var imageProcessingFunctions: {
  74813. name: string;
  74814. shader: string;
  74815. };
  74816. }
  74817. declare module BABYLON {
  74818. /** @hidden */
  74819. export var clipPlaneFragment: {
  74820. name: string;
  74821. shader: string;
  74822. };
  74823. }
  74824. declare module BABYLON {
  74825. /** @hidden */
  74826. export var particlesPixelShader: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module BABYLON {
  74832. /** @hidden */
  74833. export var clipPlaneVertexDeclaration: {
  74834. name: string;
  74835. shader: string;
  74836. };
  74837. }
  74838. declare module BABYLON {
  74839. /** @hidden */
  74840. export var clipPlaneVertex: {
  74841. name: string;
  74842. shader: string;
  74843. };
  74844. }
  74845. declare module BABYLON {
  74846. /** @hidden */
  74847. export var particlesVertexShader: {
  74848. name: string;
  74849. shader: string;
  74850. };
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * This represents a particle system in Babylon.
  74855. * 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.
  74856. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74857. * @example https://doc.babylonjs.com/babylon101/particles
  74858. */
  74859. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74860. /**
  74861. * Billboard mode will only apply to Y axis
  74862. */
  74863. static readonly BILLBOARDMODE_Y: number;
  74864. /**
  74865. * Billboard mode will apply to all axes
  74866. */
  74867. static readonly BILLBOARDMODE_ALL: number;
  74868. /**
  74869. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74870. */
  74871. static readonly BILLBOARDMODE_STRETCHED: number;
  74872. /**
  74873. * This function can be defined to provide custom update for active particles.
  74874. * This function will be called instead of regular update (age, position, color, etc.).
  74875. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74876. */
  74877. updateFunction: (particles: Particle[]) => void;
  74878. private _emitterWorldMatrix;
  74879. /**
  74880. * This function can be defined to specify initial direction for every new particle.
  74881. * It by default use the emitterType defined function
  74882. */
  74883. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74884. /**
  74885. * This function can be defined to specify initial position for every new particle.
  74886. * It by default use the emitterType defined function
  74887. */
  74888. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74889. /**
  74890. * @hidden
  74891. */
  74892. _inheritedVelocityOffset: Vector3;
  74893. /**
  74894. * An event triggered when the system is disposed
  74895. */
  74896. onDisposeObservable: Observable<ParticleSystem>;
  74897. private _onDisposeObserver;
  74898. /**
  74899. * Sets a callback that will be triggered when the system is disposed
  74900. */
  74901. onDispose: () => void;
  74902. private _particles;
  74903. private _epsilon;
  74904. private _capacity;
  74905. private _stockParticles;
  74906. private _newPartsExcess;
  74907. private _vertexData;
  74908. private _vertexBuffer;
  74909. private _vertexBuffers;
  74910. private _spriteBuffer;
  74911. private _indexBuffer;
  74912. private _effect;
  74913. private _customEffect;
  74914. private _cachedDefines;
  74915. private _scaledColorStep;
  74916. private _colorDiff;
  74917. private _scaledDirection;
  74918. private _scaledGravity;
  74919. private _currentRenderId;
  74920. private _alive;
  74921. private _useInstancing;
  74922. private _started;
  74923. private _stopped;
  74924. private _actualFrame;
  74925. private _scaledUpdateSpeed;
  74926. private _vertexBufferSize;
  74927. /** @hidden */
  74928. _currentEmitRateGradient: Nullable<FactorGradient>;
  74929. /** @hidden */
  74930. _currentEmitRate1: number;
  74931. /** @hidden */
  74932. _currentEmitRate2: number;
  74933. /** @hidden */
  74934. _currentStartSizeGradient: Nullable<FactorGradient>;
  74935. /** @hidden */
  74936. _currentStartSize1: number;
  74937. /** @hidden */
  74938. _currentStartSize2: number;
  74939. private readonly _rawTextureWidth;
  74940. private _rampGradientsTexture;
  74941. private _useRampGradients;
  74942. /** Gets or sets a boolean indicating that ramp gradients must be used
  74943. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74944. */
  74945. useRampGradients: boolean;
  74946. /**
  74947. * 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.
  74948. * 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: [])
  74949. */
  74950. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74951. private _subEmitters;
  74952. /**
  74953. * @hidden
  74954. * If the particle systems emitter should be disposed when the particle system is disposed
  74955. */
  74956. _disposeEmitterOnDispose: boolean;
  74957. /**
  74958. * The current active Sub-systems, this property is used by the root particle system only.
  74959. */
  74960. activeSubSystems: Array<ParticleSystem>;
  74961. private _rootParticleSystem;
  74962. /**
  74963. * Gets the current list of active particles
  74964. */
  74965. readonly particles: Particle[];
  74966. /**
  74967. * Returns the string "ParticleSystem"
  74968. * @returns a string containing the class name
  74969. */
  74970. getClassName(): string;
  74971. /**
  74972. * Instantiates a particle system.
  74973. * 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.
  74974. * @param name The name of the particle system
  74975. * @param capacity The max number of particles alive at the same time
  74976. * @param scene The scene the particle system belongs to
  74977. * @param customEffect a custom effect used to change the way particles are rendered by default
  74978. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74979. * @param epsilon Offset used to render the particles
  74980. */
  74981. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74982. private _addFactorGradient;
  74983. private _removeFactorGradient;
  74984. /**
  74985. * Adds a new life time gradient
  74986. * @param gradient defines the gradient to use (between 0 and 1)
  74987. * @param factor defines the life time factor to affect to the specified gradient
  74988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74989. * @returns the current particle system
  74990. */
  74991. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74992. /**
  74993. * Remove a specific life time gradient
  74994. * @param gradient defines the gradient to remove
  74995. * @returns the current particle system
  74996. */
  74997. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74998. /**
  74999. * Adds a new size gradient
  75000. * @param gradient defines the gradient to use (between 0 and 1)
  75001. * @param factor defines the size factor to affect to the specified gradient
  75002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75003. * @returns the current particle system
  75004. */
  75005. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75006. /**
  75007. * Remove a specific size gradient
  75008. * @param gradient defines the gradient to remove
  75009. * @returns the current particle system
  75010. */
  75011. removeSizeGradient(gradient: number): IParticleSystem;
  75012. /**
  75013. * Adds a new color remap gradient
  75014. * @param gradient defines the gradient to use (between 0 and 1)
  75015. * @param min defines the color remap minimal range
  75016. * @param max defines the color remap maximal range
  75017. * @returns the current particle system
  75018. */
  75019. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75020. /**
  75021. * Remove a specific color remap gradient
  75022. * @param gradient defines the gradient to remove
  75023. * @returns the current particle system
  75024. */
  75025. removeColorRemapGradient(gradient: number): IParticleSystem;
  75026. /**
  75027. * Adds a new alpha remap gradient
  75028. * @param gradient defines the gradient to use (between 0 and 1)
  75029. * @param min defines the alpha remap minimal range
  75030. * @param max defines the alpha remap maximal range
  75031. * @returns the current particle system
  75032. */
  75033. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75034. /**
  75035. * Remove a specific alpha remap gradient
  75036. * @param gradient defines the gradient to remove
  75037. * @returns the current particle system
  75038. */
  75039. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75040. /**
  75041. * Adds a new angular speed gradient
  75042. * @param gradient defines the gradient to use (between 0 and 1)
  75043. * @param factor defines the angular speed to affect to the specified gradient
  75044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75045. * @returns the current particle system
  75046. */
  75047. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75048. /**
  75049. * Remove a specific angular speed gradient
  75050. * @param gradient defines the gradient to remove
  75051. * @returns the current particle system
  75052. */
  75053. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75054. /**
  75055. * Adds a new velocity gradient
  75056. * @param gradient defines the gradient to use (between 0 and 1)
  75057. * @param factor defines the velocity to affect to the specified gradient
  75058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75059. * @returns the current particle system
  75060. */
  75061. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75062. /**
  75063. * Remove a specific velocity gradient
  75064. * @param gradient defines the gradient to remove
  75065. * @returns the current particle system
  75066. */
  75067. removeVelocityGradient(gradient: number): IParticleSystem;
  75068. /**
  75069. * Adds a new limit velocity gradient
  75070. * @param gradient defines the gradient to use (between 0 and 1)
  75071. * @param factor defines the limit velocity value to affect to the specified gradient
  75072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75073. * @returns the current particle system
  75074. */
  75075. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75076. /**
  75077. * Remove a specific limit velocity gradient
  75078. * @param gradient defines the gradient to remove
  75079. * @returns the current particle system
  75080. */
  75081. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75082. /**
  75083. * Adds a new drag gradient
  75084. * @param gradient defines the gradient to use (between 0 and 1)
  75085. * @param factor defines the drag value to affect to the specified gradient
  75086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75087. * @returns the current particle system
  75088. */
  75089. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75090. /**
  75091. * Remove a specific drag gradient
  75092. * @param gradient defines the gradient to remove
  75093. * @returns the current particle system
  75094. */
  75095. removeDragGradient(gradient: number): IParticleSystem;
  75096. /**
  75097. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75098. * @param gradient defines the gradient to use (between 0 and 1)
  75099. * @param factor defines the emit rate value to affect to the specified gradient
  75100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75101. * @returns the current particle system
  75102. */
  75103. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75104. /**
  75105. * Remove a specific emit rate gradient
  75106. * @param gradient defines the gradient to remove
  75107. * @returns the current particle system
  75108. */
  75109. removeEmitRateGradient(gradient: number): IParticleSystem;
  75110. /**
  75111. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75112. * @param gradient defines the gradient to use (between 0 and 1)
  75113. * @param factor defines the start size value to affect to the specified gradient
  75114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75115. * @returns the current particle system
  75116. */
  75117. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75118. /**
  75119. * Remove a specific start size gradient
  75120. * @param gradient defines the gradient to remove
  75121. * @returns the current particle system
  75122. */
  75123. removeStartSizeGradient(gradient: number): IParticleSystem;
  75124. private _createRampGradientTexture;
  75125. /**
  75126. * Gets the current list of ramp gradients.
  75127. * You must use addRampGradient and removeRampGradient to udpate this list
  75128. * @returns the list of ramp gradients
  75129. */
  75130. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75131. /**
  75132. * Adds a new ramp gradient used to remap particle colors
  75133. * @param gradient defines the gradient to use (between 0 and 1)
  75134. * @param color defines the color to affect to the specified gradient
  75135. * @returns the current particle system
  75136. */
  75137. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75138. /**
  75139. * Remove a specific ramp gradient
  75140. * @param gradient defines the gradient to remove
  75141. * @returns the current particle system
  75142. */
  75143. removeRampGradient(gradient: number): ParticleSystem;
  75144. /**
  75145. * Adds a new color gradient
  75146. * @param gradient defines the gradient to use (between 0 and 1)
  75147. * @param color1 defines the color to affect to the specified gradient
  75148. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75149. * @returns this particle system
  75150. */
  75151. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75152. /**
  75153. * Remove a specific color gradient
  75154. * @param gradient defines the gradient to remove
  75155. * @returns this particle system
  75156. */
  75157. removeColorGradient(gradient: number): IParticleSystem;
  75158. private _fetchR;
  75159. protected _reset(): void;
  75160. private _resetEffect;
  75161. private _createVertexBuffers;
  75162. private _createIndexBuffer;
  75163. /**
  75164. * Gets the maximum number of particles active at the same time.
  75165. * @returns The max number of active particles.
  75166. */
  75167. getCapacity(): number;
  75168. /**
  75169. * Gets whether there are still active particles in the system.
  75170. * @returns True if it is alive, otherwise false.
  75171. */
  75172. isAlive(): boolean;
  75173. /**
  75174. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75175. * @returns True if it has been started, otherwise false.
  75176. */
  75177. isStarted(): boolean;
  75178. private _prepareSubEmitterInternalArray;
  75179. /**
  75180. * Starts the particle system and begins to emit
  75181. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75182. */
  75183. start(delay?: number): void;
  75184. /**
  75185. * Stops the particle system.
  75186. * @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.
  75187. */
  75188. stop(stopSubEmitters?: boolean): void;
  75189. /**
  75190. * Remove all active particles
  75191. */
  75192. reset(): void;
  75193. /**
  75194. * @hidden (for internal use only)
  75195. */
  75196. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75197. /**
  75198. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75199. * Its lifetime will start back at 0.
  75200. */
  75201. recycleParticle: (particle: Particle) => void;
  75202. private _stopSubEmitters;
  75203. private _createParticle;
  75204. private _removeFromRoot;
  75205. private _emitFromParticle;
  75206. private _update;
  75207. /** @hidden */
  75208. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75209. /** @hidden */
  75210. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75211. /** @hidden */
  75212. private _getEffect;
  75213. /**
  75214. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75215. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75216. */
  75217. animate(preWarmOnly?: boolean): void;
  75218. private _appendParticleVertices;
  75219. /**
  75220. * Rebuilds the particle system.
  75221. */
  75222. rebuild(): void;
  75223. /**
  75224. * Is this system ready to be used/rendered
  75225. * @return true if the system is ready
  75226. */
  75227. isReady(): boolean;
  75228. private _render;
  75229. /**
  75230. * Renders the particle system in its current state.
  75231. * @returns the current number of particles
  75232. */
  75233. render(): number;
  75234. /**
  75235. * Disposes the particle system and free the associated resources
  75236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75237. */
  75238. dispose(disposeTexture?: boolean): void;
  75239. /**
  75240. * Clones the particle system.
  75241. * @param name The name of the cloned object
  75242. * @param newEmitter The new emitter to use
  75243. * @returns the cloned particle system
  75244. */
  75245. clone(name: string, newEmitter: any): ParticleSystem;
  75246. /**
  75247. * Serializes the particle system to a JSON object.
  75248. * @returns the JSON object
  75249. */
  75250. serialize(): any;
  75251. /** @hidden */
  75252. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75253. /** @hidden */
  75254. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75255. /**
  75256. * Parses a JSON object to create a particle system.
  75257. * @param parsedParticleSystem The JSON object to parse
  75258. * @param scene The scene to create the particle system in
  75259. * @param rootUrl The root url to use to load external dependencies like texture
  75260. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75261. * @returns the Parsed particle system
  75262. */
  75263. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75264. }
  75265. }
  75266. declare module BABYLON {
  75267. /**
  75268. * A particle represents one of the element emitted by a particle system.
  75269. * This is mainly define by its coordinates, direction, velocity and age.
  75270. */
  75271. export class Particle {
  75272. /**
  75273. * The particle system the particle belongs to.
  75274. */
  75275. particleSystem: ParticleSystem;
  75276. private static _Count;
  75277. /**
  75278. * Unique ID of the particle
  75279. */
  75280. id: number;
  75281. /**
  75282. * The world position of the particle in the scene.
  75283. */
  75284. position: Vector3;
  75285. /**
  75286. * The world direction of the particle in the scene.
  75287. */
  75288. direction: Vector3;
  75289. /**
  75290. * The color of the particle.
  75291. */
  75292. color: Color4;
  75293. /**
  75294. * The color change of the particle per step.
  75295. */
  75296. colorStep: Color4;
  75297. /**
  75298. * Defines how long will the life of the particle be.
  75299. */
  75300. lifeTime: number;
  75301. /**
  75302. * The current age of the particle.
  75303. */
  75304. age: number;
  75305. /**
  75306. * The current size of the particle.
  75307. */
  75308. size: number;
  75309. /**
  75310. * The current scale of the particle.
  75311. */
  75312. scale: Vector2;
  75313. /**
  75314. * The current angle of the particle.
  75315. */
  75316. angle: number;
  75317. /**
  75318. * Defines how fast is the angle changing.
  75319. */
  75320. angularSpeed: number;
  75321. /**
  75322. * Defines the cell index used by the particle to be rendered from a sprite.
  75323. */
  75324. cellIndex: number;
  75325. /**
  75326. * The information required to support color remapping
  75327. */
  75328. remapData: Vector4;
  75329. /** @hidden */
  75330. _randomCellOffset?: number;
  75331. /** @hidden */
  75332. _initialDirection: Nullable<Vector3>;
  75333. /** @hidden */
  75334. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75335. /** @hidden */
  75336. _initialStartSpriteCellID: number;
  75337. /** @hidden */
  75338. _initialEndSpriteCellID: number;
  75339. /** @hidden */
  75340. _currentColorGradient: Nullable<ColorGradient>;
  75341. /** @hidden */
  75342. _currentColor1: Color4;
  75343. /** @hidden */
  75344. _currentColor2: Color4;
  75345. /** @hidden */
  75346. _currentSizeGradient: Nullable<FactorGradient>;
  75347. /** @hidden */
  75348. _currentSize1: number;
  75349. /** @hidden */
  75350. _currentSize2: number;
  75351. /** @hidden */
  75352. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75353. /** @hidden */
  75354. _currentAngularSpeed1: number;
  75355. /** @hidden */
  75356. _currentAngularSpeed2: number;
  75357. /** @hidden */
  75358. _currentVelocityGradient: Nullable<FactorGradient>;
  75359. /** @hidden */
  75360. _currentVelocity1: number;
  75361. /** @hidden */
  75362. _currentVelocity2: number;
  75363. /** @hidden */
  75364. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75365. /** @hidden */
  75366. _currentLimitVelocity1: number;
  75367. /** @hidden */
  75368. _currentLimitVelocity2: number;
  75369. /** @hidden */
  75370. _currentDragGradient: Nullable<FactorGradient>;
  75371. /** @hidden */
  75372. _currentDrag1: number;
  75373. /** @hidden */
  75374. _currentDrag2: number;
  75375. /** @hidden */
  75376. _randomNoiseCoordinates1: Vector3;
  75377. /** @hidden */
  75378. _randomNoiseCoordinates2: Vector3;
  75379. /**
  75380. * Creates a new instance Particle
  75381. * @param particleSystem the particle system the particle belongs to
  75382. */
  75383. constructor(
  75384. /**
  75385. * The particle system the particle belongs to.
  75386. */
  75387. particleSystem: ParticleSystem);
  75388. private updateCellInfoFromSystem;
  75389. /**
  75390. * Defines how the sprite cell index is updated for the particle
  75391. */
  75392. updateCellIndex(): void;
  75393. /** @hidden */
  75394. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75395. /** @hidden */
  75396. _inheritParticleInfoToSubEmitters(): void;
  75397. /** @hidden */
  75398. _reset(): void;
  75399. /**
  75400. * Copy the properties of particle to another one.
  75401. * @param other the particle to copy the information to.
  75402. */
  75403. copyTo(other: Particle): void;
  75404. }
  75405. }
  75406. declare module BABYLON {
  75407. /**
  75408. * Particle emitter represents a volume emitting particles.
  75409. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75410. */
  75411. export interface IParticleEmitterType {
  75412. /**
  75413. * Called by the particle System when the direction is computed for the created particle.
  75414. * @param worldMatrix is the world matrix of the particle system
  75415. * @param directionToUpdate is the direction vector to update with the result
  75416. * @param particle is the particle we are computed the direction for
  75417. */
  75418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75419. /**
  75420. * Called by the particle System when the position is computed for the created particle.
  75421. * @param worldMatrix is the world matrix of the particle system
  75422. * @param positionToUpdate is the position vector to update with the result
  75423. * @param particle is the particle we are computed the position for
  75424. */
  75425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75426. /**
  75427. * Clones the current emitter and returns a copy of it
  75428. * @returns the new emitter
  75429. */
  75430. clone(): IParticleEmitterType;
  75431. /**
  75432. * Called by the GPUParticleSystem to setup the update shader
  75433. * @param effect defines the update shader
  75434. */
  75435. applyToShader(effect: Effect): void;
  75436. /**
  75437. * Returns a string to use to update the GPU particles update shader
  75438. * @returns the effect defines string
  75439. */
  75440. getEffectDefines(): string;
  75441. /**
  75442. * Returns a string representing the class name
  75443. * @returns a string containing the class name
  75444. */
  75445. getClassName(): string;
  75446. /**
  75447. * Serializes the particle system to a JSON object.
  75448. * @returns the JSON object
  75449. */
  75450. serialize(): any;
  75451. /**
  75452. * Parse properties from a JSON object
  75453. * @param serializationObject defines the JSON object
  75454. */
  75455. parse(serializationObject: any): void;
  75456. }
  75457. }
  75458. declare module BABYLON {
  75459. /**
  75460. * Particle emitter emitting particles from the inside of a box.
  75461. * It emits the particles randomly between 2 given directions.
  75462. */
  75463. export class BoxParticleEmitter implements IParticleEmitterType {
  75464. /**
  75465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75466. */
  75467. direction1: Vector3;
  75468. /**
  75469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75470. */
  75471. direction2: Vector3;
  75472. /**
  75473. * 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.
  75474. */
  75475. minEmitBox: Vector3;
  75476. /**
  75477. * 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.
  75478. */
  75479. maxEmitBox: Vector3;
  75480. /**
  75481. * Creates a new instance BoxParticleEmitter
  75482. */
  75483. constructor();
  75484. /**
  75485. * Called by the particle System when the direction is computed for the created particle.
  75486. * @param worldMatrix is the world matrix of the particle system
  75487. * @param directionToUpdate is the direction vector to update with the result
  75488. * @param particle is the particle we are computed the direction for
  75489. */
  75490. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75491. /**
  75492. * Called by the particle System when the position is computed for the created particle.
  75493. * @param worldMatrix is the world matrix of the particle system
  75494. * @param positionToUpdate is the position vector to update with the result
  75495. * @param particle is the particle we are computed the position for
  75496. */
  75497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75498. /**
  75499. * Clones the current emitter and returns a copy of it
  75500. * @returns the new emitter
  75501. */
  75502. clone(): BoxParticleEmitter;
  75503. /**
  75504. * Called by the GPUParticleSystem to setup the update shader
  75505. * @param effect defines the update shader
  75506. */
  75507. applyToShader(effect: Effect): void;
  75508. /**
  75509. * Returns a string to use to update the GPU particles update shader
  75510. * @returns a string containng the defines string
  75511. */
  75512. getEffectDefines(): string;
  75513. /**
  75514. * Returns the string "BoxParticleEmitter"
  75515. * @returns a string containing the class name
  75516. */
  75517. getClassName(): string;
  75518. /**
  75519. * Serializes the particle system to a JSON object.
  75520. * @returns the JSON object
  75521. */
  75522. serialize(): any;
  75523. /**
  75524. * Parse properties from a JSON object
  75525. * @param serializationObject defines the JSON object
  75526. */
  75527. parse(serializationObject: any): void;
  75528. }
  75529. }
  75530. declare module BABYLON {
  75531. /**
  75532. * Particle emitter emitting particles from the inside of a cone.
  75533. * It emits the particles alongside the cone volume from the base to the particle.
  75534. * The emission direction might be randomized.
  75535. */
  75536. export class ConeParticleEmitter implements IParticleEmitterType {
  75537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75538. directionRandomizer: number;
  75539. private _radius;
  75540. private _angle;
  75541. private _height;
  75542. /**
  75543. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75544. */
  75545. radiusRange: number;
  75546. /**
  75547. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75548. */
  75549. heightRange: number;
  75550. /**
  75551. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75552. */
  75553. emitFromSpawnPointOnly: boolean;
  75554. /**
  75555. * Gets or sets the radius of the emission cone
  75556. */
  75557. radius: number;
  75558. /**
  75559. * Gets or sets the angle of the emission cone
  75560. */
  75561. angle: number;
  75562. private _buildHeight;
  75563. /**
  75564. * Creates a new instance ConeParticleEmitter
  75565. * @param radius the radius of the emission cone (1 by default)
  75566. * @param angle the cone base angle (PI by default)
  75567. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75568. */
  75569. constructor(radius?: number, angle?: number,
  75570. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75571. directionRandomizer?: number);
  75572. /**
  75573. * Called by the particle System when the direction is computed for the created particle.
  75574. * @param worldMatrix is the world matrix of the particle system
  75575. * @param directionToUpdate is the direction vector to update with the result
  75576. * @param particle is the particle we are computed the direction for
  75577. */
  75578. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75579. /**
  75580. * Called by the particle System when the position is computed for the created particle.
  75581. * @param worldMatrix is the world matrix of the particle system
  75582. * @param positionToUpdate is the position vector to update with the result
  75583. * @param particle is the particle we are computed the position for
  75584. */
  75585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75586. /**
  75587. * Clones the current emitter and returns a copy of it
  75588. * @returns the new emitter
  75589. */
  75590. clone(): ConeParticleEmitter;
  75591. /**
  75592. * Called by the GPUParticleSystem to setup the update shader
  75593. * @param effect defines the update shader
  75594. */
  75595. applyToShader(effect: Effect): void;
  75596. /**
  75597. * Returns a string to use to update the GPU particles update shader
  75598. * @returns a string containng the defines string
  75599. */
  75600. getEffectDefines(): string;
  75601. /**
  75602. * Returns the string "ConeParticleEmitter"
  75603. * @returns a string containing the class name
  75604. */
  75605. getClassName(): string;
  75606. /**
  75607. * Serializes the particle system to a JSON object.
  75608. * @returns the JSON object
  75609. */
  75610. serialize(): any;
  75611. /**
  75612. * Parse properties from a JSON object
  75613. * @param serializationObject defines the JSON object
  75614. */
  75615. parse(serializationObject: any): void;
  75616. }
  75617. }
  75618. declare module BABYLON {
  75619. /**
  75620. * Particle emitter emitting particles from the inside of a cylinder.
  75621. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75622. */
  75623. export class CylinderParticleEmitter implements IParticleEmitterType {
  75624. /**
  75625. * The radius of the emission cylinder.
  75626. */
  75627. radius: number;
  75628. /**
  75629. * The height of the emission cylinder.
  75630. */
  75631. height: number;
  75632. /**
  75633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75634. */
  75635. radiusRange: number;
  75636. /**
  75637. * How much to randomize the particle direction [0-1].
  75638. */
  75639. directionRandomizer: number;
  75640. /**
  75641. * Creates a new instance CylinderParticleEmitter
  75642. * @param radius the radius of the emission cylinder (1 by default)
  75643. * @param height the height of the emission cylinder (1 by default)
  75644. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75645. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75646. */
  75647. constructor(
  75648. /**
  75649. * The radius of the emission cylinder.
  75650. */
  75651. radius?: number,
  75652. /**
  75653. * The height of the emission cylinder.
  75654. */
  75655. height?: number,
  75656. /**
  75657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75658. */
  75659. radiusRange?: number,
  75660. /**
  75661. * How much to randomize the particle direction [0-1].
  75662. */
  75663. directionRandomizer?: number);
  75664. /**
  75665. * Called by the particle System when the direction is computed for the created particle.
  75666. * @param worldMatrix is the world matrix of the particle system
  75667. * @param directionToUpdate is the direction vector to update with the result
  75668. * @param particle is the particle we are computed the direction for
  75669. */
  75670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75671. /**
  75672. * Called by the particle System when the position is computed for the created particle.
  75673. * @param worldMatrix is the world matrix of the particle system
  75674. * @param positionToUpdate is the position vector to update with the result
  75675. * @param particle is the particle we are computed the position for
  75676. */
  75677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75678. /**
  75679. * Clones the current emitter and returns a copy of it
  75680. * @returns the new emitter
  75681. */
  75682. clone(): CylinderParticleEmitter;
  75683. /**
  75684. * Called by the GPUParticleSystem to setup the update shader
  75685. * @param effect defines the update shader
  75686. */
  75687. applyToShader(effect: Effect): void;
  75688. /**
  75689. * Returns a string to use to update the GPU particles update shader
  75690. * @returns a string containng the defines string
  75691. */
  75692. getEffectDefines(): string;
  75693. /**
  75694. * Returns the string "CylinderParticleEmitter"
  75695. * @returns a string containing the class name
  75696. */
  75697. getClassName(): string;
  75698. /**
  75699. * Serializes the particle system to a JSON object.
  75700. * @returns the JSON object
  75701. */
  75702. serialize(): any;
  75703. /**
  75704. * Parse properties from a JSON object
  75705. * @param serializationObject defines the JSON object
  75706. */
  75707. parse(serializationObject: any): void;
  75708. }
  75709. /**
  75710. * Particle emitter emitting particles from the inside of a cylinder.
  75711. * It emits the particles randomly between two vectors.
  75712. */
  75713. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75714. /**
  75715. * The min limit of the emission direction.
  75716. */
  75717. direction1: Vector3;
  75718. /**
  75719. * The max limit of the emission direction.
  75720. */
  75721. direction2: Vector3;
  75722. /**
  75723. * Creates a new instance CylinderDirectedParticleEmitter
  75724. * @param radius the radius of the emission cylinder (1 by default)
  75725. * @param height the height of the emission cylinder (1 by default)
  75726. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75727. * @param direction1 the min limit of the emission direction (up vector by default)
  75728. * @param direction2 the max limit of the emission direction (up vector by default)
  75729. */
  75730. constructor(radius?: number, height?: number, radiusRange?: number,
  75731. /**
  75732. * The min limit of the emission direction.
  75733. */
  75734. direction1?: Vector3,
  75735. /**
  75736. * The max limit of the emission direction.
  75737. */
  75738. direction2?: Vector3);
  75739. /**
  75740. * Called by the particle System when the direction is computed for the created particle.
  75741. * @param worldMatrix is the world matrix of the particle system
  75742. * @param directionToUpdate is the direction vector to update with the result
  75743. * @param particle is the particle we are computed the direction for
  75744. */
  75745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75746. /**
  75747. * Clones the current emitter and returns a copy of it
  75748. * @returns the new emitter
  75749. */
  75750. clone(): CylinderDirectedParticleEmitter;
  75751. /**
  75752. * Called by the GPUParticleSystem to setup the update shader
  75753. * @param effect defines the update shader
  75754. */
  75755. applyToShader(effect: Effect): void;
  75756. /**
  75757. * Returns a string to use to update the GPU particles update shader
  75758. * @returns a string containng the defines string
  75759. */
  75760. getEffectDefines(): string;
  75761. /**
  75762. * Returns the string "CylinderDirectedParticleEmitter"
  75763. * @returns a string containing the class name
  75764. */
  75765. getClassName(): string;
  75766. /**
  75767. * Serializes the particle system to a JSON object.
  75768. * @returns the JSON object
  75769. */
  75770. serialize(): any;
  75771. /**
  75772. * Parse properties from a JSON object
  75773. * @param serializationObject defines the JSON object
  75774. */
  75775. parse(serializationObject: any): void;
  75776. }
  75777. }
  75778. declare module BABYLON {
  75779. /**
  75780. * Particle emitter emitting particles from the inside of a hemisphere.
  75781. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75782. */
  75783. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75784. /**
  75785. * The radius of the emission hemisphere.
  75786. */
  75787. radius: number;
  75788. /**
  75789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75790. */
  75791. radiusRange: number;
  75792. /**
  75793. * How much to randomize the particle direction [0-1].
  75794. */
  75795. directionRandomizer: number;
  75796. /**
  75797. * Creates a new instance HemisphericParticleEmitter
  75798. * @param radius the radius of the emission hemisphere (1 by default)
  75799. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75800. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75801. */
  75802. constructor(
  75803. /**
  75804. * The radius of the emission hemisphere.
  75805. */
  75806. radius?: number,
  75807. /**
  75808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75809. */
  75810. radiusRange?: number,
  75811. /**
  75812. * How much to randomize the particle direction [0-1].
  75813. */
  75814. directionRandomizer?: number);
  75815. /**
  75816. * Called by the particle System when the direction is computed for the created particle.
  75817. * @param worldMatrix is the world matrix of the particle system
  75818. * @param directionToUpdate is the direction vector to update with the result
  75819. * @param particle is the particle we are computed the direction for
  75820. */
  75821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75822. /**
  75823. * Called by the particle System when the position is computed for the created particle.
  75824. * @param worldMatrix is the world matrix of the particle system
  75825. * @param positionToUpdate is the position vector to update with the result
  75826. * @param particle is the particle we are computed the position for
  75827. */
  75828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75829. /**
  75830. * Clones the current emitter and returns a copy of it
  75831. * @returns the new emitter
  75832. */
  75833. clone(): HemisphericParticleEmitter;
  75834. /**
  75835. * Called by the GPUParticleSystem to setup the update shader
  75836. * @param effect defines the update shader
  75837. */
  75838. applyToShader(effect: Effect): void;
  75839. /**
  75840. * Returns a string to use to update the GPU particles update shader
  75841. * @returns a string containng the defines string
  75842. */
  75843. getEffectDefines(): string;
  75844. /**
  75845. * Returns the string "HemisphericParticleEmitter"
  75846. * @returns a string containing the class name
  75847. */
  75848. getClassName(): string;
  75849. /**
  75850. * Serializes the particle system to a JSON object.
  75851. * @returns the JSON object
  75852. */
  75853. serialize(): any;
  75854. /**
  75855. * Parse properties from a JSON object
  75856. * @param serializationObject defines the JSON object
  75857. */
  75858. parse(serializationObject: any): void;
  75859. }
  75860. }
  75861. declare module BABYLON {
  75862. /**
  75863. * Particle emitter emitting particles from a point.
  75864. * It emits the particles randomly between 2 given directions.
  75865. */
  75866. export class PointParticleEmitter implements IParticleEmitterType {
  75867. /**
  75868. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75869. */
  75870. direction1: Vector3;
  75871. /**
  75872. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75873. */
  75874. direction2: Vector3;
  75875. /**
  75876. * Creates a new instance PointParticleEmitter
  75877. */
  75878. constructor();
  75879. /**
  75880. * Called by the particle System when the direction is computed for the created particle.
  75881. * @param worldMatrix is the world matrix of the particle system
  75882. * @param directionToUpdate is the direction vector to update with the result
  75883. * @param particle is the particle we are computed the direction for
  75884. */
  75885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75886. /**
  75887. * Called by the particle System when the position is computed for the created particle.
  75888. * @param worldMatrix is the world matrix of the particle system
  75889. * @param positionToUpdate is the position vector to update with the result
  75890. * @param particle is the particle we are computed the position for
  75891. */
  75892. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75893. /**
  75894. * Clones the current emitter and returns a copy of it
  75895. * @returns the new emitter
  75896. */
  75897. clone(): PointParticleEmitter;
  75898. /**
  75899. * Called by the GPUParticleSystem to setup the update shader
  75900. * @param effect defines the update shader
  75901. */
  75902. applyToShader(effect: Effect): void;
  75903. /**
  75904. * Returns a string to use to update the GPU particles update shader
  75905. * @returns a string containng the defines string
  75906. */
  75907. getEffectDefines(): string;
  75908. /**
  75909. * Returns the string "PointParticleEmitter"
  75910. * @returns a string containing the class name
  75911. */
  75912. getClassName(): string;
  75913. /**
  75914. * Serializes the particle system to a JSON object.
  75915. * @returns the JSON object
  75916. */
  75917. serialize(): any;
  75918. /**
  75919. * Parse properties from a JSON object
  75920. * @param serializationObject defines the JSON object
  75921. */
  75922. parse(serializationObject: any): void;
  75923. }
  75924. }
  75925. declare module BABYLON {
  75926. /**
  75927. * Particle emitter emitting particles from the inside of a sphere.
  75928. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75929. */
  75930. export class SphereParticleEmitter implements IParticleEmitterType {
  75931. /**
  75932. * The radius of the emission sphere.
  75933. */
  75934. radius: number;
  75935. /**
  75936. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75937. */
  75938. radiusRange: number;
  75939. /**
  75940. * How much to randomize the particle direction [0-1].
  75941. */
  75942. directionRandomizer: number;
  75943. /**
  75944. * Creates a new instance SphereParticleEmitter
  75945. * @param radius the radius of the emission sphere (1 by default)
  75946. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75947. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75948. */
  75949. constructor(
  75950. /**
  75951. * The radius of the emission sphere.
  75952. */
  75953. radius?: number,
  75954. /**
  75955. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75956. */
  75957. radiusRange?: number,
  75958. /**
  75959. * How much to randomize the particle direction [0-1].
  75960. */
  75961. directionRandomizer?: number);
  75962. /**
  75963. * Called by the particle System when the direction is computed for the created particle.
  75964. * @param worldMatrix is the world matrix of the particle system
  75965. * @param directionToUpdate is the direction vector to update with the result
  75966. * @param particle is the particle we are computed the direction for
  75967. */
  75968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75969. /**
  75970. * Called by the particle System when the position is computed for the created particle.
  75971. * @param worldMatrix is the world matrix of the particle system
  75972. * @param positionToUpdate is the position vector to update with the result
  75973. * @param particle is the particle we are computed the position for
  75974. */
  75975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75976. /**
  75977. * Clones the current emitter and returns a copy of it
  75978. * @returns the new emitter
  75979. */
  75980. clone(): SphereParticleEmitter;
  75981. /**
  75982. * Called by the GPUParticleSystem to setup the update shader
  75983. * @param effect defines the update shader
  75984. */
  75985. applyToShader(effect: Effect): void;
  75986. /**
  75987. * Returns a string to use to update the GPU particles update shader
  75988. * @returns a string containng the defines string
  75989. */
  75990. getEffectDefines(): string;
  75991. /**
  75992. * Returns the string "SphereParticleEmitter"
  75993. * @returns a string containing the class name
  75994. */
  75995. getClassName(): string;
  75996. /**
  75997. * Serializes the particle system to a JSON object.
  75998. * @returns the JSON object
  75999. */
  76000. serialize(): any;
  76001. /**
  76002. * Parse properties from a JSON object
  76003. * @param serializationObject defines the JSON object
  76004. */
  76005. parse(serializationObject: any): void;
  76006. }
  76007. /**
  76008. * Particle emitter emitting particles from the inside of a sphere.
  76009. * It emits the particles randomly between two vectors.
  76010. */
  76011. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76012. /**
  76013. * The min limit of the emission direction.
  76014. */
  76015. direction1: Vector3;
  76016. /**
  76017. * The max limit of the emission direction.
  76018. */
  76019. direction2: Vector3;
  76020. /**
  76021. * Creates a new instance SphereDirectedParticleEmitter
  76022. * @param radius the radius of the emission sphere (1 by default)
  76023. * @param direction1 the min limit of the emission direction (up vector by default)
  76024. * @param direction2 the max limit of the emission direction (up vector by default)
  76025. */
  76026. constructor(radius?: number,
  76027. /**
  76028. * The min limit of the emission direction.
  76029. */
  76030. direction1?: Vector3,
  76031. /**
  76032. * The max limit of the emission direction.
  76033. */
  76034. direction2?: Vector3);
  76035. /**
  76036. * Called by the particle System when the direction is computed for the created particle.
  76037. * @param worldMatrix is the world matrix of the particle system
  76038. * @param directionToUpdate is the direction vector to update with the result
  76039. * @param particle is the particle we are computed the direction for
  76040. */
  76041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76042. /**
  76043. * Clones the current emitter and returns a copy of it
  76044. * @returns the new emitter
  76045. */
  76046. clone(): SphereDirectedParticleEmitter;
  76047. /**
  76048. * Called by the GPUParticleSystem to setup the update shader
  76049. * @param effect defines the update shader
  76050. */
  76051. applyToShader(effect: Effect): void;
  76052. /**
  76053. * Returns a string to use to update the GPU particles update shader
  76054. * @returns a string containng the defines string
  76055. */
  76056. getEffectDefines(): string;
  76057. /**
  76058. * Returns the string "SphereDirectedParticleEmitter"
  76059. * @returns a string containing the class name
  76060. */
  76061. getClassName(): string;
  76062. /**
  76063. * Serializes the particle system to a JSON object.
  76064. * @returns the JSON object
  76065. */
  76066. serialize(): any;
  76067. /**
  76068. * Parse properties from a JSON object
  76069. * @param serializationObject defines the JSON object
  76070. */
  76071. parse(serializationObject: any): void;
  76072. }
  76073. }
  76074. declare module BABYLON {
  76075. /**
  76076. * Interface representing a particle system in Babylon.js.
  76077. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76078. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76079. */
  76080. export interface IParticleSystem {
  76081. /**
  76082. * List of animations used by the particle system.
  76083. */
  76084. animations: Animation[];
  76085. /**
  76086. * The id of the Particle system.
  76087. */
  76088. id: string;
  76089. /**
  76090. * The name of the Particle system.
  76091. */
  76092. name: string;
  76093. /**
  76094. * The emitter represents the Mesh or position we are attaching the particle system to.
  76095. */
  76096. emitter: Nullable<AbstractMesh | Vector3>;
  76097. /**
  76098. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76099. */
  76100. isBillboardBased: boolean;
  76101. /**
  76102. * The rendering group used by the Particle system to chose when to render.
  76103. */
  76104. renderingGroupId: number;
  76105. /**
  76106. * The layer mask we are rendering the particles through.
  76107. */
  76108. layerMask: number;
  76109. /**
  76110. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76111. */
  76112. updateSpeed: number;
  76113. /**
  76114. * The amount of time the particle system is running (depends of the overall update speed).
  76115. */
  76116. targetStopDuration: number;
  76117. /**
  76118. * The texture used to render each particle. (this can be a spritesheet)
  76119. */
  76120. particleTexture: Nullable<Texture>;
  76121. /**
  76122. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76123. */
  76124. blendMode: number;
  76125. /**
  76126. * Minimum life time of emitting particles.
  76127. */
  76128. minLifeTime: number;
  76129. /**
  76130. * Maximum life time of emitting particles.
  76131. */
  76132. maxLifeTime: number;
  76133. /**
  76134. * Minimum Size of emitting particles.
  76135. */
  76136. minSize: number;
  76137. /**
  76138. * Maximum Size of emitting particles.
  76139. */
  76140. maxSize: number;
  76141. /**
  76142. * Minimum scale of emitting particles on X axis.
  76143. */
  76144. minScaleX: number;
  76145. /**
  76146. * Maximum scale of emitting particles on X axis.
  76147. */
  76148. maxScaleX: number;
  76149. /**
  76150. * Minimum scale of emitting particles on Y axis.
  76151. */
  76152. minScaleY: number;
  76153. /**
  76154. * Maximum scale of emitting particles on Y axis.
  76155. */
  76156. maxScaleY: number;
  76157. /**
  76158. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76159. */
  76160. color1: Color4;
  76161. /**
  76162. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76163. */
  76164. color2: Color4;
  76165. /**
  76166. * Color the particle will have at the end of its lifetime.
  76167. */
  76168. colorDead: Color4;
  76169. /**
  76170. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76171. */
  76172. emitRate: number;
  76173. /**
  76174. * You can use gravity if you want to give an orientation to your particles.
  76175. */
  76176. gravity: Vector3;
  76177. /**
  76178. * Minimum power of emitting particles.
  76179. */
  76180. minEmitPower: number;
  76181. /**
  76182. * Maximum power of emitting particles.
  76183. */
  76184. maxEmitPower: number;
  76185. /**
  76186. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76187. */
  76188. minAngularSpeed: number;
  76189. /**
  76190. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76191. */
  76192. maxAngularSpeed: number;
  76193. /**
  76194. * Gets or sets the minimal initial rotation in radians.
  76195. */
  76196. minInitialRotation: number;
  76197. /**
  76198. * Gets or sets the maximal initial rotation in radians.
  76199. */
  76200. maxInitialRotation: number;
  76201. /**
  76202. * The particle emitter type defines the emitter used by the particle system.
  76203. * It can be for example box, sphere, or cone...
  76204. */
  76205. particleEmitterType: Nullable<IParticleEmitterType>;
  76206. /**
  76207. * Defines the delay in milliseconds before starting the system (0 by default)
  76208. */
  76209. startDelay: number;
  76210. /**
  76211. * 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
  76212. */
  76213. preWarmCycles: number;
  76214. /**
  76215. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76216. */
  76217. preWarmStepOffset: number;
  76218. /**
  76219. * 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)
  76220. */
  76221. spriteCellChangeSpeed: number;
  76222. /**
  76223. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76224. */
  76225. startSpriteCellID: number;
  76226. /**
  76227. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76228. */
  76229. endSpriteCellID: number;
  76230. /**
  76231. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76232. */
  76233. spriteCellWidth: number;
  76234. /**
  76235. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76236. */
  76237. spriteCellHeight: number;
  76238. /**
  76239. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76240. */
  76241. spriteRandomStartCell: boolean;
  76242. /**
  76243. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76244. */
  76245. isAnimationSheetEnabled: boolean;
  76246. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76247. translationPivot: Vector2;
  76248. /**
  76249. * Gets or sets a texture used to add random noise to particle positions
  76250. */
  76251. noiseTexture: Nullable<BaseTexture>;
  76252. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76253. noiseStrength: Vector3;
  76254. /**
  76255. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76256. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76257. */
  76258. billboardMode: number;
  76259. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76260. limitVelocityDamping: number;
  76261. /**
  76262. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76263. */
  76264. beginAnimationOnStart: boolean;
  76265. /**
  76266. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76267. */
  76268. beginAnimationFrom: number;
  76269. /**
  76270. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76271. */
  76272. beginAnimationTo: number;
  76273. /**
  76274. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76275. */
  76276. beginAnimationLoop: boolean;
  76277. /**
  76278. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76279. */
  76280. disposeOnStop: boolean;
  76281. /**
  76282. * Gets the maximum number of particles active at the same time.
  76283. * @returns The max number of active particles.
  76284. */
  76285. getCapacity(): number;
  76286. /**
  76287. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76288. * @returns True if it has been started, otherwise false.
  76289. */
  76290. isStarted(): boolean;
  76291. /**
  76292. * Animates the particle system for this frame.
  76293. */
  76294. animate(): void;
  76295. /**
  76296. * Renders the particle system in its current state.
  76297. * @returns the current number of particles
  76298. */
  76299. render(): number;
  76300. /**
  76301. * Dispose the particle system and frees its associated resources.
  76302. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76303. */
  76304. dispose(disposeTexture?: boolean): void;
  76305. /**
  76306. * Clones the particle system.
  76307. * @param name The name of the cloned object
  76308. * @param newEmitter The new emitter to use
  76309. * @returns the cloned particle system
  76310. */
  76311. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76312. /**
  76313. * Serializes the particle system to a JSON object.
  76314. * @returns the JSON object
  76315. */
  76316. serialize(): any;
  76317. /**
  76318. * Rebuild the particle system
  76319. */
  76320. rebuild(): void;
  76321. /**
  76322. * Starts the particle system and begins to emit
  76323. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76324. */
  76325. start(delay?: number): void;
  76326. /**
  76327. * Stops the particle system.
  76328. */
  76329. stop(): void;
  76330. /**
  76331. * Remove all active particles
  76332. */
  76333. reset(): void;
  76334. /**
  76335. * Is this system ready to be used/rendered
  76336. * @return true if the system is ready
  76337. */
  76338. isReady(): boolean;
  76339. /**
  76340. * Adds a new color gradient
  76341. * @param gradient defines the gradient to use (between 0 and 1)
  76342. * @param color1 defines the color to affect to the specified gradient
  76343. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76344. * @returns the current particle system
  76345. */
  76346. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76347. /**
  76348. * Remove a specific color gradient
  76349. * @param gradient defines the gradient to remove
  76350. * @returns the current particle system
  76351. */
  76352. removeColorGradient(gradient: number): IParticleSystem;
  76353. /**
  76354. * Adds a new size gradient
  76355. * @param gradient defines the gradient to use (between 0 and 1)
  76356. * @param factor defines the size factor to affect to the specified gradient
  76357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76358. * @returns the current particle system
  76359. */
  76360. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76361. /**
  76362. * Remove a specific size gradient
  76363. * @param gradient defines the gradient to remove
  76364. * @returns the current particle system
  76365. */
  76366. removeSizeGradient(gradient: number): IParticleSystem;
  76367. /**
  76368. * Gets the current list of color gradients.
  76369. * You must use addColorGradient and removeColorGradient to udpate this list
  76370. * @returns the list of color gradients
  76371. */
  76372. getColorGradients(): Nullable<Array<ColorGradient>>;
  76373. /**
  76374. * Gets the current list of size gradients.
  76375. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76376. * @returns the list of size gradients
  76377. */
  76378. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76379. /**
  76380. * Gets the current list of angular speed gradients.
  76381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76382. * @returns the list of angular speed gradients
  76383. */
  76384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76385. /**
  76386. * Adds a new angular speed gradient
  76387. * @param gradient defines the gradient to use (between 0 and 1)
  76388. * @param factor defines the angular speed to affect to the specified gradient
  76389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76390. * @returns the current particle system
  76391. */
  76392. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76393. /**
  76394. * Remove a specific angular speed gradient
  76395. * @param gradient defines the gradient to remove
  76396. * @returns the current particle system
  76397. */
  76398. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76399. /**
  76400. * Gets the current list of velocity gradients.
  76401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76402. * @returns the list of velocity gradients
  76403. */
  76404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76405. /**
  76406. * Adds a new velocity gradient
  76407. * @param gradient defines the gradient to use (between 0 and 1)
  76408. * @param factor defines the velocity to affect to the specified gradient
  76409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76410. * @returns the current particle system
  76411. */
  76412. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76413. /**
  76414. * Remove a specific velocity gradient
  76415. * @param gradient defines the gradient to remove
  76416. * @returns the current particle system
  76417. */
  76418. removeVelocityGradient(gradient: number): IParticleSystem;
  76419. /**
  76420. * Gets the current list of limit velocity gradients.
  76421. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76422. * @returns the list of limit velocity gradients
  76423. */
  76424. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76425. /**
  76426. * Adds a new limit velocity gradient
  76427. * @param gradient defines the gradient to use (between 0 and 1)
  76428. * @param factor defines the limit velocity to affect to the specified gradient
  76429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76430. * @returns the current particle system
  76431. */
  76432. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76433. /**
  76434. * Remove a specific limit velocity gradient
  76435. * @param gradient defines the gradient to remove
  76436. * @returns the current particle system
  76437. */
  76438. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76439. /**
  76440. * Adds a new drag gradient
  76441. * @param gradient defines the gradient to use (between 0 and 1)
  76442. * @param factor defines the drag to affect to the specified gradient
  76443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76444. * @returns the current particle system
  76445. */
  76446. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76447. /**
  76448. * Remove a specific drag gradient
  76449. * @param gradient defines the gradient to remove
  76450. * @returns the current particle system
  76451. */
  76452. removeDragGradient(gradient: number): IParticleSystem;
  76453. /**
  76454. * Gets the current list of drag gradients.
  76455. * You must use addDragGradient and removeDragGradient to udpate this list
  76456. * @returns the list of drag gradients
  76457. */
  76458. getDragGradients(): Nullable<Array<FactorGradient>>;
  76459. /**
  76460. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76461. * @param gradient defines the gradient to use (between 0 and 1)
  76462. * @param factor defines the emit rate to affect to the specified gradient
  76463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76464. * @returns the current particle system
  76465. */
  76466. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76467. /**
  76468. * Remove a specific emit rate gradient
  76469. * @param gradient defines the gradient to remove
  76470. * @returns the current particle system
  76471. */
  76472. removeEmitRateGradient(gradient: number): IParticleSystem;
  76473. /**
  76474. * Gets the current list of emit rate gradients.
  76475. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76476. * @returns the list of emit rate gradients
  76477. */
  76478. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76479. /**
  76480. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76481. * @param gradient defines the gradient to use (between 0 and 1)
  76482. * @param factor defines the start size to affect to the specified gradient
  76483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76484. * @returns the current particle system
  76485. */
  76486. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76487. /**
  76488. * Remove a specific start size gradient
  76489. * @param gradient defines the gradient to remove
  76490. * @returns the current particle system
  76491. */
  76492. removeStartSizeGradient(gradient: number): IParticleSystem;
  76493. /**
  76494. * Gets the current list of start size gradients.
  76495. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76496. * @returns the list of start size gradients
  76497. */
  76498. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76499. /**
  76500. * Adds a new life time gradient
  76501. * @param gradient defines the gradient to use (between 0 and 1)
  76502. * @param factor defines the life time factor to affect to the specified gradient
  76503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76504. * @returns the current particle system
  76505. */
  76506. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76507. /**
  76508. * Remove a specific life time gradient
  76509. * @param gradient defines the gradient to remove
  76510. * @returns the current particle system
  76511. */
  76512. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76513. /**
  76514. * Gets the current list of life time gradients.
  76515. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76516. * @returns the list of life time gradients
  76517. */
  76518. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76519. /**
  76520. * Gets the current list of color gradients.
  76521. * You must use addColorGradient and removeColorGradient to udpate this list
  76522. * @returns the list of color gradients
  76523. */
  76524. getColorGradients(): Nullable<Array<ColorGradient>>;
  76525. /**
  76526. * Adds a new ramp gradient used to remap particle colors
  76527. * @param gradient defines the gradient to use (between 0 and 1)
  76528. * @param color defines the color to affect to the specified gradient
  76529. * @returns the current particle system
  76530. */
  76531. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76532. /**
  76533. * Gets the current list of ramp gradients.
  76534. * You must use addRampGradient and removeRampGradient to udpate this list
  76535. * @returns the list of ramp gradients
  76536. */
  76537. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76538. /** Gets or sets a boolean indicating that ramp gradients must be used
  76539. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76540. */
  76541. useRampGradients: boolean;
  76542. /**
  76543. * Adds a new color remap gradient
  76544. * @param gradient defines the gradient to use (between 0 and 1)
  76545. * @param min defines the color remap minimal range
  76546. * @param max defines the color remap maximal range
  76547. * @returns the current particle system
  76548. */
  76549. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76550. /**
  76551. * Gets the current list of color remap gradients.
  76552. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76553. * @returns the list of color remap gradients
  76554. */
  76555. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76556. /**
  76557. * Adds a new alpha remap gradient
  76558. * @param gradient defines the gradient to use (between 0 and 1)
  76559. * @param min defines the alpha remap minimal range
  76560. * @param max defines the alpha remap maximal range
  76561. * @returns the current particle system
  76562. */
  76563. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76564. /**
  76565. * Gets the current list of alpha remap gradients.
  76566. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76567. * @returns the list of alpha remap gradients
  76568. */
  76569. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76570. /**
  76571. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76574. * @returns the emitter
  76575. */
  76576. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76577. /**
  76578. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76579. * @param radius The radius of the hemisphere to emit from
  76580. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76581. * @returns the emitter
  76582. */
  76583. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76584. /**
  76585. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76586. * @param radius The radius of the sphere to emit from
  76587. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76588. * @returns the emitter
  76589. */
  76590. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76591. /**
  76592. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76593. * @param radius The radius of the sphere to emit from
  76594. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76595. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76596. * @returns the emitter
  76597. */
  76598. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76599. /**
  76600. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76601. * @param radius The radius of the emission cylinder
  76602. * @param height The height of the emission cylinder
  76603. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76604. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76605. * @returns the emitter
  76606. */
  76607. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76608. /**
  76609. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76610. * @param radius The radius of the cylinder to emit from
  76611. * @param height The height of the emission cylinder
  76612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76615. * @returns the emitter
  76616. */
  76617. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76618. /**
  76619. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76620. * @param radius The radius of the cone to emit from
  76621. * @param angle The base angle of the cone
  76622. * @returns the emitter
  76623. */
  76624. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76625. /**
  76626. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76629. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76630. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76631. * @returns the emitter
  76632. */
  76633. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76634. /**
  76635. * Get hosting scene
  76636. * @returns the scene
  76637. */
  76638. getScene(): Scene;
  76639. }
  76640. }
  76641. declare module BABYLON {
  76642. /**
  76643. * Creates an instance based on a source mesh.
  76644. */
  76645. export class InstancedMesh extends AbstractMesh {
  76646. private _sourceMesh;
  76647. private _currentLOD;
  76648. /** @hidden */
  76649. _indexInSourceMeshInstanceArray: number;
  76650. constructor(name: string, source: Mesh);
  76651. /**
  76652. * Returns the string "InstancedMesh".
  76653. */
  76654. getClassName(): string;
  76655. /** Gets the list of lights affecting that mesh */
  76656. readonly lightSources: Light[];
  76657. _resyncLightSources(): void;
  76658. _resyncLighSource(light: Light): void;
  76659. _removeLightSource(light: Light): void;
  76660. /**
  76661. * If the source mesh receives shadows
  76662. */
  76663. readonly receiveShadows: boolean;
  76664. /**
  76665. * The material of the source mesh
  76666. */
  76667. readonly material: Nullable<Material>;
  76668. /**
  76669. * Visibility of the source mesh
  76670. */
  76671. readonly visibility: number;
  76672. /**
  76673. * Skeleton of the source mesh
  76674. */
  76675. readonly skeleton: Nullable<Skeleton>;
  76676. /**
  76677. * Rendering ground id of the source mesh
  76678. */
  76679. renderingGroupId: number;
  76680. /**
  76681. * Returns the total number of vertices (integer).
  76682. */
  76683. getTotalVertices(): number;
  76684. /**
  76685. * Returns a positive integer : the total number of indices in this mesh geometry.
  76686. * @returns the numner of indices or zero if the mesh has no geometry.
  76687. */
  76688. getTotalIndices(): number;
  76689. /**
  76690. * The source mesh of the instance
  76691. */
  76692. readonly sourceMesh: Mesh;
  76693. /**
  76694. * Is this node ready to be used/rendered
  76695. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76696. * @return {boolean} is it ready
  76697. */
  76698. isReady(completeCheck?: boolean): boolean;
  76699. /**
  76700. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76701. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76702. * @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.
  76703. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76704. */
  76705. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76706. /**
  76707. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76708. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76709. * The `data` are either a numeric array either a Float32Array.
  76710. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76711. * 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).
  76712. * Note that a new underlying VertexBuffer object is created each call.
  76713. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76714. *
  76715. * Possible `kind` values :
  76716. * - VertexBuffer.PositionKind
  76717. * - VertexBuffer.UVKind
  76718. * - VertexBuffer.UV2Kind
  76719. * - VertexBuffer.UV3Kind
  76720. * - VertexBuffer.UV4Kind
  76721. * - VertexBuffer.UV5Kind
  76722. * - VertexBuffer.UV6Kind
  76723. * - VertexBuffer.ColorKind
  76724. * - VertexBuffer.MatricesIndicesKind
  76725. * - VertexBuffer.MatricesIndicesExtraKind
  76726. * - VertexBuffer.MatricesWeightsKind
  76727. * - VertexBuffer.MatricesWeightsExtraKind
  76728. *
  76729. * Returns the Mesh.
  76730. */
  76731. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76732. /**
  76733. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76734. * If the mesh has no geometry, it is simply returned as it is.
  76735. * The `data` are either a numeric array either a Float32Array.
  76736. * No new underlying VertexBuffer object is created.
  76737. * 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.
  76738. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76739. *
  76740. * Possible `kind` values :
  76741. * - VertexBuffer.PositionKind
  76742. * - VertexBuffer.UVKind
  76743. * - VertexBuffer.UV2Kind
  76744. * - VertexBuffer.UV3Kind
  76745. * - VertexBuffer.UV4Kind
  76746. * - VertexBuffer.UV5Kind
  76747. * - VertexBuffer.UV6Kind
  76748. * - VertexBuffer.ColorKind
  76749. * - VertexBuffer.MatricesIndicesKind
  76750. * - VertexBuffer.MatricesIndicesExtraKind
  76751. * - VertexBuffer.MatricesWeightsKind
  76752. * - VertexBuffer.MatricesWeightsExtraKind
  76753. *
  76754. * Returns the Mesh.
  76755. */
  76756. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76757. /**
  76758. * Sets the mesh indices.
  76759. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76760. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76761. * This method creates a new index buffer each call.
  76762. * Returns the Mesh.
  76763. */
  76764. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76765. /**
  76766. * Boolean : True if the mesh owns the requested kind of data.
  76767. */
  76768. isVerticesDataPresent(kind: string): boolean;
  76769. /**
  76770. * Returns an array of indices (IndicesArray).
  76771. */
  76772. getIndices(): Nullable<IndicesArray>;
  76773. readonly _positions: Nullable<Vector3[]>;
  76774. /**
  76775. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76776. * This means the mesh underlying bounding box and sphere are recomputed.
  76777. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76778. * @returns the current mesh
  76779. */
  76780. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76781. /** @hidden */
  76782. _preActivate(): InstancedMesh;
  76783. /** @hidden */
  76784. _activate(renderId: number): boolean;
  76785. getWorldMatrix(): Matrix;
  76786. /**
  76787. * Returns the current associated LOD AbstractMesh.
  76788. */
  76789. getLOD(camera: Camera): AbstractMesh;
  76790. /** @hidden */
  76791. _syncSubMeshes(): InstancedMesh;
  76792. /** @hidden */
  76793. _generatePointsArray(): boolean;
  76794. /**
  76795. * Creates a new InstancedMesh from the current mesh.
  76796. * - name (string) : the cloned mesh name
  76797. * - newParent (optional Node) : the optional Node to parent the clone to.
  76798. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76799. *
  76800. * Returns the clone.
  76801. */
  76802. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76803. /**
  76804. * Disposes the InstancedMesh.
  76805. * Returns nothing.
  76806. */
  76807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76808. }
  76809. }
  76810. declare module BABYLON {
  76811. /**
  76812. * Defines the options associated with the creation of a shader material.
  76813. */
  76814. export interface IShaderMaterialOptions {
  76815. /**
  76816. * Does the material work in alpha blend mode
  76817. */
  76818. needAlphaBlending: boolean;
  76819. /**
  76820. * Does the material work in alpha test mode
  76821. */
  76822. needAlphaTesting: boolean;
  76823. /**
  76824. * The list of attribute names used in the shader
  76825. */
  76826. attributes: string[];
  76827. /**
  76828. * The list of unifrom names used in the shader
  76829. */
  76830. uniforms: string[];
  76831. /**
  76832. * The list of UBO names used in the shader
  76833. */
  76834. uniformBuffers: string[];
  76835. /**
  76836. * The list of sampler names used in the shader
  76837. */
  76838. samplers: string[];
  76839. /**
  76840. * The list of defines used in the shader
  76841. */
  76842. defines: string[];
  76843. }
  76844. /**
  76845. * 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.
  76846. *
  76847. * This returned material effects how the mesh will look based on the code in the shaders.
  76848. *
  76849. * @see http://doc.babylonjs.com/how_to/shader_material
  76850. */
  76851. export class ShaderMaterial extends Material {
  76852. private _shaderPath;
  76853. private _options;
  76854. private _textures;
  76855. private _textureArrays;
  76856. private _floats;
  76857. private _ints;
  76858. private _floatsArrays;
  76859. private _colors3;
  76860. private _colors3Arrays;
  76861. private _colors4;
  76862. private _vectors2;
  76863. private _vectors3;
  76864. private _vectors4;
  76865. private _matrices;
  76866. private _matrices3x3;
  76867. private _matrices2x2;
  76868. private _vectors2Arrays;
  76869. private _vectors3Arrays;
  76870. private _cachedWorldViewMatrix;
  76871. private _renderId;
  76872. /**
  76873. * Instantiate a new shader material.
  76874. * 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.
  76875. * This returned material effects how the mesh will look based on the code in the shaders.
  76876. * @see http://doc.babylonjs.com/how_to/shader_material
  76877. * @param name Define the name of the material in the scene
  76878. * @param scene Define the scene the material belongs to
  76879. * @param shaderPath Defines the route to the shader code in one of three ways:
  76880. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76881. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76882. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76883. * @param options Define the options used to create the shader
  76884. */
  76885. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76886. /**
  76887. * Gets the options used to compile the shader.
  76888. * They can be modified to trigger a new compilation
  76889. */
  76890. readonly options: IShaderMaterialOptions;
  76891. /**
  76892. * Gets the current class name of the material e.g. "ShaderMaterial"
  76893. * Mainly use in serialization.
  76894. * @returns the class name
  76895. */
  76896. getClassName(): string;
  76897. /**
  76898. * Specifies if the material will require alpha blending
  76899. * @returns a boolean specifying if alpha blending is needed
  76900. */
  76901. needAlphaBlending(): boolean;
  76902. /**
  76903. * Specifies if this material should be rendered in alpha test mode
  76904. * @returns a boolean specifying if an alpha test is needed.
  76905. */
  76906. needAlphaTesting(): boolean;
  76907. private _checkUniform;
  76908. /**
  76909. * Set a texture in the shader.
  76910. * @param name Define the name of the uniform samplers as defined in the shader
  76911. * @param texture Define the texture to bind to this sampler
  76912. * @return the material itself allowing "fluent" like uniform updates
  76913. */
  76914. setTexture(name: string, texture: Texture): ShaderMaterial;
  76915. /**
  76916. * Set a texture array in the shader.
  76917. * @param name Define the name of the uniform sampler array as defined in the shader
  76918. * @param textures Define the list of textures to bind to this sampler
  76919. * @return the material itself allowing "fluent" like uniform updates
  76920. */
  76921. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76922. /**
  76923. * Set a float in the shader.
  76924. * @param name Define the name of the uniform as defined in the shader
  76925. * @param value Define the value to give to the uniform
  76926. * @return the material itself allowing "fluent" like uniform updates
  76927. */
  76928. setFloat(name: string, value: number): ShaderMaterial;
  76929. /**
  76930. * Set a int in the shader.
  76931. * @param name Define the name of the uniform as defined in the shader
  76932. * @param value Define the value to give to the uniform
  76933. * @return the material itself allowing "fluent" like uniform updates
  76934. */
  76935. setInt(name: string, value: number): ShaderMaterial;
  76936. /**
  76937. * Set an array of floats in the shader.
  76938. * @param name Define the name of the uniform as defined in the shader
  76939. * @param value Define the value to give to the uniform
  76940. * @return the material itself allowing "fluent" like uniform updates
  76941. */
  76942. setFloats(name: string, value: number[]): ShaderMaterial;
  76943. /**
  76944. * Set a vec3 in the shader from a Color3.
  76945. * @param name Define the name of the uniform as defined in the shader
  76946. * @param value Define the value to give to the uniform
  76947. * @return the material itself allowing "fluent" like uniform updates
  76948. */
  76949. setColor3(name: string, value: Color3): ShaderMaterial;
  76950. /**
  76951. * Set a vec3 array in the shader from a Color3 array.
  76952. * @param name Define the name of the uniform as defined in the shader
  76953. * @param value Define the value to give to the uniform
  76954. * @return the material itself allowing "fluent" like uniform updates
  76955. */
  76956. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76957. /**
  76958. * Set a vec4 in the shader from a Color4.
  76959. * @param name Define the name of the uniform as defined in the shader
  76960. * @param value Define the value to give to the uniform
  76961. * @return the material itself allowing "fluent" like uniform updates
  76962. */
  76963. setColor4(name: string, value: Color4): ShaderMaterial;
  76964. /**
  76965. * Set a vec2 in the shader from a Vector2.
  76966. * @param name Define the name of the uniform as defined in the shader
  76967. * @param value Define the value to give to the uniform
  76968. * @return the material itself allowing "fluent" like uniform updates
  76969. */
  76970. setVector2(name: string, value: Vector2): ShaderMaterial;
  76971. /**
  76972. * Set a vec3 in the shader from a Vector3.
  76973. * @param name Define the name of the uniform as defined in the shader
  76974. * @param value Define the value to give to the uniform
  76975. * @return the material itself allowing "fluent" like uniform updates
  76976. */
  76977. setVector3(name: string, value: Vector3): ShaderMaterial;
  76978. /**
  76979. * Set a vec4 in the shader from a Vector4.
  76980. * @param name Define the name of the uniform as defined in the shader
  76981. * @param value Define the value to give to the uniform
  76982. * @return the material itself allowing "fluent" like uniform updates
  76983. */
  76984. setVector4(name: string, value: Vector4): ShaderMaterial;
  76985. /**
  76986. * Set a mat4 in the shader from a Matrix.
  76987. * @param name Define the name of the uniform as defined in the shader
  76988. * @param value Define the value to give to the uniform
  76989. * @return the material itself allowing "fluent" like uniform updates
  76990. */
  76991. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76992. /**
  76993. * Set a mat3 in the shader from a Float32Array.
  76994. * @param name Define the name of the uniform as defined in the shader
  76995. * @param value Define the value to give to the uniform
  76996. * @return the material itself allowing "fluent" like uniform updates
  76997. */
  76998. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76999. /**
  77000. * Set a mat2 in the shader from a Float32Array.
  77001. * @param name Define the name of the uniform as defined in the shader
  77002. * @param value Define the value to give to the uniform
  77003. * @return the material itself allowing "fluent" like uniform updates
  77004. */
  77005. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77006. /**
  77007. * Set a vec2 array in the shader from a number array.
  77008. * @param name Define the name of the uniform as defined in the shader
  77009. * @param value Define the value to give to the uniform
  77010. * @return the material itself allowing "fluent" like uniform updates
  77011. */
  77012. setArray2(name: string, value: number[]): ShaderMaterial;
  77013. /**
  77014. * Set a vec3 array in the shader from a number array.
  77015. * @param name Define the name of the uniform as defined in the shader
  77016. * @param value Define the value to give to the uniform
  77017. * @return the material itself allowing "fluent" like uniform updates
  77018. */
  77019. setArray3(name: string, value: number[]): ShaderMaterial;
  77020. private _checkCache;
  77021. /**
  77022. * Specifies that the submesh is ready to be used
  77023. * @param mesh defines the mesh to check
  77024. * @param subMesh defines which submesh to check
  77025. * @param useInstances specifies that instances should be used
  77026. * @returns a boolean indicating that the submesh is ready or not
  77027. */
  77028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77029. /**
  77030. * Checks if the material is ready to render the requested mesh
  77031. * @param mesh Define the mesh to render
  77032. * @param useInstances Define whether or not the material is used with instances
  77033. * @returns true if ready, otherwise false
  77034. */
  77035. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77036. /**
  77037. * Binds the world matrix to the material
  77038. * @param world defines the world transformation matrix
  77039. */
  77040. bindOnlyWorldMatrix(world: Matrix): void;
  77041. /**
  77042. * Binds the material to the mesh
  77043. * @param world defines the world transformation matrix
  77044. * @param mesh defines the mesh to bind the material to
  77045. */
  77046. bind(world: Matrix, mesh?: Mesh): void;
  77047. /**
  77048. * Gets the active textures from the material
  77049. * @returns an array of textures
  77050. */
  77051. getActiveTextures(): BaseTexture[];
  77052. /**
  77053. * Specifies if the material uses a texture
  77054. * @param texture defines the texture to check against the material
  77055. * @returns a boolean specifying if the material uses the texture
  77056. */
  77057. hasTexture(texture: BaseTexture): boolean;
  77058. /**
  77059. * Makes a duplicate of the material, and gives it a new name
  77060. * @param name defines the new name for the duplicated material
  77061. * @returns the cloned material
  77062. */
  77063. clone(name: string): ShaderMaterial;
  77064. /**
  77065. * Disposes the material
  77066. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77067. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77068. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77069. */
  77070. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77071. /**
  77072. * Serializes this material in a JSON representation
  77073. * @returns the serialized material object
  77074. */
  77075. serialize(): any;
  77076. /**
  77077. * Creates a shader material from parsed shader material data
  77078. * @param source defines the JSON represnetation of the material
  77079. * @param scene defines the hosting scene
  77080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77081. * @returns a new material
  77082. */
  77083. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77084. }
  77085. }
  77086. declare module BABYLON {
  77087. /** @hidden */
  77088. export var colorPixelShader: {
  77089. name: string;
  77090. shader: string;
  77091. };
  77092. }
  77093. declare module BABYLON {
  77094. /** @hidden */
  77095. export var colorVertexShader: {
  77096. name: string;
  77097. shader: string;
  77098. };
  77099. }
  77100. declare module BABYLON {
  77101. /**
  77102. * Line mesh
  77103. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77104. */
  77105. export class LinesMesh extends Mesh {
  77106. /**
  77107. * If vertex color should be applied to the mesh
  77108. */
  77109. useVertexColor?: boolean | undefined;
  77110. /**
  77111. * If vertex alpha should be applied to the mesh
  77112. */
  77113. useVertexAlpha?: boolean | undefined;
  77114. /**
  77115. * Color of the line (Default: White)
  77116. */
  77117. color: Color3;
  77118. /**
  77119. * Alpha of the line (Default: 1)
  77120. */
  77121. alpha: number;
  77122. /**
  77123. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77124. * This margin is expressed in world space coordinates, so its value may vary.
  77125. * Default value is 0.1
  77126. */
  77127. intersectionThreshold: number;
  77128. private _colorShader;
  77129. /**
  77130. * Creates a new LinesMesh
  77131. * @param name defines the name
  77132. * @param scene defines the hosting scene
  77133. * @param parent defines the parent mesh if any
  77134. * @param source defines the optional source LinesMesh used to clone data from
  77135. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77136. * When false, achieved by calling a clone(), also passing False.
  77137. * This will make creation of children, recursive.
  77138. * @param useVertexColor defines if this LinesMesh supports vertex color
  77139. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77140. */
  77141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77142. /**
  77143. * If vertex color should be applied to the mesh
  77144. */
  77145. useVertexColor?: boolean | undefined,
  77146. /**
  77147. * If vertex alpha should be applied to the mesh
  77148. */
  77149. useVertexAlpha?: boolean | undefined);
  77150. private _addClipPlaneDefine;
  77151. private _removeClipPlaneDefine;
  77152. isReady(): boolean;
  77153. /**
  77154. * Returns the string "LineMesh"
  77155. */
  77156. getClassName(): string;
  77157. /**
  77158. * @hidden
  77159. */
  77160. /**
  77161. * @hidden
  77162. */
  77163. material: Material;
  77164. /**
  77165. * @hidden
  77166. */
  77167. readonly checkCollisions: boolean;
  77168. /** @hidden */
  77169. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77170. /** @hidden */
  77171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77172. /**
  77173. * Disposes of the line mesh
  77174. * @param doNotRecurse If children should be disposed
  77175. */
  77176. dispose(doNotRecurse?: boolean): void;
  77177. /**
  77178. * Returns a new LineMesh object cloned from the current one.
  77179. */
  77180. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77181. /**
  77182. * Creates a new InstancedLinesMesh object from the mesh model.
  77183. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77184. * @param name defines the name of the new instance
  77185. * @returns a new InstancedLinesMesh
  77186. */
  77187. createInstance(name: string): InstancedLinesMesh;
  77188. }
  77189. /**
  77190. * Creates an instance based on a source LinesMesh
  77191. */
  77192. export class InstancedLinesMesh extends InstancedMesh {
  77193. /**
  77194. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77195. * This margin is expressed in world space coordinates, so its value may vary.
  77196. * Initilized with the intersectionThreshold value of the source LinesMesh
  77197. */
  77198. intersectionThreshold: number;
  77199. constructor(name: string, source: LinesMesh);
  77200. /**
  77201. * Returns the string "InstancedLinesMesh".
  77202. */
  77203. getClassName(): string;
  77204. }
  77205. }
  77206. declare module BABYLON {
  77207. /** @hidden */
  77208. export var linePixelShader: {
  77209. name: string;
  77210. shader: string;
  77211. };
  77212. }
  77213. declare module BABYLON {
  77214. /** @hidden */
  77215. export var lineVertexShader: {
  77216. name: string;
  77217. shader: string;
  77218. };
  77219. }
  77220. declare module BABYLON {
  77221. interface AbstractMesh {
  77222. /**
  77223. * Disables the mesh edge rendering mode
  77224. * @returns the currentAbstractMesh
  77225. */
  77226. disableEdgesRendering(): AbstractMesh;
  77227. /**
  77228. * Enables the edge rendering mode on the mesh.
  77229. * This mode makes the mesh edges visible
  77230. * @param epsilon defines the maximal distance between two angles to detect a face
  77231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77232. * @returns the currentAbstractMesh
  77233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77234. */
  77235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77236. /**
  77237. * Gets the edgesRenderer associated with the mesh
  77238. */
  77239. edgesRenderer: Nullable<EdgesRenderer>;
  77240. }
  77241. interface LinesMesh {
  77242. /**
  77243. * Enables the edge rendering mode on the mesh.
  77244. * This mode makes the mesh edges visible
  77245. * @param epsilon defines the maximal distance between two angles to detect a face
  77246. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77247. * @returns the currentAbstractMesh
  77248. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77249. */
  77250. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77251. }
  77252. interface InstancedLinesMesh {
  77253. /**
  77254. * Enables the edge rendering mode on the mesh.
  77255. * This mode makes the mesh edges visible
  77256. * @param epsilon defines the maximal distance between two angles to detect a face
  77257. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77258. * @returns the current InstancedLinesMesh
  77259. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77260. */
  77261. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77262. }
  77263. /**
  77264. * Defines the minimum contract an Edges renderer should follow.
  77265. */
  77266. export interface IEdgesRenderer extends IDisposable {
  77267. /**
  77268. * Gets or sets a boolean indicating if the edgesRenderer is active
  77269. */
  77270. isEnabled: boolean;
  77271. /**
  77272. * Renders the edges of the attached mesh,
  77273. */
  77274. render(): void;
  77275. /**
  77276. * Checks wether or not the edges renderer is ready to render.
  77277. * @return true if ready, otherwise false.
  77278. */
  77279. isReady(): boolean;
  77280. }
  77281. /**
  77282. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77283. */
  77284. export class EdgesRenderer implements IEdgesRenderer {
  77285. /**
  77286. * Define the size of the edges with an orthographic camera
  77287. */
  77288. edgesWidthScalerForOrthographic: number;
  77289. /**
  77290. * Define the size of the edges with a perspective camera
  77291. */
  77292. edgesWidthScalerForPerspective: number;
  77293. protected _source: AbstractMesh;
  77294. protected _linesPositions: number[];
  77295. protected _linesNormals: number[];
  77296. protected _linesIndices: number[];
  77297. protected _epsilon: number;
  77298. protected _indicesCount: number;
  77299. protected _lineShader: ShaderMaterial;
  77300. protected _ib: DataBuffer;
  77301. protected _buffers: {
  77302. [key: string]: Nullable<VertexBuffer>;
  77303. };
  77304. protected _checkVerticesInsteadOfIndices: boolean;
  77305. private _meshRebuildObserver;
  77306. private _meshDisposeObserver;
  77307. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77308. isEnabled: boolean;
  77309. /**
  77310. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77311. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77312. * @param source Mesh used to create edges
  77313. * @param epsilon sum of angles in adjacency to check for edge
  77314. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77315. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77316. */
  77317. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77318. protected _prepareRessources(): void;
  77319. /** @hidden */
  77320. _rebuild(): void;
  77321. /**
  77322. * Releases the required resources for the edges renderer
  77323. */
  77324. dispose(): void;
  77325. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77326. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77327. /**
  77328. * Checks if the pair of p0 and p1 is en edge
  77329. * @param faceIndex
  77330. * @param edge
  77331. * @param faceNormals
  77332. * @param p0
  77333. * @param p1
  77334. * @private
  77335. */
  77336. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77337. /**
  77338. * push line into the position, normal and index buffer
  77339. * @protected
  77340. */
  77341. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77342. /**
  77343. * Generates lines edges from adjacencjes
  77344. * @private
  77345. */
  77346. _generateEdgesLines(): void;
  77347. /**
  77348. * Checks wether or not the edges renderer is ready to render.
  77349. * @return true if ready, otherwise false.
  77350. */
  77351. isReady(): boolean;
  77352. /**
  77353. * Renders the edges of the attached mesh,
  77354. */
  77355. render(): void;
  77356. }
  77357. /**
  77358. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77359. */
  77360. export class LineEdgesRenderer extends EdgesRenderer {
  77361. /**
  77362. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77363. * @param source LineMesh used to generate edges
  77364. * @param epsilon not important (specified angle for edge detection)
  77365. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77366. */
  77367. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77368. /**
  77369. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77370. */
  77371. _generateEdgesLines(): void;
  77372. }
  77373. }
  77374. declare module BABYLON {
  77375. /**
  77376. * This represents the object necessary to create a rendering group.
  77377. * This is exclusively used and created by the rendering manager.
  77378. * To modify the behavior, you use the available helpers in your scene or meshes.
  77379. * @hidden
  77380. */
  77381. export class RenderingGroup {
  77382. index: number;
  77383. private _scene;
  77384. private _opaqueSubMeshes;
  77385. private _transparentSubMeshes;
  77386. private _alphaTestSubMeshes;
  77387. private _depthOnlySubMeshes;
  77388. private _particleSystems;
  77389. private _spriteManagers;
  77390. private _opaqueSortCompareFn;
  77391. private _alphaTestSortCompareFn;
  77392. private _transparentSortCompareFn;
  77393. private _renderOpaque;
  77394. private _renderAlphaTest;
  77395. private _renderTransparent;
  77396. /** @hidden */
  77397. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77398. onBeforeTransparentRendering: () => void;
  77399. /**
  77400. * Set the opaque sort comparison function.
  77401. * If null the sub meshes will be render in the order they were created
  77402. */
  77403. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77404. /**
  77405. * Set the alpha test sort comparison function.
  77406. * If null the sub meshes will be render in the order they were created
  77407. */
  77408. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77409. /**
  77410. * Set the transparent sort comparison function.
  77411. * If null the sub meshes will be render in the order they were created
  77412. */
  77413. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77414. /**
  77415. * Creates a new rendering group.
  77416. * @param index The rendering group index
  77417. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77418. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77419. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77420. */
  77421. 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>);
  77422. /**
  77423. * Render all the sub meshes contained in the group.
  77424. * @param customRenderFunction Used to override the default render behaviour of the group.
  77425. * @returns true if rendered some submeshes.
  77426. */
  77427. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77428. /**
  77429. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77430. * @param subMeshes The submeshes to render
  77431. */
  77432. private renderOpaqueSorted;
  77433. /**
  77434. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77435. * @param subMeshes The submeshes to render
  77436. */
  77437. private renderAlphaTestSorted;
  77438. /**
  77439. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77440. * @param subMeshes The submeshes to render
  77441. */
  77442. private renderTransparentSorted;
  77443. /**
  77444. * Renders the submeshes in a specified order.
  77445. * @param subMeshes The submeshes to sort before render
  77446. * @param sortCompareFn The comparison function use to sort
  77447. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77448. * @param transparent Specifies to activate blending if true
  77449. */
  77450. private static renderSorted;
  77451. /**
  77452. * Renders the submeshes in the order they were dispatched (no sort applied).
  77453. * @param subMeshes The submeshes to render
  77454. */
  77455. private static renderUnsorted;
  77456. /**
  77457. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77458. * are rendered back to front if in the same alpha index.
  77459. *
  77460. * @param a The first submesh
  77461. * @param b The second submesh
  77462. * @returns The result of the comparison
  77463. */
  77464. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77465. /**
  77466. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77467. * are rendered back to front.
  77468. *
  77469. * @param a The first submesh
  77470. * @param b The second submesh
  77471. * @returns The result of the comparison
  77472. */
  77473. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77474. /**
  77475. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77476. * are rendered front to back (prevent overdraw).
  77477. *
  77478. * @param a The first submesh
  77479. * @param b The second submesh
  77480. * @returns The result of the comparison
  77481. */
  77482. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77483. /**
  77484. * Resets the different lists of submeshes to prepare a new frame.
  77485. */
  77486. prepare(): void;
  77487. dispose(): void;
  77488. /**
  77489. * Inserts the submesh in its correct queue depending on its material.
  77490. * @param subMesh The submesh to dispatch
  77491. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77492. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77493. */
  77494. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77495. dispatchSprites(spriteManager: ISpriteManager): void;
  77496. dispatchParticles(particleSystem: IParticleSystem): void;
  77497. private _renderParticles;
  77498. private _renderSprites;
  77499. }
  77500. }
  77501. declare module BABYLON {
  77502. /**
  77503. * Interface describing the different options available in the rendering manager
  77504. * regarding Auto Clear between groups.
  77505. */
  77506. export interface IRenderingManagerAutoClearSetup {
  77507. /**
  77508. * Defines whether or not autoclear is enable.
  77509. */
  77510. autoClear: boolean;
  77511. /**
  77512. * Defines whether or not to autoclear the depth buffer.
  77513. */
  77514. depth: boolean;
  77515. /**
  77516. * Defines whether or not to autoclear the stencil buffer.
  77517. */
  77518. stencil: boolean;
  77519. }
  77520. /**
  77521. * This class is used by the onRenderingGroupObservable
  77522. */
  77523. export class RenderingGroupInfo {
  77524. /**
  77525. * The Scene that being rendered
  77526. */
  77527. scene: Scene;
  77528. /**
  77529. * The camera currently used for the rendering pass
  77530. */
  77531. camera: Nullable<Camera>;
  77532. /**
  77533. * The ID of the renderingGroup being processed
  77534. */
  77535. renderingGroupId: number;
  77536. }
  77537. /**
  77538. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77539. * It is enable to manage the different groups as well as the different necessary sort functions.
  77540. * This should not be used directly aside of the few static configurations
  77541. */
  77542. export class RenderingManager {
  77543. /**
  77544. * The max id used for rendering groups (not included)
  77545. */
  77546. static MAX_RENDERINGGROUPS: number;
  77547. /**
  77548. * The min id used for rendering groups (included)
  77549. */
  77550. static MIN_RENDERINGGROUPS: number;
  77551. /**
  77552. * Used to globally prevent autoclearing scenes.
  77553. */
  77554. static AUTOCLEAR: boolean;
  77555. /**
  77556. * @hidden
  77557. */
  77558. _useSceneAutoClearSetup: boolean;
  77559. private _scene;
  77560. private _renderingGroups;
  77561. private _depthStencilBufferAlreadyCleaned;
  77562. private _autoClearDepthStencil;
  77563. private _customOpaqueSortCompareFn;
  77564. private _customAlphaTestSortCompareFn;
  77565. private _customTransparentSortCompareFn;
  77566. private _renderingGroupInfo;
  77567. /**
  77568. * Instantiates a new rendering group for a particular scene
  77569. * @param scene Defines the scene the groups belongs to
  77570. */
  77571. constructor(scene: Scene);
  77572. private _clearDepthStencilBuffer;
  77573. /**
  77574. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77575. * @hidden
  77576. */
  77577. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77578. /**
  77579. * Resets the different information of the group to prepare a new frame
  77580. * @hidden
  77581. */
  77582. reset(): void;
  77583. /**
  77584. * Dispose and release the group and its associated resources.
  77585. * @hidden
  77586. */
  77587. dispose(): void;
  77588. /**
  77589. * Clear the info related to rendering groups preventing retention points during dispose.
  77590. */
  77591. freeRenderingGroups(): void;
  77592. private _prepareRenderingGroup;
  77593. /**
  77594. * Add a sprite manager to the rendering manager in order to render it this frame.
  77595. * @param spriteManager Define the sprite manager to render
  77596. */
  77597. dispatchSprites(spriteManager: ISpriteManager): void;
  77598. /**
  77599. * Add a particle system to the rendering manager in order to render it this frame.
  77600. * @param particleSystem Define the particle system to render
  77601. */
  77602. dispatchParticles(particleSystem: IParticleSystem): void;
  77603. /**
  77604. * Add a submesh to the manager in order to render it this frame
  77605. * @param subMesh The submesh to dispatch
  77606. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77607. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77608. */
  77609. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77610. /**
  77611. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77612. * This allowed control for front to back rendering or reversly depending of the special needs.
  77613. *
  77614. * @param renderingGroupId The rendering group id corresponding to its index
  77615. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77616. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77617. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77618. */
  77619. 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;
  77620. /**
  77621. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77622. *
  77623. * @param renderingGroupId The rendering group id corresponding to its index
  77624. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77625. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77626. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77627. */
  77628. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77629. /**
  77630. * Gets the current auto clear configuration for one rendering group of the rendering
  77631. * manager.
  77632. * @param index the rendering group index to get the information for
  77633. * @returns The auto clear setup for the requested rendering group
  77634. */
  77635. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77636. }
  77637. }
  77638. declare module BABYLON {
  77639. /**
  77640. * This Helps creating a texture that will be created from a camera in your scene.
  77641. * It is basically a dynamic texture that could be used to create special effects for instance.
  77642. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77643. */
  77644. export class RenderTargetTexture extends Texture {
  77645. isCube: boolean;
  77646. /**
  77647. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77648. */
  77649. static readonly REFRESHRATE_RENDER_ONCE: number;
  77650. /**
  77651. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77652. */
  77653. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77654. /**
  77655. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77656. * the central point of your effect and can save a lot of performances.
  77657. */
  77658. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77659. /**
  77660. * Use this predicate to dynamically define the list of mesh you want to render.
  77661. * If set, the renderList property will be overwritten.
  77662. */
  77663. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77664. private _renderList;
  77665. /**
  77666. * Use this list to define the list of mesh you want to render.
  77667. */
  77668. renderList: Nullable<Array<AbstractMesh>>;
  77669. private _hookArray;
  77670. /**
  77671. * Define if particles should be rendered in your texture.
  77672. */
  77673. renderParticles: boolean;
  77674. /**
  77675. * Define if sprites should be rendered in your texture.
  77676. */
  77677. renderSprites: boolean;
  77678. /**
  77679. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77680. */
  77681. coordinatesMode: number;
  77682. /**
  77683. * Define the camera used to render the texture.
  77684. */
  77685. activeCamera: Nullable<Camera>;
  77686. /**
  77687. * Override the render function of the texture with your own one.
  77688. */
  77689. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77690. /**
  77691. * Define if camera post processes should be use while rendering the texture.
  77692. */
  77693. useCameraPostProcesses: boolean;
  77694. /**
  77695. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77696. */
  77697. ignoreCameraViewport: boolean;
  77698. private _postProcessManager;
  77699. private _postProcesses;
  77700. private _resizeObserver;
  77701. /**
  77702. * An event triggered when the texture is unbind.
  77703. */
  77704. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77705. /**
  77706. * An event triggered when the texture is unbind.
  77707. */
  77708. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77709. private _onAfterUnbindObserver;
  77710. /**
  77711. * Set a after unbind callback in the texture.
  77712. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77713. */
  77714. onAfterUnbind: () => void;
  77715. /**
  77716. * An event triggered before rendering the texture
  77717. */
  77718. onBeforeRenderObservable: Observable<number>;
  77719. private _onBeforeRenderObserver;
  77720. /**
  77721. * Set a before render callback in the texture.
  77722. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77723. */
  77724. onBeforeRender: (faceIndex: number) => void;
  77725. /**
  77726. * An event triggered after rendering the texture
  77727. */
  77728. onAfterRenderObservable: Observable<number>;
  77729. private _onAfterRenderObserver;
  77730. /**
  77731. * Set a after render callback in the texture.
  77732. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77733. */
  77734. onAfterRender: (faceIndex: number) => void;
  77735. /**
  77736. * An event triggered after the texture clear
  77737. */
  77738. onClearObservable: Observable<Engine>;
  77739. private _onClearObserver;
  77740. /**
  77741. * Set a clear callback in the texture.
  77742. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77743. */
  77744. onClear: (Engine: Engine) => void;
  77745. /**
  77746. * Define the clear color of the Render Target if it should be different from the scene.
  77747. */
  77748. clearColor: Color4;
  77749. protected _size: number | {
  77750. width: number;
  77751. height: number;
  77752. };
  77753. protected _initialSizeParameter: number | {
  77754. width: number;
  77755. height: number;
  77756. } | {
  77757. ratio: number;
  77758. };
  77759. protected _sizeRatio: Nullable<number>;
  77760. /** @hidden */
  77761. _generateMipMaps: boolean;
  77762. protected _renderingManager: RenderingManager;
  77763. /** @hidden */
  77764. _waitingRenderList: string[];
  77765. protected _doNotChangeAspectRatio: boolean;
  77766. protected _currentRefreshId: number;
  77767. protected _refreshRate: number;
  77768. protected _textureMatrix: Matrix;
  77769. protected _samples: number;
  77770. protected _renderTargetOptions: RenderTargetCreationOptions;
  77771. /**
  77772. * Gets render target creation options that were used.
  77773. */
  77774. readonly renderTargetOptions: RenderTargetCreationOptions;
  77775. protected _engine: Engine;
  77776. protected _onRatioRescale(): void;
  77777. /**
  77778. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77779. * It must define where the camera used to render the texture is set
  77780. */
  77781. boundingBoxPosition: Vector3;
  77782. private _boundingBoxSize;
  77783. /**
  77784. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77785. * When defined, the cubemap will switch to local mode
  77786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77787. * @example https://www.babylonjs-playground.com/#RNASML
  77788. */
  77789. boundingBoxSize: Vector3;
  77790. /**
  77791. * In case the RTT has been created with a depth texture, get the associated
  77792. * depth texture.
  77793. * Otherwise, return null.
  77794. */
  77795. depthStencilTexture: Nullable<InternalTexture>;
  77796. /**
  77797. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77798. * or used a shadow, depth texture...
  77799. * @param name The friendly name of the texture
  77800. * @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)
  77801. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77802. * @param generateMipMaps True if mip maps need to be generated after render.
  77803. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77804. * @param type The type of the buffer in the RTT (int, half float, float...)
  77805. * @param isCube True if a cube texture needs to be created
  77806. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77807. * @param generateDepthBuffer True to generate a depth buffer
  77808. * @param generateStencilBuffer True to generate a stencil buffer
  77809. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77810. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77811. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77812. */
  77813. constructor(name: string, size: number | {
  77814. width: number;
  77815. height: number;
  77816. } | {
  77817. ratio: number;
  77818. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77819. /**
  77820. * Creates a depth stencil texture.
  77821. * This is only available in WebGL 2 or with the depth texture extension available.
  77822. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77823. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77824. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77825. */
  77826. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77827. private _processSizeParameter;
  77828. /**
  77829. * Define the number of samples to use in case of MSAA.
  77830. * It defaults to one meaning no MSAA has been enabled.
  77831. */
  77832. samples: number;
  77833. /**
  77834. * Resets the refresh counter of the texture and start bak from scratch.
  77835. * Could be useful to regenerate the texture if it is setup to render only once.
  77836. */
  77837. resetRefreshCounter(): void;
  77838. /**
  77839. * Define the refresh rate of the texture or the rendering frequency.
  77840. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77841. */
  77842. refreshRate: number;
  77843. /**
  77844. * Adds a post process to the render target rendering passes.
  77845. * @param postProcess define the post process to add
  77846. */
  77847. addPostProcess(postProcess: PostProcess): void;
  77848. /**
  77849. * Clear all the post processes attached to the render target
  77850. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77851. */
  77852. clearPostProcesses(dispose?: boolean): void;
  77853. /**
  77854. * Remove one of the post process from the list of attached post processes to the texture
  77855. * @param postProcess define the post process to remove from the list
  77856. */
  77857. removePostProcess(postProcess: PostProcess): void;
  77858. /** @hidden */
  77859. _shouldRender(): boolean;
  77860. /**
  77861. * Gets the actual render size of the texture.
  77862. * @returns the width of the render size
  77863. */
  77864. getRenderSize(): number;
  77865. /**
  77866. * Gets the actual render width of the texture.
  77867. * @returns the width of the render size
  77868. */
  77869. getRenderWidth(): number;
  77870. /**
  77871. * Gets the actual render height of the texture.
  77872. * @returns the height of the render size
  77873. */
  77874. getRenderHeight(): number;
  77875. /**
  77876. * Get if the texture can be rescaled or not.
  77877. */
  77878. readonly canRescale: boolean;
  77879. /**
  77880. * Resize the texture using a ratio.
  77881. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77882. */
  77883. scale(ratio: number): void;
  77884. /**
  77885. * Get the texture reflection matrix used to rotate/transform the reflection.
  77886. * @returns the reflection matrix
  77887. */
  77888. getReflectionTextureMatrix(): Matrix;
  77889. /**
  77890. * Resize the texture to a new desired size.
  77891. * Be carrefull as it will recreate all the data in the new texture.
  77892. * @param size Define the new size. It can be:
  77893. * - a number for squared texture,
  77894. * - an object containing { width: number, height: number }
  77895. * - or an object containing a ratio { ratio: number }
  77896. */
  77897. resize(size: number | {
  77898. width: number;
  77899. height: number;
  77900. } | {
  77901. ratio: number;
  77902. }): void;
  77903. /**
  77904. * Renders all the objects from the render list into the texture.
  77905. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77906. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77907. */
  77908. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77909. private _bestReflectionRenderTargetDimension;
  77910. /**
  77911. * @hidden
  77912. * @param faceIndex face index to bind to if this is a cubetexture
  77913. */
  77914. _bindFrameBuffer(faceIndex?: number): void;
  77915. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77916. private renderToTarget;
  77917. /**
  77918. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77919. * This allowed control for front to back rendering or reversly depending of the special needs.
  77920. *
  77921. * @param renderingGroupId The rendering group id corresponding to its index
  77922. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77923. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77924. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77925. */
  77926. 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;
  77927. /**
  77928. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77929. *
  77930. * @param renderingGroupId The rendering group id corresponding to its index
  77931. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77932. */
  77933. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77934. /**
  77935. * Clones the texture.
  77936. * @returns the cloned texture
  77937. */
  77938. clone(): RenderTargetTexture;
  77939. /**
  77940. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77941. * @returns The JSON representation of the texture
  77942. */
  77943. serialize(): any;
  77944. /**
  77945. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77946. */
  77947. disposeFramebufferObjects(): void;
  77948. /**
  77949. * Dispose the texture and release its associated resources.
  77950. */
  77951. dispose(): void;
  77952. /** @hidden */
  77953. _rebuild(): void;
  77954. /**
  77955. * Clear the info related to rendering groups preventing retention point in material dispose.
  77956. */
  77957. freeRenderingGroups(): void;
  77958. /**
  77959. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77960. * @returns the view count
  77961. */
  77962. getViewCount(): number;
  77963. }
  77964. }
  77965. declare module BABYLON {
  77966. /**
  77967. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77968. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77969. * You can then easily use it as a reflectionTexture on a flat surface.
  77970. * In case the surface is not a plane, please consider relying on reflection probes.
  77971. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77972. */
  77973. export class MirrorTexture extends RenderTargetTexture {
  77974. private scene;
  77975. /**
  77976. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77977. * 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.
  77978. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77979. */
  77980. mirrorPlane: Plane;
  77981. /**
  77982. * Define the blur ratio used to blur the reflection if needed.
  77983. */
  77984. blurRatio: number;
  77985. /**
  77986. * Define the adaptive blur kernel used to blur the reflection if needed.
  77987. * This will autocompute the closest best match for the `blurKernel`
  77988. */
  77989. adaptiveBlurKernel: number;
  77990. /**
  77991. * Define the blur kernel used to blur the reflection if needed.
  77992. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77993. */
  77994. blurKernel: number;
  77995. /**
  77996. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77997. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77998. */
  77999. blurKernelX: number;
  78000. /**
  78001. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78002. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78003. */
  78004. blurKernelY: number;
  78005. private _autoComputeBlurKernel;
  78006. protected _onRatioRescale(): void;
  78007. private _updateGammaSpace;
  78008. private _imageProcessingConfigChangeObserver;
  78009. private _transformMatrix;
  78010. private _mirrorMatrix;
  78011. private _savedViewMatrix;
  78012. private _blurX;
  78013. private _blurY;
  78014. private _adaptiveBlurKernel;
  78015. private _blurKernelX;
  78016. private _blurKernelY;
  78017. private _blurRatio;
  78018. /**
  78019. * Instantiates a Mirror Texture.
  78020. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78021. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78022. * You can then easily use it as a reflectionTexture on a flat surface.
  78023. * In case the surface is not a plane, please consider relying on reflection probes.
  78024. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78025. * @param name
  78026. * @param size
  78027. * @param scene
  78028. * @param generateMipMaps
  78029. * @param type
  78030. * @param samplingMode
  78031. * @param generateDepthBuffer
  78032. */
  78033. constructor(name: string, size: number | {
  78034. width: number;
  78035. height: number;
  78036. } | {
  78037. ratio: number;
  78038. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78039. private _preparePostProcesses;
  78040. /**
  78041. * Clone the mirror texture.
  78042. * @returns the cloned texture
  78043. */
  78044. clone(): MirrorTexture;
  78045. /**
  78046. * Serialize the texture to a JSON representation you could use in Parse later on
  78047. * @returns the serialized JSON representation
  78048. */
  78049. serialize(): any;
  78050. /**
  78051. * Dispose the texture and release its associated resources.
  78052. */
  78053. dispose(): void;
  78054. }
  78055. }
  78056. declare module BABYLON {
  78057. /**
  78058. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78059. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78060. */
  78061. export class Texture extends BaseTexture {
  78062. /** @hidden */
  78063. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78064. /** @hidden */
  78065. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78066. /** @hidden */
  78067. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78068. /** nearest is mag = nearest and min = nearest and mip = linear */
  78069. static readonly NEAREST_SAMPLINGMODE: number;
  78070. /** nearest is mag = nearest and min = nearest and mip = linear */
  78071. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78072. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78073. static readonly BILINEAR_SAMPLINGMODE: number;
  78074. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78075. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78076. /** Trilinear is mag = linear and min = linear and mip = linear */
  78077. static readonly TRILINEAR_SAMPLINGMODE: number;
  78078. /** Trilinear is mag = linear and min = linear and mip = linear */
  78079. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78080. /** mag = nearest and min = nearest and mip = nearest */
  78081. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78082. /** mag = nearest and min = linear and mip = nearest */
  78083. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78084. /** mag = nearest and min = linear and mip = linear */
  78085. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78086. /** mag = nearest and min = linear and mip = none */
  78087. static readonly NEAREST_LINEAR: number;
  78088. /** mag = nearest and min = nearest and mip = none */
  78089. static readonly NEAREST_NEAREST: number;
  78090. /** mag = linear and min = nearest and mip = nearest */
  78091. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78092. /** mag = linear and min = nearest and mip = linear */
  78093. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78094. /** mag = linear and min = linear and mip = none */
  78095. static readonly LINEAR_LINEAR: number;
  78096. /** mag = linear and min = nearest and mip = none */
  78097. static readonly LINEAR_NEAREST: number;
  78098. /** Explicit coordinates mode */
  78099. static readonly EXPLICIT_MODE: number;
  78100. /** Spherical coordinates mode */
  78101. static readonly SPHERICAL_MODE: number;
  78102. /** Planar coordinates mode */
  78103. static readonly PLANAR_MODE: number;
  78104. /** Cubic coordinates mode */
  78105. static readonly CUBIC_MODE: number;
  78106. /** Projection coordinates mode */
  78107. static readonly PROJECTION_MODE: number;
  78108. /** Inverse Cubic coordinates mode */
  78109. static readonly SKYBOX_MODE: number;
  78110. /** Inverse Cubic coordinates mode */
  78111. static readonly INVCUBIC_MODE: number;
  78112. /** Equirectangular coordinates mode */
  78113. static readonly EQUIRECTANGULAR_MODE: number;
  78114. /** Equirectangular Fixed coordinates mode */
  78115. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78116. /** Equirectangular Fixed Mirrored coordinates mode */
  78117. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78118. /** Texture is not repeating outside of 0..1 UVs */
  78119. static readonly CLAMP_ADDRESSMODE: number;
  78120. /** Texture is repeating outside of 0..1 UVs */
  78121. static readonly WRAP_ADDRESSMODE: number;
  78122. /** Texture is repeating and mirrored */
  78123. static readonly MIRROR_ADDRESSMODE: number;
  78124. /**
  78125. * 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
  78126. */
  78127. static UseSerializedUrlIfAny: boolean;
  78128. /**
  78129. * Define the url of the texture.
  78130. */
  78131. url: Nullable<string>;
  78132. /**
  78133. * Define an offset on the texture to offset the u coordinates of the UVs
  78134. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78135. */
  78136. uOffset: number;
  78137. /**
  78138. * Define an offset on the texture to offset the v coordinates of the UVs
  78139. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78140. */
  78141. vOffset: number;
  78142. /**
  78143. * Define an offset on the texture to scale the u coordinates of the UVs
  78144. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78145. */
  78146. uScale: number;
  78147. /**
  78148. * Define an offset on the texture to scale the v coordinates of the UVs
  78149. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78150. */
  78151. vScale: number;
  78152. /**
  78153. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78154. * @see http://doc.babylonjs.com/how_to/more_materials
  78155. */
  78156. uAng: number;
  78157. /**
  78158. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78159. * @see http://doc.babylonjs.com/how_to/more_materials
  78160. */
  78161. vAng: number;
  78162. /**
  78163. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78164. * @see http://doc.babylonjs.com/how_to/more_materials
  78165. */
  78166. wAng: number;
  78167. /**
  78168. * Defines the center of rotation (U)
  78169. */
  78170. uRotationCenter: number;
  78171. /**
  78172. * Defines the center of rotation (V)
  78173. */
  78174. vRotationCenter: number;
  78175. /**
  78176. * Defines the center of rotation (W)
  78177. */
  78178. wRotationCenter: number;
  78179. /**
  78180. * Are mip maps generated for this texture or not.
  78181. */
  78182. readonly noMipmap: boolean;
  78183. /**
  78184. * List of inspectable custom properties (used by the Inspector)
  78185. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78186. */
  78187. inspectableCustomProperties: Nullable<IInspectable[]>;
  78188. private _noMipmap;
  78189. /** @hidden */
  78190. _invertY: boolean;
  78191. private _rowGenerationMatrix;
  78192. private _cachedTextureMatrix;
  78193. private _projectionModeMatrix;
  78194. private _t0;
  78195. private _t1;
  78196. private _t2;
  78197. private _cachedUOffset;
  78198. private _cachedVOffset;
  78199. private _cachedUScale;
  78200. private _cachedVScale;
  78201. private _cachedUAng;
  78202. private _cachedVAng;
  78203. private _cachedWAng;
  78204. private _cachedProjectionMatrixId;
  78205. private _cachedCoordinatesMode;
  78206. /** @hidden */
  78207. protected _initialSamplingMode: number;
  78208. /** @hidden */
  78209. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78210. private _deleteBuffer;
  78211. protected _format: Nullable<number>;
  78212. private _delayedOnLoad;
  78213. private _delayedOnError;
  78214. /**
  78215. * Observable triggered once the texture has been loaded.
  78216. */
  78217. onLoadObservable: Observable<Texture>;
  78218. protected _isBlocking: boolean;
  78219. /**
  78220. * Is the texture preventing material to render while loading.
  78221. * If false, a default texture will be used instead of the loading one during the preparation step.
  78222. */
  78223. isBlocking: boolean;
  78224. /**
  78225. * Get the current sampling mode associated with the texture.
  78226. */
  78227. readonly samplingMode: number;
  78228. /**
  78229. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78230. */
  78231. readonly invertY: boolean;
  78232. /**
  78233. * Instantiates a new texture.
  78234. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78235. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78236. * @param url define the url of the picture to load as a texture
  78237. * @param scene define the scene the texture will belong to
  78238. * @param noMipmap define if the texture will require mip maps or not
  78239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78241. * @param onLoad define a callback triggered when the texture has been loaded
  78242. * @param onError define a callback triggered when an error occurred during the loading session
  78243. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78244. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78245. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78246. */
  78247. 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);
  78248. /**
  78249. * Update the url (and optional buffer) of this texture if url was null during construction.
  78250. * @param url the url of the texture
  78251. * @param buffer the buffer of the texture (defaults to null)
  78252. * @param onLoad callback called when the texture is loaded (defaults to null)
  78253. */
  78254. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78255. /**
  78256. * Finish the loading sequence of a texture flagged as delayed load.
  78257. * @hidden
  78258. */
  78259. delayLoad(): void;
  78260. private _prepareRowForTextureGeneration;
  78261. /**
  78262. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78263. * @returns the transform matrix of the texture.
  78264. */
  78265. getTextureMatrix(): Matrix;
  78266. /**
  78267. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78268. * @returns The reflection texture transform
  78269. */
  78270. getReflectionTextureMatrix(): Matrix;
  78271. /**
  78272. * Clones the texture.
  78273. * @returns the cloned texture
  78274. */
  78275. clone(): Texture;
  78276. /**
  78277. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78278. * @returns The JSON representation of the texture
  78279. */
  78280. serialize(): any;
  78281. /**
  78282. * Get the current class name of the texture useful for serialization or dynamic coding.
  78283. * @returns "Texture"
  78284. */
  78285. getClassName(): string;
  78286. /**
  78287. * Dispose the texture and release its associated resources.
  78288. */
  78289. dispose(): void;
  78290. /**
  78291. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78292. * @param parsedTexture Define the JSON representation of the texture
  78293. * @param scene Define the scene the parsed texture should be instantiated in
  78294. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78295. * @returns The parsed texture if successful
  78296. */
  78297. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78298. /**
  78299. * Creates a texture from its base 64 representation.
  78300. * @param data Define the base64 payload without the data: prefix
  78301. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78302. * @param scene Define the scene the texture should belong to
  78303. * @param noMipmap Forces the texture to not create mip map information if true
  78304. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78305. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78306. * @param onLoad define a callback triggered when the texture has been loaded
  78307. * @param onError define a callback triggered when an error occurred during the loading session
  78308. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78309. * @returns the created texture
  78310. */
  78311. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78312. /**
  78313. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78314. * @param data Define the base64 payload without the data: prefix
  78315. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78316. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78317. * @param scene Define the scene the texture should belong to
  78318. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78319. * @param noMipmap Forces the texture to not create mip map information if true
  78320. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78321. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78322. * @param onLoad define a callback triggered when the texture has been loaded
  78323. * @param onError define a callback triggered when an error occurred during the loading session
  78324. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78325. * @returns the created texture
  78326. */
  78327. 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;
  78328. }
  78329. }
  78330. declare module BABYLON {
  78331. interface Engine {
  78332. /**
  78333. * Creates a raw texture
  78334. * @param data defines the data to store in the texture
  78335. * @param width defines the width of the texture
  78336. * @param height defines the height of the texture
  78337. * @param format defines the format of the data
  78338. * @param generateMipMaps defines if the engine should generate the mip levels
  78339. * @param invertY defines if data must be stored with Y axis inverted
  78340. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78341. * @param compression defines the compression used (null by default)
  78342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78343. * @returns the raw texture inside an InternalTexture
  78344. */
  78345. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78346. /**
  78347. * Update a raw texture
  78348. * @param texture defines the texture to update
  78349. * @param data defines the data to store in the texture
  78350. * @param format defines the format of the data
  78351. * @param invertY defines if data must be stored with Y axis inverted
  78352. */
  78353. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78354. /**
  78355. * Update a raw texture
  78356. * @param texture defines the texture to update
  78357. * @param data defines the data to store in the texture
  78358. * @param format defines the format of the data
  78359. * @param invertY defines if data must be stored with Y axis inverted
  78360. * @param compression defines the compression used (null by default)
  78361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78362. */
  78363. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78364. /**
  78365. * Creates a new raw cube texture
  78366. * @param data defines the array of data to use to create each face
  78367. * @param size defines the size of the textures
  78368. * @param format defines the format of the data
  78369. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78370. * @param generateMipMaps defines if the engine should generate the mip levels
  78371. * @param invertY defines if data must be stored with Y axis inverted
  78372. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78373. * @param compression defines the compression used (null by default)
  78374. * @returns the cube texture as an InternalTexture
  78375. */
  78376. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78377. /**
  78378. * Update a raw cube texture
  78379. * @param texture defines the texture to udpdate
  78380. * @param data defines the data to store
  78381. * @param format defines the data format
  78382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78383. * @param invertY defines if data must be stored with Y axis inverted
  78384. */
  78385. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78386. /**
  78387. * Update a raw cube texture
  78388. * @param texture defines the texture to udpdate
  78389. * @param data defines the data to store
  78390. * @param format defines the data format
  78391. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78392. * @param invertY defines if data must be stored with Y axis inverted
  78393. * @param compression defines the compression used (null by default)
  78394. */
  78395. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78396. /**
  78397. * Update a raw cube texture
  78398. * @param texture defines the texture to udpdate
  78399. * @param data defines the data to store
  78400. * @param format defines the data format
  78401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78402. * @param invertY defines if data must be stored with Y axis inverted
  78403. * @param compression defines the compression used (null by default)
  78404. * @param level defines which level of the texture to update
  78405. */
  78406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78407. /**
  78408. * Creates a new raw cube texture from a specified url
  78409. * @param url defines the url where the data is located
  78410. * @param scene defines the current scene
  78411. * @param size defines the size of the textures
  78412. * @param format defines the format of the data
  78413. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78414. * @param noMipmap defines if the engine should avoid generating the mip levels
  78415. * @param callback defines a callback used to extract texture data from loaded data
  78416. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78417. * @param onLoad defines a callback called when texture is loaded
  78418. * @param onError defines a callback called if there is an error
  78419. * @returns the cube texture as an InternalTexture
  78420. */
  78421. 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;
  78422. /**
  78423. * Creates a new raw cube texture from a specified url
  78424. * @param url defines the url where the data is located
  78425. * @param scene defines the current scene
  78426. * @param size defines the size of the textures
  78427. * @param format defines the format of the data
  78428. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78429. * @param noMipmap defines if the engine should avoid generating the mip levels
  78430. * @param callback defines a callback used to extract texture data from loaded data
  78431. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78432. * @param onLoad defines a callback called when texture is loaded
  78433. * @param onError defines a callback called if there is an error
  78434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78435. * @param invertY defines if data must be stored with Y axis inverted
  78436. * @returns the cube texture as an InternalTexture
  78437. */
  78438. 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;
  78439. /**
  78440. * Creates a new raw 3D texture
  78441. * @param data defines the data used to create the texture
  78442. * @param width defines the width of the texture
  78443. * @param height defines the height of the texture
  78444. * @param depth defines the depth of the texture
  78445. * @param format defines the format of the texture
  78446. * @param generateMipMaps defines if the engine must generate mip levels
  78447. * @param invertY defines if data must be stored with Y axis inverted
  78448. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78449. * @param compression defines the compressed used (can be null)
  78450. * @param textureType defines the compressed used (can be null)
  78451. * @returns a new raw 3D texture (stored in an InternalTexture)
  78452. */
  78453. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78454. /**
  78455. * Update a raw 3D texture
  78456. * @param texture defines the texture to update
  78457. * @param data defines the data to store
  78458. * @param format defines the data format
  78459. * @param invertY defines if data must be stored with Y axis inverted
  78460. */
  78461. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78462. /**
  78463. * Update a raw 3D texture
  78464. * @param texture defines the texture to update
  78465. * @param data defines the data to store
  78466. * @param format defines the data format
  78467. * @param invertY defines if data must be stored with Y axis inverted
  78468. * @param compression defines the used compression (can be null)
  78469. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78470. */
  78471. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78472. }
  78473. }
  78474. declare module BABYLON {
  78475. /**
  78476. * Raw texture can help creating a texture directly from an array of data.
  78477. * This can be super useful if you either get the data from an uncompressed source or
  78478. * if you wish to create your texture pixel by pixel.
  78479. */
  78480. export class RawTexture extends Texture {
  78481. /**
  78482. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78483. */
  78484. format: number;
  78485. private _engine;
  78486. /**
  78487. * Instantiates a new RawTexture.
  78488. * Raw texture can help creating a texture directly from an array of data.
  78489. * This can be super useful if you either get the data from an uncompressed source or
  78490. * if you wish to create your texture pixel by pixel.
  78491. * @param data define the array of data to use to create the texture
  78492. * @param width define the width of the texture
  78493. * @param height define the height of the texture
  78494. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78495. * @param scene define the scene the texture belongs to
  78496. * @param generateMipMaps define whether mip maps should be generated or not
  78497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78499. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78500. */
  78501. constructor(data: ArrayBufferView, width: number, height: number,
  78502. /**
  78503. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78504. */
  78505. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78506. /**
  78507. * Updates the texture underlying data.
  78508. * @param data Define the new data of the texture
  78509. */
  78510. update(data: ArrayBufferView): void;
  78511. /**
  78512. * Creates a luminance texture from some data.
  78513. * @param data Define the texture data
  78514. * @param width Define the width of the texture
  78515. * @param height Define the height of the texture
  78516. * @param scene Define the scene the texture belongs to
  78517. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78518. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78519. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78520. * @returns the luminance texture
  78521. */
  78522. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78523. /**
  78524. * Creates a luminance alpha texture from some data.
  78525. * @param data Define the texture data
  78526. * @param width Define the width of the texture
  78527. * @param height Define the height of the texture
  78528. * @param scene Define the scene the texture belongs to
  78529. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78530. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78531. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78532. * @returns the luminance alpha texture
  78533. */
  78534. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78535. /**
  78536. * Creates an alpha texture from some data.
  78537. * @param data Define the texture data
  78538. * @param width Define the width of the texture
  78539. * @param height Define the height of the texture
  78540. * @param scene Define the scene the texture belongs to
  78541. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78542. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78543. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78544. * @returns the alpha texture
  78545. */
  78546. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78547. /**
  78548. * Creates a RGB texture from some data.
  78549. * @param data Define the texture data
  78550. * @param width Define the width of the texture
  78551. * @param height Define the height of the texture
  78552. * @param scene Define the scene the texture belongs to
  78553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78556. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78557. * @returns the RGB alpha texture
  78558. */
  78559. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78560. /**
  78561. * Creates a RGBA texture from some data.
  78562. * @param data Define the texture data
  78563. * @param width Define the width of the texture
  78564. * @param height Define the height of the texture
  78565. * @param scene Define the scene the texture belongs to
  78566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78570. * @returns the RGBA texture
  78571. */
  78572. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78573. /**
  78574. * Creates a R texture from some data.
  78575. * @param data Define the texture data
  78576. * @param width Define the width of the texture
  78577. * @param height Define the height of the texture
  78578. * @param scene Define the scene the texture belongs to
  78579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78583. * @returns the R texture
  78584. */
  78585. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78586. }
  78587. }
  78588. declare module BABYLON {
  78589. /**
  78590. * Defines a runtime animation
  78591. */
  78592. export class RuntimeAnimation {
  78593. private _events;
  78594. /**
  78595. * The current frame of the runtime animation
  78596. */
  78597. private _currentFrame;
  78598. /**
  78599. * The animation used by the runtime animation
  78600. */
  78601. private _animation;
  78602. /**
  78603. * The target of the runtime animation
  78604. */
  78605. private _target;
  78606. /**
  78607. * The initiating animatable
  78608. */
  78609. private _host;
  78610. /**
  78611. * The original value of the runtime animation
  78612. */
  78613. private _originalValue;
  78614. /**
  78615. * The original blend value of the runtime animation
  78616. */
  78617. private _originalBlendValue;
  78618. /**
  78619. * The offsets cache of the runtime animation
  78620. */
  78621. private _offsetsCache;
  78622. /**
  78623. * The high limits cache of the runtime animation
  78624. */
  78625. private _highLimitsCache;
  78626. /**
  78627. * Specifies if the runtime animation has been stopped
  78628. */
  78629. private _stopped;
  78630. /**
  78631. * The blending factor of the runtime animation
  78632. */
  78633. private _blendingFactor;
  78634. /**
  78635. * The BabylonJS scene
  78636. */
  78637. private _scene;
  78638. /**
  78639. * The current value of the runtime animation
  78640. */
  78641. private _currentValue;
  78642. /** @hidden */
  78643. _animationState: _IAnimationState;
  78644. /**
  78645. * The active target of the runtime animation
  78646. */
  78647. private _activeTargets;
  78648. private _currentActiveTarget;
  78649. private _directTarget;
  78650. /**
  78651. * The target path of the runtime animation
  78652. */
  78653. private _targetPath;
  78654. /**
  78655. * The weight of the runtime animation
  78656. */
  78657. private _weight;
  78658. /**
  78659. * The ratio offset of the runtime animation
  78660. */
  78661. private _ratioOffset;
  78662. /**
  78663. * The previous delay of the runtime animation
  78664. */
  78665. private _previousDelay;
  78666. /**
  78667. * The previous ratio of the runtime animation
  78668. */
  78669. private _previousRatio;
  78670. private _enableBlending;
  78671. private _keys;
  78672. private _minFrame;
  78673. private _maxFrame;
  78674. private _minValue;
  78675. private _maxValue;
  78676. private _targetIsArray;
  78677. /**
  78678. * Gets the current frame of the runtime animation
  78679. */
  78680. readonly currentFrame: number;
  78681. /**
  78682. * Gets the weight of the runtime animation
  78683. */
  78684. readonly weight: number;
  78685. /**
  78686. * Gets the current value of the runtime animation
  78687. */
  78688. readonly currentValue: any;
  78689. /**
  78690. * Gets the target path of the runtime animation
  78691. */
  78692. readonly targetPath: string;
  78693. /**
  78694. * Gets the actual target of the runtime animation
  78695. */
  78696. readonly target: any;
  78697. /** @hidden */
  78698. _onLoop: () => void;
  78699. /**
  78700. * Create a new RuntimeAnimation object
  78701. * @param target defines the target of the animation
  78702. * @param animation defines the source animation object
  78703. * @param scene defines the hosting scene
  78704. * @param host defines the initiating Animatable
  78705. */
  78706. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78707. private _preparePath;
  78708. /**
  78709. * Gets the animation from the runtime animation
  78710. */
  78711. readonly animation: Animation;
  78712. /**
  78713. * Resets the runtime animation to the beginning
  78714. * @param restoreOriginal defines whether to restore the target property to the original value
  78715. */
  78716. reset(restoreOriginal?: boolean): void;
  78717. /**
  78718. * Specifies if the runtime animation is stopped
  78719. * @returns Boolean specifying if the runtime animation is stopped
  78720. */
  78721. isStopped(): boolean;
  78722. /**
  78723. * Disposes of the runtime animation
  78724. */
  78725. dispose(): void;
  78726. /**
  78727. * Apply the interpolated value to the target
  78728. * @param currentValue defines the value computed by the animation
  78729. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78730. */
  78731. setValue(currentValue: any, weight: number): void;
  78732. private _getOriginalValues;
  78733. private _setValue;
  78734. /**
  78735. * Gets the loop pmode of the runtime animation
  78736. * @returns Loop Mode
  78737. */
  78738. private _getCorrectLoopMode;
  78739. /**
  78740. * Move the current animation to a given frame
  78741. * @param frame defines the frame to move to
  78742. */
  78743. goToFrame(frame: number): void;
  78744. /**
  78745. * @hidden Internal use only
  78746. */
  78747. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78748. /**
  78749. * Execute the current animation
  78750. * @param delay defines the delay to add to the current frame
  78751. * @param from defines the lower bound of the animation range
  78752. * @param to defines the upper bound of the animation range
  78753. * @param loop defines if the current animation must loop
  78754. * @param speedRatio defines the current speed ratio
  78755. * @param weight defines the weight of the animation (default is -1 so no weight)
  78756. * @param onLoop optional callback called when animation loops
  78757. * @returns a boolean indicating if the animation is running
  78758. */
  78759. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78760. }
  78761. }
  78762. declare module BABYLON {
  78763. /**
  78764. * Class used to store an actual running animation
  78765. */
  78766. export class Animatable {
  78767. /** defines the target object */
  78768. target: any;
  78769. /** defines the starting frame number (default is 0) */
  78770. fromFrame: number;
  78771. /** defines the ending frame number (default is 100) */
  78772. toFrame: number;
  78773. /** defines if the animation must loop (default is false) */
  78774. loopAnimation: boolean;
  78775. /** defines a callback to call when animation ends if it is not looping */
  78776. onAnimationEnd?: (() => void) | null | undefined;
  78777. /** defines a callback to call when animation loops */
  78778. onAnimationLoop?: (() => void) | null | undefined;
  78779. private _localDelayOffset;
  78780. private _pausedDelay;
  78781. private _runtimeAnimations;
  78782. private _paused;
  78783. private _scene;
  78784. private _speedRatio;
  78785. private _weight;
  78786. private _syncRoot;
  78787. /**
  78788. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78789. * This will only apply for non looping animation (default is true)
  78790. */
  78791. disposeOnEnd: boolean;
  78792. /**
  78793. * Gets a boolean indicating if the animation has started
  78794. */
  78795. animationStarted: boolean;
  78796. /**
  78797. * Observer raised when the animation ends
  78798. */
  78799. onAnimationEndObservable: Observable<Animatable>;
  78800. /**
  78801. * Observer raised when the animation loops
  78802. */
  78803. onAnimationLoopObservable: Observable<Animatable>;
  78804. /**
  78805. * Gets the root Animatable used to synchronize and normalize animations
  78806. */
  78807. readonly syncRoot: Nullable<Animatable>;
  78808. /**
  78809. * Gets the current frame of the first RuntimeAnimation
  78810. * Used to synchronize Animatables
  78811. */
  78812. readonly masterFrame: number;
  78813. /**
  78814. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78815. */
  78816. weight: number;
  78817. /**
  78818. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78819. */
  78820. speedRatio: number;
  78821. /**
  78822. * Creates a new Animatable
  78823. * @param scene defines the hosting scene
  78824. * @param target defines the target object
  78825. * @param fromFrame defines the starting frame number (default is 0)
  78826. * @param toFrame defines the ending frame number (default is 100)
  78827. * @param loopAnimation defines if the animation must loop (default is false)
  78828. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78829. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78830. * @param animations defines a group of animation to add to the new Animatable
  78831. * @param onAnimationLoop defines a callback to call when animation loops
  78832. */
  78833. constructor(scene: Scene,
  78834. /** defines the target object */
  78835. target: any,
  78836. /** defines the starting frame number (default is 0) */
  78837. fromFrame?: number,
  78838. /** defines the ending frame number (default is 100) */
  78839. toFrame?: number,
  78840. /** defines if the animation must loop (default is false) */
  78841. loopAnimation?: boolean, speedRatio?: number,
  78842. /** defines a callback to call when animation ends if it is not looping */
  78843. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78844. /** defines a callback to call when animation loops */
  78845. onAnimationLoop?: (() => void) | null | undefined);
  78846. /**
  78847. * Synchronize and normalize current Animatable with a source Animatable
  78848. * This is useful when using animation weights and when animations are not of the same length
  78849. * @param root defines the root Animatable to synchronize with
  78850. * @returns the current Animatable
  78851. */
  78852. syncWith(root: Animatable): Animatable;
  78853. /**
  78854. * Gets the list of runtime animations
  78855. * @returns an array of RuntimeAnimation
  78856. */
  78857. getAnimations(): RuntimeAnimation[];
  78858. /**
  78859. * Adds more animations to the current animatable
  78860. * @param target defines the target of the animations
  78861. * @param animations defines the new animations to add
  78862. */
  78863. appendAnimations(target: any, animations: Animation[]): void;
  78864. /**
  78865. * Gets the source animation for a specific property
  78866. * @param property defines the propertyu to look for
  78867. * @returns null or the source animation for the given property
  78868. */
  78869. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78870. /**
  78871. * Gets the runtime animation for a specific property
  78872. * @param property defines the propertyu to look for
  78873. * @returns null or the runtime animation for the given property
  78874. */
  78875. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78876. /**
  78877. * Resets the animatable to its original state
  78878. */
  78879. reset(): void;
  78880. /**
  78881. * Allows the animatable to blend with current running animations
  78882. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78883. * @param blendingSpeed defines the blending speed to use
  78884. */
  78885. enableBlending(blendingSpeed: number): void;
  78886. /**
  78887. * Disable animation blending
  78888. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78889. */
  78890. disableBlending(): void;
  78891. /**
  78892. * Jump directly to a given frame
  78893. * @param frame defines the frame to jump to
  78894. */
  78895. goToFrame(frame: number): void;
  78896. /**
  78897. * Pause the animation
  78898. */
  78899. pause(): void;
  78900. /**
  78901. * Restart the animation
  78902. */
  78903. restart(): void;
  78904. private _raiseOnAnimationEnd;
  78905. /**
  78906. * Stop and delete the current animation
  78907. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78908. * @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)
  78909. */
  78910. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78911. /**
  78912. * Wait asynchronously for the animation to end
  78913. * @returns a promise which will be fullfilled when the animation ends
  78914. */
  78915. waitAsync(): Promise<Animatable>;
  78916. /** @hidden */
  78917. _animate(delay: number): boolean;
  78918. }
  78919. interface Scene {
  78920. /** @hidden */
  78921. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78922. /** @hidden */
  78923. _processLateAnimationBindingsForMatrices(holder: {
  78924. totalWeight: number;
  78925. animations: RuntimeAnimation[];
  78926. originalValue: Matrix;
  78927. }): any;
  78928. /** @hidden */
  78929. _processLateAnimationBindingsForQuaternions(holder: {
  78930. totalWeight: number;
  78931. animations: RuntimeAnimation[];
  78932. originalValue: Quaternion;
  78933. }, refQuaternion: Quaternion): Quaternion;
  78934. /** @hidden */
  78935. _processLateAnimationBindings(): void;
  78936. /**
  78937. * Will start the animation sequence of a given target
  78938. * @param target defines the target
  78939. * @param from defines from which frame should animation start
  78940. * @param to defines until which frame should animation run.
  78941. * @param weight defines the weight to apply to the animation (1.0 by default)
  78942. * @param loop defines if the animation loops
  78943. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78944. * @param onAnimationEnd defines the function to be executed when the animation ends
  78945. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78946. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78947. * @param onAnimationLoop defines the callback to call when an animation loops
  78948. * @returns the animatable object created for this animation
  78949. */
  78950. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78951. /**
  78952. * Will start the animation sequence of a given target
  78953. * @param target defines the target
  78954. * @param from defines from which frame should animation start
  78955. * @param to defines until which frame should animation run.
  78956. * @param loop defines if the animation loops
  78957. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78958. * @param onAnimationEnd defines the function to be executed when the animation ends
  78959. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78960. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78961. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78962. * @param onAnimationLoop defines the callback to call when an animation loops
  78963. * @returns the animatable object created for this animation
  78964. */
  78965. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78966. /**
  78967. * Will start the animation sequence of a given target and its hierarchy
  78968. * @param target defines the target
  78969. * @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.
  78970. * @param from defines from which frame should animation start
  78971. * @param to defines until which frame should animation run.
  78972. * @param loop defines if the animation loops
  78973. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78974. * @param onAnimationEnd defines the function to be executed when the animation ends
  78975. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78976. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78977. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78978. * @param onAnimationLoop defines the callback to call when an animation loops
  78979. * @returns the list of created animatables
  78980. */
  78981. 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[];
  78982. /**
  78983. * Begin a new animation on a given node
  78984. * @param target defines the target where the animation will take place
  78985. * @param animations defines the list of animations to start
  78986. * @param from defines the initial value
  78987. * @param to defines the final value
  78988. * @param loop defines if you want animation to loop (off by default)
  78989. * @param speedRatio defines the speed ratio to apply to all animations
  78990. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78991. * @param onAnimationLoop defines the callback to call when an animation loops
  78992. * @returns the list of created animatables
  78993. */
  78994. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78995. /**
  78996. * Begin a new animation on a given node and its hierarchy
  78997. * @param target defines the root node where the animation will take place
  78998. * @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.
  78999. * @param animations defines the list of animations to start
  79000. * @param from defines the initial value
  79001. * @param to defines the final value
  79002. * @param loop defines if you want animation to loop (off by default)
  79003. * @param speedRatio defines the speed ratio to apply to all animations
  79004. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79005. * @param onAnimationLoop defines the callback to call when an animation loops
  79006. * @returns the list of animatables created for all nodes
  79007. */
  79008. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79009. /**
  79010. * Gets the animatable associated with a specific target
  79011. * @param target defines the target of the animatable
  79012. * @returns the required animatable if found
  79013. */
  79014. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79015. /**
  79016. * Gets all animatables associated with a given target
  79017. * @param target defines the target to look animatables for
  79018. * @returns an array of Animatables
  79019. */
  79020. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79021. /**
  79022. * Will stop the animation of the given target
  79023. * @param target - the target
  79024. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  79025. * @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)
  79026. */
  79027. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  79028. /**
  79029. * Stops and removes all animations that have been applied to the scene
  79030. */
  79031. stopAllAnimations(): void;
  79032. }
  79033. interface Bone {
  79034. /**
  79035. * Copy an animation range from another bone
  79036. * @param source defines the source bone
  79037. * @param rangeName defines the range name to copy
  79038. * @param frameOffset defines the frame offset
  79039. * @param rescaleAsRequired defines if rescaling must be applied if required
  79040. * @param skelDimensionsRatio defines the scaling ratio
  79041. * @returns true if operation was successful
  79042. */
  79043. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79044. }
  79045. }
  79046. declare module BABYLON {
  79047. /**
  79048. * Class used to handle skinning animations
  79049. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79050. */
  79051. export class Skeleton implements IAnimatable {
  79052. /** defines the skeleton name */
  79053. name: string;
  79054. /** defines the skeleton Id */
  79055. id: string;
  79056. /**
  79057. * Defines the list of child bones
  79058. */
  79059. bones: Bone[];
  79060. /**
  79061. * Defines an estimate of the dimension of the skeleton at rest
  79062. */
  79063. dimensionsAtRest: Vector3;
  79064. /**
  79065. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79066. */
  79067. needInitialSkinMatrix: boolean;
  79068. /**
  79069. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79070. */
  79071. overrideMesh: Nullable<AbstractMesh>;
  79072. /**
  79073. * Gets the list of animations attached to this skeleton
  79074. */
  79075. animations: Array<Animation>;
  79076. private _scene;
  79077. private _isDirty;
  79078. private _transformMatrices;
  79079. private _transformMatrixTexture;
  79080. private _meshesWithPoseMatrix;
  79081. private _animatables;
  79082. private _identity;
  79083. private _synchronizedWithMesh;
  79084. private _ranges;
  79085. private _lastAbsoluteTransformsUpdateId;
  79086. private _canUseTextureForBones;
  79087. private _uniqueId;
  79088. /** @hidden */
  79089. _numBonesWithLinkedTransformNode: number;
  79090. /**
  79091. * Specifies if the skeleton should be serialized
  79092. */
  79093. doNotSerialize: boolean;
  79094. private _useTextureToStoreBoneMatrices;
  79095. /**
  79096. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79097. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79098. */
  79099. useTextureToStoreBoneMatrices: boolean;
  79100. private _animationPropertiesOverride;
  79101. /**
  79102. * Gets or sets the animation properties override
  79103. */
  79104. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79105. /**
  79106. * List of inspectable custom properties (used by the Inspector)
  79107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79108. */
  79109. inspectableCustomProperties: IInspectable[];
  79110. /**
  79111. * An observable triggered before computing the skeleton's matrices
  79112. */
  79113. onBeforeComputeObservable: Observable<Skeleton>;
  79114. /**
  79115. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79116. */
  79117. readonly isUsingTextureForMatrices: boolean;
  79118. /**
  79119. * Gets the unique ID of this skeleton
  79120. */
  79121. readonly uniqueId: number;
  79122. /**
  79123. * Creates a new skeleton
  79124. * @param name defines the skeleton name
  79125. * @param id defines the skeleton Id
  79126. * @param scene defines the hosting scene
  79127. */
  79128. constructor(
  79129. /** defines the skeleton name */
  79130. name: string,
  79131. /** defines the skeleton Id */
  79132. id: string, scene: Scene);
  79133. /**
  79134. * Gets the current object class name.
  79135. * @return the class name
  79136. */
  79137. getClassName(): string;
  79138. /**
  79139. * Returns an array containing the root bones
  79140. * @returns an array containing the root bones
  79141. */
  79142. getChildren(): Array<Bone>;
  79143. /**
  79144. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79145. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79146. * @returns a Float32Array containing matrices data
  79147. */
  79148. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79149. /**
  79150. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79151. * @returns a raw texture containing the data
  79152. */
  79153. getTransformMatrixTexture(): Nullable<RawTexture>;
  79154. /**
  79155. * Gets the current hosting scene
  79156. * @returns a scene object
  79157. */
  79158. getScene(): Scene;
  79159. /**
  79160. * Gets a string representing the current skeleton data
  79161. * @param fullDetails defines a boolean indicating if we want a verbose version
  79162. * @returns a string representing the current skeleton data
  79163. */
  79164. toString(fullDetails?: boolean): string;
  79165. /**
  79166. * Get bone's index searching by name
  79167. * @param name defines bone's name to search for
  79168. * @return the indice of the bone. Returns -1 if not found
  79169. */
  79170. getBoneIndexByName(name: string): number;
  79171. /**
  79172. * Creater a new animation range
  79173. * @param name defines the name of the range
  79174. * @param from defines the start key
  79175. * @param to defines the end key
  79176. */
  79177. createAnimationRange(name: string, from: number, to: number): void;
  79178. /**
  79179. * Delete a specific animation range
  79180. * @param name defines the name of the range
  79181. * @param deleteFrames defines if frames must be removed as well
  79182. */
  79183. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79184. /**
  79185. * Gets a specific animation range
  79186. * @param name defines the name of the range to look for
  79187. * @returns the requested animation range or null if not found
  79188. */
  79189. getAnimationRange(name: string): Nullable<AnimationRange>;
  79190. /**
  79191. * Gets the list of all animation ranges defined on this skeleton
  79192. * @returns an array
  79193. */
  79194. getAnimationRanges(): Nullable<AnimationRange>[];
  79195. /**
  79196. * Copy animation range from a source skeleton.
  79197. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79198. * @param source defines the source skeleton
  79199. * @param name defines the name of the range to copy
  79200. * @param rescaleAsRequired defines if rescaling must be applied if required
  79201. * @returns true if operation was successful
  79202. */
  79203. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79204. /**
  79205. * Forces the skeleton to go to rest pose
  79206. */
  79207. returnToRest(): void;
  79208. private _getHighestAnimationFrame;
  79209. /**
  79210. * Begin a specific animation range
  79211. * @param name defines the name of the range to start
  79212. * @param loop defines if looping must be turned on (false by default)
  79213. * @param speedRatio defines the speed ratio to apply (1 by default)
  79214. * @param onAnimationEnd defines a callback which will be called when animation will end
  79215. * @returns a new animatable
  79216. */
  79217. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79218. /** @hidden */
  79219. _markAsDirty(): void;
  79220. /** @hidden */
  79221. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79222. /** @hidden */
  79223. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79224. private _computeTransformMatrices;
  79225. /**
  79226. * Build all resources required to render a skeleton
  79227. */
  79228. prepare(): void;
  79229. /**
  79230. * Gets the list of animatables currently running for this skeleton
  79231. * @returns an array of animatables
  79232. */
  79233. getAnimatables(): IAnimatable[];
  79234. /**
  79235. * Clone the current skeleton
  79236. * @param name defines the name of the new skeleton
  79237. * @param id defines the id of the new skeleton
  79238. * @returns the new skeleton
  79239. */
  79240. clone(name: string, id: string): Skeleton;
  79241. /**
  79242. * Enable animation blending for this skeleton
  79243. * @param blendingSpeed defines the blending speed to apply
  79244. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79245. */
  79246. enableBlending(blendingSpeed?: number): void;
  79247. /**
  79248. * Releases all resources associated with the current skeleton
  79249. */
  79250. dispose(): void;
  79251. /**
  79252. * Serialize the skeleton in a JSON object
  79253. * @returns a JSON object
  79254. */
  79255. serialize(): any;
  79256. /**
  79257. * Creates a new skeleton from serialized data
  79258. * @param parsedSkeleton defines the serialized data
  79259. * @param scene defines the hosting scene
  79260. * @returns a new skeleton
  79261. */
  79262. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79263. /**
  79264. * Compute all node absolute transforms
  79265. * @param forceUpdate defines if computation must be done even if cache is up to date
  79266. */
  79267. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79268. /**
  79269. * Gets the root pose matrix
  79270. * @returns a matrix
  79271. */
  79272. getPoseMatrix(): Nullable<Matrix>;
  79273. /**
  79274. * Sorts bones per internal index
  79275. */
  79276. sortBones(): void;
  79277. private _sortBones;
  79278. }
  79279. }
  79280. declare module BABYLON {
  79281. /**
  79282. * Defines a target to use with MorphTargetManager
  79283. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79284. */
  79285. export class MorphTarget implements IAnimatable {
  79286. /** defines the name of the target */
  79287. name: string;
  79288. /**
  79289. * Gets or sets the list of animations
  79290. */
  79291. animations: Animation[];
  79292. private _scene;
  79293. private _positions;
  79294. private _normals;
  79295. private _tangents;
  79296. private _influence;
  79297. /**
  79298. * Observable raised when the influence changes
  79299. */
  79300. onInfluenceChanged: Observable<boolean>;
  79301. /** @hidden */
  79302. _onDataLayoutChanged: Observable<void>;
  79303. /**
  79304. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79305. */
  79306. influence: number;
  79307. /**
  79308. * Gets or sets the id of the morph Target
  79309. */
  79310. id: string;
  79311. private _animationPropertiesOverride;
  79312. /**
  79313. * Gets or sets the animation properties override
  79314. */
  79315. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79316. /**
  79317. * Creates a new MorphTarget
  79318. * @param name defines the name of the target
  79319. * @param influence defines the influence to use
  79320. * @param scene defines the scene the morphtarget belongs to
  79321. */
  79322. constructor(
  79323. /** defines the name of the target */
  79324. name: string, influence?: number, scene?: Nullable<Scene>);
  79325. /**
  79326. * Gets a boolean defining if the target contains position data
  79327. */
  79328. readonly hasPositions: boolean;
  79329. /**
  79330. * Gets a boolean defining if the target contains normal data
  79331. */
  79332. readonly hasNormals: boolean;
  79333. /**
  79334. * Gets a boolean defining if the target contains tangent data
  79335. */
  79336. readonly hasTangents: boolean;
  79337. /**
  79338. * Affects position data to this target
  79339. * @param data defines the position data to use
  79340. */
  79341. setPositions(data: Nullable<FloatArray>): void;
  79342. /**
  79343. * Gets the position data stored in this target
  79344. * @returns a FloatArray containing the position data (or null if not present)
  79345. */
  79346. getPositions(): Nullable<FloatArray>;
  79347. /**
  79348. * Affects normal data to this target
  79349. * @param data defines the normal data to use
  79350. */
  79351. setNormals(data: Nullable<FloatArray>): void;
  79352. /**
  79353. * Gets the normal data stored in this target
  79354. * @returns a FloatArray containing the normal data (or null if not present)
  79355. */
  79356. getNormals(): Nullable<FloatArray>;
  79357. /**
  79358. * Affects tangent data to this target
  79359. * @param data defines the tangent data to use
  79360. */
  79361. setTangents(data: Nullable<FloatArray>): void;
  79362. /**
  79363. * Gets the tangent data stored in this target
  79364. * @returns a FloatArray containing the tangent data (or null if not present)
  79365. */
  79366. getTangents(): Nullable<FloatArray>;
  79367. /**
  79368. * Serializes the current target into a Serialization object
  79369. * @returns the serialized object
  79370. */
  79371. serialize(): any;
  79372. /**
  79373. * Returns the string "MorphTarget"
  79374. * @returns "MorphTarget"
  79375. */
  79376. getClassName(): string;
  79377. /**
  79378. * Creates a new target from serialized data
  79379. * @param serializationObject defines the serialized data to use
  79380. * @returns a new MorphTarget
  79381. */
  79382. static Parse(serializationObject: any): MorphTarget;
  79383. /**
  79384. * Creates a MorphTarget from mesh data
  79385. * @param mesh defines the source mesh
  79386. * @param name defines the name to use for the new target
  79387. * @param influence defines the influence to attach to the target
  79388. * @returns a new MorphTarget
  79389. */
  79390. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79391. }
  79392. }
  79393. declare module BABYLON {
  79394. /**
  79395. * This class is used to deform meshes using morphing between different targets
  79396. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79397. */
  79398. export class MorphTargetManager {
  79399. private _targets;
  79400. private _targetInfluenceChangedObservers;
  79401. private _targetDataLayoutChangedObservers;
  79402. private _activeTargets;
  79403. private _scene;
  79404. private _influences;
  79405. private _supportsNormals;
  79406. private _supportsTangents;
  79407. private _vertexCount;
  79408. private _uniqueId;
  79409. private _tempInfluences;
  79410. /**
  79411. * Creates a new MorphTargetManager
  79412. * @param scene defines the current scene
  79413. */
  79414. constructor(scene?: Nullable<Scene>);
  79415. /**
  79416. * Gets the unique ID of this manager
  79417. */
  79418. readonly uniqueId: number;
  79419. /**
  79420. * Gets the number of vertices handled by this manager
  79421. */
  79422. readonly vertexCount: number;
  79423. /**
  79424. * Gets a boolean indicating if this manager supports morphing of normals
  79425. */
  79426. readonly supportsNormals: boolean;
  79427. /**
  79428. * Gets a boolean indicating if this manager supports morphing of tangents
  79429. */
  79430. readonly supportsTangents: boolean;
  79431. /**
  79432. * Gets the number of targets stored in this manager
  79433. */
  79434. readonly numTargets: number;
  79435. /**
  79436. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79437. */
  79438. readonly numInfluencers: number;
  79439. /**
  79440. * Gets the list of influences (one per target)
  79441. */
  79442. readonly influences: Float32Array;
  79443. /**
  79444. * Gets the active target at specified index. An active target is a target with an influence > 0
  79445. * @param index defines the index to check
  79446. * @returns the requested target
  79447. */
  79448. getActiveTarget(index: number): MorphTarget;
  79449. /**
  79450. * Gets the target at specified index
  79451. * @param index defines the index to check
  79452. * @returns the requested target
  79453. */
  79454. getTarget(index: number): MorphTarget;
  79455. /**
  79456. * Add a new target to this manager
  79457. * @param target defines the target to add
  79458. */
  79459. addTarget(target: MorphTarget): void;
  79460. /**
  79461. * Removes a target from the manager
  79462. * @param target defines the target to remove
  79463. */
  79464. removeTarget(target: MorphTarget): void;
  79465. /**
  79466. * Serializes the current manager into a Serialization object
  79467. * @returns the serialized object
  79468. */
  79469. serialize(): any;
  79470. private _syncActiveTargets;
  79471. /**
  79472. * Syncrhonize the targets with all the meshes using this morph target manager
  79473. */
  79474. synchronize(): void;
  79475. /**
  79476. * Creates a new MorphTargetManager from serialized data
  79477. * @param serializationObject defines the serialized data
  79478. * @param scene defines the hosting scene
  79479. * @returns the new MorphTargetManager
  79480. */
  79481. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79482. }
  79483. }
  79484. declare module BABYLON {
  79485. /**
  79486. * Class used to represent a specific level of detail of a mesh
  79487. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79488. */
  79489. export class MeshLODLevel {
  79490. /** Defines the distance where this level should star being displayed */
  79491. distance: number;
  79492. /** Defines the mesh to use to render this level */
  79493. mesh: Nullable<Mesh>;
  79494. /**
  79495. * Creates a new LOD level
  79496. * @param distance defines the distance where this level should star being displayed
  79497. * @param mesh defines the mesh to use to render this level
  79498. */
  79499. constructor(
  79500. /** Defines the distance where this level should star being displayed */
  79501. distance: number,
  79502. /** Defines the mesh to use to render this level */
  79503. mesh: Nullable<Mesh>);
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /**
  79508. * Mesh representing the gorund
  79509. */
  79510. export class GroundMesh extends Mesh {
  79511. /** If octree should be generated */
  79512. generateOctree: boolean;
  79513. private _heightQuads;
  79514. /** @hidden */
  79515. _subdivisionsX: number;
  79516. /** @hidden */
  79517. _subdivisionsY: number;
  79518. /** @hidden */
  79519. _width: number;
  79520. /** @hidden */
  79521. _height: number;
  79522. /** @hidden */
  79523. _minX: number;
  79524. /** @hidden */
  79525. _maxX: number;
  79526. /** @hidden */
  79527. _minZ: number;
  79528. /** @hidden */
  79529. _maxZ: number;
  79530. constructor(name: string, scene: Scene);
  79531. /**
  79532. * "GroundMesh"
  79533. * @returns "GroundMesh"
  79534. */
  79535. getClassName(): string;
  79536. /**
  79537. * The minimum of x and y subdivisions
  79538. */
  79539. readonly subdivisions: number;
  79540. /**
  79541. * X subdivisions
  79542. */
  79543. readonly subdivisionsX: number;
  79544. /**
  79545. * Y subdivisions
  79546. */
  79547. readonly subdivisionsY: number;
  79548. /**
  79549. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79550. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79551. * @param chunksCount the number of subdivisions for x and y
  79552. * @param octreeBlocksSize (Default: 32)
  79553. */
  79554. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79555. /**
  79556. * Returns a height (y) value in the Worl system :
  79557. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79558. * @param x x coordinate
  79559. * @param z z coordinate
  79560. * @returns the ground y position if (x, z) are outside the ground surface.
  79561. */
  79562. getHeightAtCoordinates(x: number, z: number): number;
  79563. /**
  79564. * Returns a normalized vector (Vector3) orthogonal to the ground
  79565. * at the ground coordinates (x, z) expressed in the World system.
  79566. * @param x x coordinate
  79567. * @param z z coordinate
  79568. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79569. */
  79570. getNormalAtCoordinates(x: number, z: number): Vector3;
  79571. /**
  79572. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79573. * at the ground coordinates (x, z) expressed in the World system.
  79574. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79575. * @param x x coordinate
  79576. * @param z z coordinate
  79577. * @param ref vector to store the result
  79578. * @returns the GroundMesh.
  79579. */
  79580. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79581. /**
  79582. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79583. * if the ground has been updated.
  79584. * This can be used in the render loop.
  79585. * @returns the GroundMesh.
  79586. */
  79587. updateCoordinateHeights(): GroundMesh;
  79588. private _getFacetAt;
  79589. private _initHeightQuads;
  79590. private _computeHeightQuads;
  79591. /**
  79592. * Serializes this ground mesh
  79593. * @param serializationObject object to write serialization to
  79594. */
  79595. serialize(serializationObject: any): void;
  79596. /**
  79597. * Parses a serialized ground mesh
  79598. * @param parsedMesh the serialized mesh
  79599. * @param scene the scene to create the ground mesh in
  79600. * @returns the created ground mesh
  79601. */
  79602. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79603. }
  79604. }
  79605. declare module BABYLON {
  79606. /**
  79607. * Interface for Physics-Joint data
  79608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79609. */
  79610. export interface PhysicsJointData {
  79611. /**
  79612. * The main pivot of the joint
  79613. */
  79614. mainPivot?: Vector3;
  79615. /**
  79616. * The connected pivot of the joint
  79617. */
  79618. connectedPivot?: Vector3;
  79619. /**
  79620. * The main axis of the joint
  79621. */
  79622. mainAxis?: Vector3;
  79623. /**
  79624. * The connected axis of the joint
  79625. */
  79626. connectedAxis?: Vector3;
  79627. /**
  79628. * The collision of the joint
  79629. */
  79630. collision?: boolean;
  79631. /**
  79632. * Native Oimo/Cannon/Energy data
  79633. */
  79634. nativeParams?: any;
  79635. }
  79636. /**
  79637. * This is a holder class for the physics joint created by the physics plugin
  79638. * It holds a set of functions to control the underlying joint
  79639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79640. */
  79641. export class PhysicsJoint {
  79642. /**
  79643. * The type of the physics joint
  79644. */
  79645. type: number;
  79646. /**
  79647. * The data for the physics joint
  79648. */
  79649. jointData: PhysicsJointData;
  79650. private _physicsJoint;
  79651. protected _physicsPlugin: IPhysicsEnginePlugin;
  79652. /**
  79653. * Initializes the physics joint
  79654. * @param type The type of the physics joint
  79655. * @param jointData The data for the physics joint
  79656. */
  79657. constructor(
  79658. /**
  79659. * The type of the physics joint
  79660. */
  79661. type: number,
  79662. /**
  79663. * The data for the physics joint
  79664. */
  79665. jointData: PhysicsJointData);
  79666. /**
  79667. * Gets the physics joint
  79668. */
  79669. /**
  79670. * Sets the physics joint
  79671. */
  79672. physicsJoint: any;
  79673. /**
  79674. * Sets the physics plugin
  79675. */
  79676. physicsPlugin: IPhysicsEnginePlugin;
  79677. /**
  79678. * Execute a function that is physics-plugin specific.
  79679. * @param {Function} func the function that will be executed.
  79680. * It accepts two parameters: the physics world and the physics joint
  79681. */
  79682. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79683. /**
  79684. * Distance-Joint type
  79685. */
  79686. static DistanceJoint: number;
  79687. /**
  79688. * Hinge-Joint type
  79689. */
  79690. static HingeJoint: number;
  79691. /**
  79692. * Ball-and-Socket joint type
  79693. */
  79694. static BallAndSocketJoint: number;
  79695. /**
  79696. * Wheel-Joint type
  79697. */
  79698. static WheelJoint: number;
  79699. /**
  79700. * Slider-Joint type
  79701. */
  79702. static SliderJoint: number;
  79703. /**
  79704. * Prismatic-Joint type
  79705. */
  79706. static PrismaticJoint: number;
  79707. /**
  79708. * Universal-Joint type
  79709. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79710. */
  79711. static UniversalJoint: number;
  79712. /**
  79713. * Hinge-Joint 2 type
  79714. */
  79715. static Hinge2Joint: number;
  79716. /**
  79717. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79718. */
  79719. static PointToPointJoint: number;
  79720. /**
  79721. * Spring-Joint type
  79722. */
  79723. static SpringJoint: number;
  79724. /**
  79725. * Lock-Joint type
  79726. */
  79727. static LockJoint: number;
  79728. }
  79729. /**
  79730. * A class representing a physics distance joint
  79731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79732. */
  79733. export class DistanceJoint extends PhysicsJoint {
  79734. /**
  79735. *
  79736. * @param jointData The data for the Distance-Joint
  79737. */
  79738. constructor(jointData: DistanceJointData);
  79739. /**
  79740. * Update the predefined distance.
  79741. * @param maxDistance The maximum preferred distance
  79742. * @param minDistance The minimum preferred distance
  79743. */
  79744. updateDistance(maxDistance: number, minDistance?: number): void;
  79745. }
  79746. /**
  79747. * Represents a Motor-Enabled Joint
  79748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79749. */
  79750. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79751. /**
  79752. * Initializes the Motor-Enabled Joint
  79753. * @param type The type of the joint
  79754. * @param jointData The physica joint data for the joint
  79755. */
  79756. constructor(type: number, jointData: PhysicsJointData);
  79757. /**
  79758. * Set the motor values.
  79759. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79760. * @param force the force to apply
  79761. * @param maxForce max force for this motor.
  79762. */
  79763. setMotor(force?: number, maxForce?: number): void;
  79764. /**
  79765. * Set the motor's limits.
  79766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79767. * @param upperLimit The upper limit of the motor
  79768. * @param lowerLimit The lower limit of the motor
  79769. */
  79770. setLimit(upperLimit: number, lowerLimit?: number): void;
  79771. }
  79772. /**
  79773. * This class represents a single physics Hinge-Joint
  79774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79775. */
  79776. export class HingeJoint extends MotorEnabledJoint {
  79777. /**
  79778. * Initializes the Hinge-Joint
  79779. * @param jointData The joint data for the Hinge-Joint
  79780. */
  79781. constructor(jointData: PhysicsJointData);
  79782. /**
  79783. * Set the motor values.
  79784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79785. * @param {number} force the force to apply
  79786. * @param {number} maxForce max force for this motor.
  79787. */
  79788. setMotor(force?: number, maxForce?: number): void;
  79789. /**
  79790. * Set the motor's limits.
  79791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79792. * @param upperLimit The upper limit of the motor
  79793. * @param lowerLimit The lower limit of the motor
  79794. */
  79795. setLimit(upperLimit: number, lowerLimit?: number): void;
  79796. }
  79797. /**
  79798. * This class represents a dual hinge physics joint (same as wheel joint)
  79799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79800. */
  79801. export class Hinge2Joint extends MotorEnabledJoint {
  79802. /**
  79803. * Initializes the Hinge2-Joint
  79804. * @param jointData The joint data for the Hinge2-Joint
  79805. */
  79806. constructor(jointData: PhysicsJointData);
  79807. /**
  79808. * Set the motor values.
  79809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79810. * @param {number} targetSpeed the speed the motor is to reach
  79811. * @param {number} maxForce max force for this motor.
  79812. * @param {motorIndex} the motor's index, 0 or 1.
  79813. */
  79814. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79815. /**
  79816. * Set the motor limits.
  79817. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79818. * @param {number} upperLimit the upper limit
  79819. * @param {number} lowerLimit lower limit
  79820. * @param {motorIndex} the motor's index, 0 or 1.
  79821. */
  79822. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79823. }
  79824. /**
  79825. * Interface for a motor enabled joint
  79826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79827. */
  79828. export interface IMotorEnabledJoint {
  79829. /**
  79830. * Physics joint
  79831. */
  79832. physicsJoint: any;
  79833. /**
  79834. * Sets the motor of the motor-enabled joint
  79835. * @param force The force of the motor
  79836. * @param maxForce The maximum force of the motor
  79837. * @param motorIndex The index of the motor
  79838. */
  79839. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79840. /**
  79841. * Sets the limit of the motor
  79842. * @param upperLimit The upper limit of the motor
  79843. * @param lowerLimit The lower limit of the motor
  79844. * @param motorIndex The index of the motor
  79845. */
  79846. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79847. }
  79848. /**
  79849. * Joint data for a Distance-Joint
  79850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79851. */
  79852. export interface DistanceJointData extends PhysicsJointData {
  79853. /**
  79854. * Max distance the 2 joint objects can be apart
  79855. */
  79856. maxDistance: number;
  79857. }
  79858. /**
  79859. * Joint data from a spring joint
  79860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79861. */
  79862. export interface SpringJointData extends PhysicsJointData {
  79863. /**
  79864. * Length of the spring
  79865. */
  79866. length: number;
  79867. /**
  79868. * Stiffness of the spring
  79869. */
  79870. stiffness: number;
  79871. /**
  79872. * Damping of the spring
  79873. */
  79874. damping: number;
  79875. /** this callback will be called when applying the force to the impostors. */
  79876. forceApplicationCallback: () => void;
  79877. }
  79878. }
  79879. declare module BABYLON {
  79880. /**
  79881. * Holds the data for the raycast result
  79882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79883. */
  79884. export class PhysicsRaycastResult {
  79885. private _hasHit;
  79886. private _hitDistance;
  79887. private _hitNormalWorld;
  79888. private _hitPointWorld;
  79889. private _rayFromWorld;
  79890. private _rayToWorld;
  79891. /**
  79892. * Gets if there was a hit
  79893. */
  79894. readonly hasHit: boolean;
  79895. /**
  79896. * Gets the distance from the hit
  79897. */
  79898. readonly hitDistance: number;
  79899. /**
  79900. * Gets the hit normal/direction in the world
  79901. */
  79902. readonly hitNormalWorld: Vector3;
  79903. /**
  79904. * Gets the hit point in the world
  79905. */
  79906. readonly hitPointWorld: Vector3;
  79907. /**
  79908. * Gets the ray "start point" of the ray in the world
  79909. */
  79910. readonly rayFromWorld: Vector3;
  79911. /**
  79912. * Gets the ray "end point" of the ray in the world
  79913. */
  79914. readonly rayToWorld: Vector3;
  79915. /**
  79916. * Sets the hit data (normal & point in world space)
  79917. * @param hitNormalWorld defines the normal in world space
  79918. * @param hitPointWorld defines the point in world space
  79919. */
  79920. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79921. /**
  79922. * Sets the distance from the start point to the hit point
  79923. * @param distance
  79924. */
  79925. setHitDistance(distance: number): void;
  79926. /**
  79927. * Calculates the distance manually
  79928. */
  79929. calculateHitDistance(): void;
  79930. /**
  79931. * Resets all the values to default
  79932. * @param from The from point on world space
  79933. * @param to The to point on world space
  79934. */
  79935. reset(from?: Vector3, to?: Vector3): void;
  79936. }
  79937. /**
  79938. * Interface for the size containing width and height
  79939. */
  79940. interface IXYZ {
  79941. /**
  79942. * X
  79943. */
  79944. x: number;
  79945. /**
  79946. * Y
  79947. */
  79948. y: number;
  79949. /**
  79950. * Z
  79951. */
  79952. z: number;
  79953. }
  79954. }
  79955. declare module BABYLON {
  79956. /**
  79957. * Interface used to describe a physics joint
  79958. */
  79959. export interface PhysicsImpostorJoint {
  79960. /** Defines the main impostor to which the joint is linked */
  79961. mainImpostor: PhysicsImpostor;
  79962. /** Defines the impostor that is connected to the main impostor using this joint */
  79963. connectedImpostor: PhysicsImpostor;
  79964. /** Defines the joint itself */
  79965. joint: PhysicsJoint;
  79966. }
  79967. /** @hidden */
  79968. export interface IPhysicsEnginePlugin {
  79969. world: any;
  79970. name: string;
  79971. setGravity(gravity: Vector3): void;
  79972. setTimeStep(timeStep: number): void;
  79973. getTimeStep(): number;
  79974. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79975. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79976. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79977. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79978. removePhysicsBody(impostor: PhysicsImpostor): void;
  79979. generateJoint(joint: PhysicsImpostorJoint): void;
  79980. removeJoint(joint: PhysicsImpostorJoint): void;
  79981. isSupported(): boolean;
  79982. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79984. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79985. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79987. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79988. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79989. getBodyMass(impostor: PhysicsImpostor): number;
  79990. getBodyFriction(impostor: PhysicsImpostor): number;
  79991. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79992. getBodyRestitution(impostor: PhysicsImpostor): number;
  79993. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79994. getBodyPressure?(impostor: PhysicsImpostor): number;
  79995. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79996. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79997. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79998. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79999. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80000. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80001. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80002. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80003. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80004. sleepBody(impostor: PhysicsImpostor): void;
  80005. wakeUpBody(impostor: PhysicsImpostor): void;
  80006. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80007. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80008. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80009. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80010. getRadius(impostor: PhysicsImpostor): number;
  80011. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80012. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80013. dispose(): void;
  80014. }
  80015. /**
  80016. * Interface used to define a physics engine
  80017. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80018. */
  80019. export interface IPhysicsEngine {
  80020. /**
  80021. * Gets the gravity vector used by the simulation
  80022. */
  80023. gravity: Vector3;
  80024. /**
  80025. * Sets the gravity vector used by the simulation
  80026. * @param gravity defines the gravity vector to use
  80027. */
  80028. setGravity(gravity: Vector3): void;
  80029. /**
  80030. * Set the time step of the physics engine.
  80031. * Default is 1/60.
  80032. * To slow it down, enter 1/600 for example.
  80033. * To speed it up, 1/30
  80034. * @param newTimeStep the new timestep to apply to this world.
  80035. */
  80036. setTimeStep(newTimeStep: number): void;
  80037. /**
  80038. * Get the time step of the physics engine.
  80039. * @returns the current time step
  80040. */
  80041. getTimeStep(): number;
  80042. /**
  80043. * Release all resources
  80044. */
  80045. dispose(): void;
  80046. /**
  80047. * Gets the name of the current physics plugin
  80048. * @returns the name of the plugin
  80049. */
  80050. getPhysicsPluginName(): string;
  80051. /**
  80052. * Adding a new impostor for the impostor tracking.
  80053. * This will be done by the impostor itself.
  80054. * @param impostor the impostor to add
  80055. */
  80056. addImpostor(impostor: PhysicsImpostor): void;
  80057. /**
  80058. * Remove an impostor from the engine.
  80059. * This impostor and its mesh will not longer be updated by the physics engine.
  80060. * @param impostor the impostor to remove
  80061. */
  80062. removeImpostor(impostor: PhysicsImpostor): void;
  80063. /**
  80064. * Add a joint to the physics engine
  80065. * @param mainImpostor defines the main impostor to which the joint is added.
  80066. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80067. * @param joint defines the joint that will connect both impostors.
  80068. */
  80069. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80070. /**
  80071. * Removes a joint from the simulation
  80072. * @param mainImpostor defines the impostor used with the joint
  80073. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80074. * @param joint defines the joint to remove
  80075. */
  80076. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80077. /**
  80078. * Gets the current plugin used to run the simulation
  80079. * @returns current plugin
  80080. */
  80081. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80082. /**
  80083. * Gets the list of physic impostors
  80084. * @returns an array of PhysicsImpostor
  80085. */
  80086. getImpostors(): Array<PhysicsImpostor>;
  80087. /**
  80088. * Gets the impostor for a physics enabled object
  80089. * @param object defines the object impersonated by the impostor
  80090. * @returns the PhysicsImpostor or null if not found
  80091. */
  80092. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80093. /**
  80094. * Gets the impostor for a physics body object
  80095. * @param body defines physics body used by the impostor
  80096. * @returns the PhysicsImpostor or null if not found
  80097. */
  80098. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80099. /**
  80100. * Does a raycast in the physics world
  80101. * @param from when should the ray start?
  80102. * @param to when should the ray end?
  80103. * @returns PhysicsRaycastResult
  80104. */
  80105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80106. /**
  80107. * Called by the scene. No need to call it.
  80108. * @param delta defines the timespam between frames
  80109. */
  80110. _step(delta: number): void;
  80111. }
  80112. }
  80113. declare module BABYLON {
  80114. /**
  80115. * The interface for the physics imposter parameters
  80116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80117. */
  80118. export interface PhysicsImpostorParameters {
  80119. /**
  80120. * The mass of the physics imposter
  80121. */
  80122. mass: number;
  80123. /**
  80124. * The friction of the physics imposter
  80125. */
  80126. friction?: number;
  80127. /**
  80128. * The coefficient of restitution of the physics imposter
  80129. */
  80130. restitution?: number;
  80131. /**
  80132. * The native options of the physics imposter
  80133. */
  80134. nativeOptions?: any;
  80135. /**
  80136. * Specifies if the parent should be ignored
  80137. */
  80138. ignoreParent?: boolean;
  80139. /**
  80140. * Specifies if bi-directional transformations should be disabled
  80141. */
  80142. disableBidirectionalTransformation?: boolean;
  80143. /**
  80144. * The pressure inside the physics imposter, soft object only
  80145. */
  80146. pressure?: number;
  80147. /**
  80148. * The stiffness the physics imposter, soft object only
  80149. */
  80150. stiffness?: number;
  80151. /**
  80152. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80153. */
  80154. velocityIterations?: number;
  80155. /**
  80156. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80157. */
  80158. positionIterations?: number;
  80159. /**
  80160. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80161. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80162. * Add to fix multiple points
  80163. */
  80164. fixedPoints?: number;
  80165. /**
  80166. * The collision margin around a soft object
  80167. */
  80168. margin?: number;
  80169. /**
  80170. * The collision margin around a soft object
  80171. */
  80172. damping?: number;
  80173. /**
  80174. * The path for a rope based on an extrusion
  80175. */
  80176. path?: any;
  80177. /**
  80178. * The shape of an extrusion used for a rope based on an extrusion
  80179. */
  80180. shape?: any;
  80181. }
  80182. /**
  80183. * Interface for a physics-enabled object
  80184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80185. */
  80186. export interface IPhysicsEnabledObject {
  80187. /**
  80188. * The position of the physics-enabled object
  80189. */
  80190. position: Vector3;
  80191. /**
  80192. * The rotation of the physics-enabled object
  80193. */
  80194. rotationQuaternion: Nullable<Quaternion>;
  80195. /**
  80196. * The scale of the physics-enabled object
  80197. */
  80198. scaling: Vector3;
  80199. /**
  80200. * The rotation of the physics-enabled object
  80201. */
  80202. rotation?: Vector3;
  80203. /**
  80204. * The parent of the physics-enabled object
  80205. */
  80206. parent?: any;
  80207. /**
  80208. * The bounding info of the physics-enabled object
  80209. * @returns The bounding info of the physics-enabled object
  80210. */
  80211. getBoundingInfo(): BoundingInfo;
  80212. /**
  80213. * Computes the world matrix
  80214. * @param force Specifies if the world matrix should be computed by force
  80215. * @returns A world matrix
  80216. */
  80217. computeWorldMatrix(force: boolean): Matrix;
  80218. /**
  80219. * Gets the world matrix
  80220. * @returns A world matrix
  80221. */
  80222. getWorldMatrix?(): Matrix;
  80223. /**
  80224. * Gets the child meshes
  80225. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80226. * @returns An array of abstract meshes
  80227. */
  80228. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80229. /**
  80230. * Gets the vertex data
  80231. * @param kind The type of vertex data
  80232. * @returns A nullable array of numbers, or a float32 array
  80233. */
  80234. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80235. /**
  80236. * Gets the indices from the mesh
  80237. * @returns A nullable array of index arrays
  80238. */
  80239. getIndices?(): Nullable<IndicesArray>;
  80240. /**
  80241. * Gets the scene from the mesh
  80242. * @returns the indices array or null
  80243. */
  80244. getScene?(): Scene;
  80245. /**
  80246. * Gets the absolute position from the mesh
  80247. * @returns the absolute position
  80248. */
  80249. getAbsolutePosition(): Vector3;
  80250. /**
  80251. * Gets the absolute pivot point from the mesh
  80252. * @returns the absolute pivot point
  80253. */
  80254. getAbsolutePivotPoint(): Vector3;
  80255. /**
  80256. * Rotates the mesh
  80257. * @param axis The axis of rotation
  80258. * @param amount The amount of rotation
  80259. * @param space The space of the rotation
  80260. * @returns The rotation transform node
  80261. */
  80262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80263. /**
  80264. * Translates the mesh
  80265. * @param axis The axis of translation
  80266. * @param distance The distance of translation
  80267. * @param space The space of the translation
  80268. * @returns The transform node
  80269. */
  80270. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80271. /**
  80272. * Sets the absolute position of the mesh
  80273. * @param absolutePosition The absolute position of the mesh
  80274. * @returns The transform node
  80275. */
  80276. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80277. /**
  80278. * Gets the class name of the mesh
  80279. * @returns The class name
  80280. */
  80281. getClassName(): string;
  80282. }
  80283. /**
  80284. * Represents a physics imposter
  80285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80286. */
  80287. export class PhysicsImpostor {
  80288. /**
  80289. * The physics-enabled object used as the physics imposter
  80290. */
  80291. object: IPhysicsEnabledObject;
  80292. /**
  80293. * The type of the physics imposter
  80294. */
  80295. type: number;
  80296. private _options;
  80297. private _scene?;
  80298. /**
  80299. * The default object size of the imposter
  80300. */
  80301. static DEFAULT_OBJECT_SIZE: Vector3;
  80302. /**
  80303. * The identity quaternion of the imposter
  80304. */
  80305. static IDENTITY_QUATERNION: Quaternion;
  80306. /** @hidden */
  80307. _pluginData: any;
  80308. private _physicsEngine;
  80309. private _physicsBody;
  80310. private _bodyUpdateRequired;
  80311. private _onBeforePhysicsStepCallbacks;
  80312. private _onAfterPhysicsStepCallbacks;
  80313. /** @hidden */
  80314. _onPhysicsCollideCallbacks: Array<{
  80315. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80316. otherImpostors: Array<PhysicsImpostor>;
  80317. }>;
  80318. private _deltaPosition;
  80319. private _deltaRotation;
  80320. private _deltaRotationConjugated;
  80321. /** hidden */
  80322. _isFromLine: boolean;
  80323. private _parent;
  80324. private _isDisposed;
  80325. private static _tmpVecs;
  80326. private static _tmpQuat;
  80327. /**
  80328. * Specifies if the physics imposter is disposed
  80329. */
  80330. readonly isDisposed: boolean;
  80331. /**
  80332. * Gets the mass of the physics imposter
  80333. */
  80334. mass: number;
  80335. /**
  80336. * Gets the coefficient of friction
  80337. */
  80338. /**
  80339. * Sets the coefficient of friction
  80340. */
  80341. friction: number;
  80342. /**
  80343. * Gets the coefficient of restitution
  80344. */
  80345. /**
  80346. * Sets the coefficient of restitution
  80347. */
  80348. restitution: number;
  80349. /**
  80350. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80351. */
  80352. /**
  80353. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80354. */
  80355. pressure: number;
  80356. /**
  80357. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80358. */
  80359. /**
  80360. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80361. */
  80362. stiffness: number;
  80363. /**
  80364. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80365. */
  80366. /**
  80367. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80368. */
  80369. velocityIterations: number;
  80370. /**
  80371. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80372. */
  80373. /**
  80374. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80375. */
  80376. positionIterations: number;
  80377. /**
  80378. * The unique id of the physics imposter
  80379. * set by the physics engine when adding this impostor to the array
  80380. */
  80381. uniqueId: number;
  80382. /**
  80383. * @hidden
  80384. */
  80385. soft: boolean;
  80386. /**
  80387. * @hidden
  80388. */
  80389. segments: number;
  80390. private _joints;
  80391. /**
  80392. * Initializes the physics imposter
  80393. * @param object The physics-enabled object used as the physics imposter
  80394. * @param type The type of the physics imposter
  80395. * @param _options The options for the physics imposter
  80396. * @param _scene The Babylon scene
  80397. */
  80398. constructor(
  80399. /**
  80400. * The physics-enabled object used as the physics imposter
  80401. */
  80402. object: IPhysicsEnabledObject,
  80403. /**
  80404. * The type of the physics imposter
  80405. */
  80406. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80407. /**
  80408. * This function will completly initialize this impostor.
  80409. * It will create a new body - but only if this mesh has no parent.
  80410. * If it has, this impostor will not be used other than to define the impostor
  80411. * of the child mesh.
  80412. * @hidden
  80413. */
  80414. _init(): void;
  80415. private _getPhysicsParent;
  80416. /**
  80417. * Should a new body be generated.
  80418. * @returns boolean specifying if body initialization is required
  80419. */
  80420. isBodyInitRequired(): boolean;
  80421. /**
  80422. * Sets the updated scaling
  80423. * @param updated Specifies if the scaling is updated
  80424. */
  80425. setScalingUpdated(): void;
  80426. /**
  80427. * Force a regeneration of this or the parent's impostor's body.
  80428. * Use under cautious - This will remove all joints already implemented.
  80429. */
  80430. forceUpdate(): void;
  80431. /**
  80432. * Gets the body that holds this impostor. Either its own, or its parent.
  80433. */
  80434. /**
  80435. * Set the physics body. Used mainly by the physics engine/plugin
  80436. */
  80437. physicsBody: any;
  80438. /**
  80439. * Get the parent of the physics imposter
  80440. * @returns Physics imposter or null
  80441. */
  80442. /**
  80443. * Sets the parent of the physics imposter
  80444. */
  80445. parent: Nullable<PhysicsImpostor>;
  80446. /**
  80447. * Resets the update flags
  80448. */
  80449. resetUpdateFlags(): void;
  80450. /**
  80451. * Gets the object extend size
  80452. * @returns the object extend size
  80453. */
  80454. getObjectExtendSize(): Vector3;
  80455. /**
  80456. * Gets the object center
  80457. * @returns The object center
  80458. */
  80459. getObjectCenter(): Vector3;
  80460. /**
  80461. * Get a specific parametes from the options parameter
  80462. * @param paramName The object parameter name
  80463. * @returns The object parameter
  80464. */
  80465. getParam(paramName: string): any;
  80466. /**
  80467. * Sets a specific parameter in the options given to the physics plugin
  80468. * @param paramName The parameter name
  80469. * @param value The value of the parameter
  80470. */
  80471. setParam(paramName: string, value: number): void;
  80472. /**
  80473. * Specifically change the body's mass option. Won't recreate the physics body object
  80474. * @param mass The mass of the physics imposter
  80475. */
  80476. setMass(mass: number): void;
  80477. /**
  80478. * Gets the linear velocity
  80479. * @returns linear velocity or null
  80480. */
  80481. getLinearVelocity(): Nullable<Vector3>;
  80482. /**
  80483. * Sets the linear velocity
  80484. * @param velocity linear velocity or null
  80485. */
  80486. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80487. /**
  80488. * Gets the angular velocity
  80489. * @returns angular velocity or null
  80490. */
  80491. getAngularVelocity(): Nullable<Vector3>;
  80492. /**
  80493. * Sets the angular velocity
  80494. * @param velocity The velocity or null
  80495. */
  80496. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80497. /**
  80498. * Execute a function with the physics plugin native code
  80499. * Provide a function the will have two variables - the world object and the physics body object
  80500. * @param func The function to execute with the physics plugin native code
  80501. */
  80502. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80503. /**
  80504. * Register a function that will be executed before the physics world is stepping forward
  80505. * @param func The function to execute before the physics world is stepped forward
  80506. */
  80507. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80508. /**
  80509. * Unregister a function that will be executed before the physics world is stepping forward
  80510. * @param func The function to execute before the physics world is stepped forward
  80511. */
  80512. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80513. /**
  80514. * Register a function that will be executed after the physics step
  80515. * @param func The function to execute after physics step
  80516. */
  80517. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80518. /**
  80519. * Unregisters a function that will be executed after the physics step
  80520. * @param func The function to execute after physics step
  80521. */
  80522. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80523. /**
  80524. * register a function that will be executed when this impostor collides against a different body
  80525. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80526. * @param func Callback that is executed on collision
  80527. */
  80528. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80529. /**
  80530. * Unregisters the physics imposter on contact
  80531. * @param collideAgainst The physics object to collide against
  80532. * @param func Callback to execute on collision
  80533. */
  80534. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80535. private _tmpQuat;
  80536. private _tmpQuat2;
  80537. /**
  80538. * Get the parent rotation
  80539. * @returns The parent rotation
  80540. */
  80541. getParentsRotation(): Quaternion;
  80542. /**
  80543. * this function is executed by the physics engine.
  80544. */
  80545. beforeStep: () => void;
  80546. /**
  80547. * this function is executed by the physics engine
  80548. */
  80549. afterStep: () => void;
  80550. /**
  80551. * Legacy collision detection event support
  80552. */
  80553. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80554. /**
  80555. * event and body object due to cannon's event-based architecture.
  80556. */
  80557. onCollide: (e: {
  80558. body: any;
  80559. }) => void;
  80560. /**
  80561. * Apply a force
  80562. * @param force The force to apply
  80563. * @param contactPoint The contact point for the force
  80564. * @returns The physics imposter
  80565. */
  80566. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80567. /**
  80568. * Apply an impulse
  80569. * @param force The impulse force
  80570. * @param contactPoint The contact point for the impulse force
  80571. * @returns The physics imposter
  80572. */
  80573. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80574. /**
  80575. * A help function to create a joint
  80576. * @param otherImpostor A physics imposter used to create a joint
  80577. * @param jointType The type of joint
  80578. * @param jointData The data for the joint
  80579. * @returns The physics imposter
  80580. */
  80581. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80582. /**
  80583. * Add a joint to this impostor with a different impostor
  80584. * @param otherImpostor A physics imposter used to add a joint
  80585. * @param joint The joint to add
  80586. * @returns The physics imposter
  80587. */
  80588. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80589. /**
  80590. * Add an anchor to a cloth impostor
  80591. * @param otherImpostor rigid impostor to anchor to
  80592. * @param width ratio across width from 0 to 1
  80593. * @param height ratio up height from 0 to 1
  80594. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80595. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80596. * @returns impostor the soft imposter
  80597. */
  80598. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80599. /**
  80600. * Add a hook to a rope impostor
  80601. * @param otherImpostor rigid impostor to anchor to
  80602. * @param length ratio across rope from 0 to 1
  80603. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80604. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80605. * @returns impostor the rope imposter
  80606. */
  80607. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80608. /**
  80609. * Will keep this body still, in a sleep mode.
  80610. * @returns the physics imposter
  80611. */
  80612. sleep(): PhysicsImpostor;
  80613. /**
  80614. * Wake the body up.
  80615. * @returns The physics imposter
  80616. */
  80617. wakeUp(): PhysicsImpostor;
  80618. /**
  80619. * Clones the physics imposter
  80620. * @param newObject The physics imposter clones to this physics-enabled object
  80621. * @returns A nullable physics imposter
  80622. */
  80623. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80624. /**
  80625. * Disposes the physics imposter
  80626. */
  80627. dispose(): void;
  80628. /**
  80629. * Sets the delta position
  80630. * @param position The delta position amount
  80631. */
  80632. setDeltaPosition(position: Vector3): void;
  80633. /**
  80634. * Sets the delta rotation
  80635. * @param rotation The delta rotation amount
  80636. */
  80637. setDeltaRotation(rotation: Quaternion): void;
  80638. /**
  80639. * Gets the box size of the physics imposter and stores the result in the input parameter
  80640. * @param result Stores the box size
  80641. * @returns The physics imposter
  80642. */
  80643. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80644. /**
  80645. * Gets the radius of the physics imposter
  80646. * @returns Radius of the physics imposter
  80647. */
  80648. getRadius(): number;
  80649. /**
  80650. * Sync a bone with this impostor
  80651. * @param bone The bone to sync to the impostor.
  80652. * @param boneMesh The mesh that the bone is influencing.
  80653. * @param jointPivot The pivot of the joint / bone in local space.
  80654. * @param distToJoint Optional distance from the impostor to the joint.
  80655. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80656. */
  80657. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80658. /**
  80659. * Sync impostor to a bone
  80660. * @param bone The bone that the impostor will be synced to.
  80661. * @param boneMesh The mesh that the bone is influencing.
  80662. * @param jointPivot The pivot of the joint / bone in local space.
  80663. * @param distToJoint Optional distance from the impostor to the joint.
  80664. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80665. * @param boneAxis Optional vector3 axis the bone is aligned with
  80666. */
  80667. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80668. /**
  80669. * No-Imposter type
  80670. */
  80671. static NoImpostor: number;
  80672. /**
  80673. * Sphere-Imposter type
  80674. */
  80675. static SphereImpostor: number;
  80676. /**
  80677. * Box-Imposter type
  80678. */
  80679. static BoxImpostor: number;
  80680. /**
  80681. * Plane-Imposter type
  80682. */
  80683. static PlaneImpostor: number;
  80684. /**
  80685. * Mesh-imposter type
  80686. */
  80687. static MeshImpostor: number;
  80688. /**
  80689. * Cylinder-Imposter type
  80690. */
  80691. static CylinderImpostor: number;
  80692. /**
  80693. * Particle-Imposter type
  80694. */
  80695. static ParticleImpostor: number;
  80696. /**
  80697. * Heightmap-Imposter type
  80698. */
  80699. static HeightmapImpostor: number;
  80700. /**
  80701. * ConvexHull-Impostor type (Ammo.js plugin only)
  80702. */
  80703. static ConvexHullImpostor: number;
  80704. /**
  80705. * Rope-Imposter type
  80706. */
  80707. static RopeImpostor: number;
  80708. /**
  80709. * Cloth-Imposter type
  80710. */
  80711. static ClothImpostor: number;
  80712. /**
  80713. * Softbody-Imposter type
  80714. */
  80715. static SoftbodyImpostor: number;
  80716. }
  80717. }
  80718. declare module BABYLON {
  80719. /**
  80720. * @hidden
  80721. **/
  80722. export class _CreationDataStorage {
  80723. closePath?: boolean;
  80724. closeArray?: boolean;
  80725. idx: number[];
  80726. dashSize: number;
  80727. gapSize: number;
  80728. path3D: Path3D;
  80729. pathArray: Vector3[][];
  80730. arc: number;
  80731. radius: number;
  80732. cap: number;
  80733. tessellation: number;
  80734. }
  80735. /**
  80736. * @hidden
  80737. **/
  80738. class _InstanceDataStorage {
  80739. visibleInstances: any;
  80740. batchCache: _InstancesBatch;
  80741. instancesBufferSize: number;
  80742. instancesBuffer: Nullable<Buffer>;
  80743. instancesData: Float32Array;
  80744. overridenInstanceCount: number;
  80745. isFrozen: boolean;
  80746. previousBatch: _InstancesBatch;
  80747. hardwareInstancedRendering: boolean;
  80748. sideOrientation: number;
  80749. }
  80750. /**
  80751. * @hidden
  80752. **/
  80753. export class _InstancesBatch {
  80754. mustReturn: boolean;
  80755. visibleInstances: Nullable<InstancedMesh[]>[];
  80756. renderSelf: boolean[];
  80757. hardwareInstancedRendering: boolean[];
  80758. }
  80759. /**
  80760. * Class used to represent renderable models
  80761. */
  80762. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80763. /**
  80764. * Mesh side orientation : usually the external or front surface
  80765. */
  80766. static readonly FRONTSIDE: number;
  80767. /**
  80768. * Mesh side orientation : usually the internal or back surface
  80769. */
  80770. static readonly BACKSIDE: number;
  80771. /**
  80772. * Mesh side orientation : both internal and external or front and back surfaces
  80773. */
  80774. static readonly DOUBLESIDE: number;
  80775. /**
  80776. * Mesh side orientation : by default, `FRONTSIDE`
  80777. */
  80778. static readonly DEFAULTSIDE: number;
  80779. /**
  80780. * Mesh cap setting : no cap
  80781. */
  80782. static readonly NO_CAP: number;
  80783. /**
  80784. * Mesh cap setting : one cap at the beginning of the mesh
  80785. */
  80786. static readonly CAP_START: number;
  80787. /**
  80788. * Mesh cap setting : one cap at the end of the mesh
  80789. */
  80790. static readonly CAP_END: number;
  80791. /**
  80792. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80793. */
  80794. static readonly CAP_ALL: number;
  80795. /**
  80796. * Gets the default side orientation.
  80797. * @param orientation the orientation to value to attempt to get
  80798. * @returns the default orientation
  80799. * @hidden
  80800. */
  80801. static _GetDefaultSideOrientation(orientation?: number): number;
  80802. private _onBeforeRenderObservable;
  80803. private _onBeforeBindObservable;
  80804. private _onAfterRenderObservable;
  80805. private _onBeforeDrawObservable;
  80806. /**
  80807. * An event triggered before rendering the mesh
  80808. */
  80809. readonly onBeforeRenderObservable: Observable<Mesh>;
  80810. /**
  80811. * An event triggered before binding the mesh
  80812. */
  80813. readonly onBeforeBindObservable: Observable<Mesh>;
  80814. /**
  80815. * An event triggered after rendering the mesh
  80816. */
  80817. readonly onAfterRenderObservable: Observable<Mesh>;
  80818. /**
  80819. * An event triggered before drawing the mesh
  80820. */
  80821. readonly onBeforeDrawObservable: Observable<Mesh>;
  80822. private _onBeforeDrawObserver;
  80823. /**
  80824. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80825. */
  80826. onBeforeDraw: () => void;
  80827. /**
  80828. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80829. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80830. */
  80831. delayLoadState: number;
  80832. /**
  80833. * Gets the list of instances created from this mesh
  80834. * it is not supposed to be modified manually.
  80835. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80836. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80837. */
  80838. instances: InstancedMesh[];
  80839. /**
  80840. * Gets the file containing delay loading data for this mesh
  80841. */
  80842. delayLoadingFile: string;
  80843. /** @hidden */
  80844. _binaryInfo: any;
  80845. private _LODLevels;
  80846. /**
  80847. * User defined function used to change how LOD level selection is done
  80848. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80849. */
  80850. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80851. private _morphTargetManager;
  80852. /**
  80853. * Gets or sets the morph target manager
  80854. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80855. */
  80856. morphTargetManager: Nullable<MorphTargetManager>;
  80857. /** @hidden */
  80858. _creationDataStorage: Nullable<_CreationDataStorage>;
  80859. /** @hidden */
  80860. _geometry: Nullable<Geometry>;
  80861. /** @hidden */
  80862. _delayInfo: Array<string>;
  80863. /** @hidden */
  80864. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80865. /** @hidden */
  80866. _instanceDataStorage: _InstanceDataStorage;
  80867. private _effectiveMaterial;
  80868. /** @hidden */
  80869. _shouldGenerateFlatShading: boolean;
  80870. private _preActivateId;
  80871. /** @hidden */
  80872. _originalBuilderSideOrientation: number;
  80873. /**
  80874. * Use this property to change the original side orientation defined at construction time
  80875. */
  80876. overrideMaterialSideOrientation: Nullable<number>;
  80877. private _areNormalsFrozen;
  80878. private _sourcePositions;
  80879. private _sourceNormals;
  80880. private _source;
  80881. private meshMap;
  80882. /**
  80883. * Gets the source mesh (the one used to clone this one from)
  80884. */
  80885. readonly source: Nullable<Mesh>;
  80886. /**
  80887. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80888. */
  80889. isUnIndexed: boolean;
  80890. /**
  80891. * @constructor
  80892. * @param name The value used by scene.getMeshByName() to do a lookup.
  80893. * @param scene The scene to add this mesh to.
  80894. * @param parent The parent of this mesh, if it has one
  80895. * @param source An optional Mesh from which geometry is shared, cloned.
  80896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80897. * When false, achieved by calling a clone(), also passing False.
  80898. * This will make creation of children, recursive.
  80899. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80900. */
  80901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80902. /**
  80903. * Gets the class name
  80904. * @returns the string "Mesh".
  80905. */
  80906. getClassName(): string;
  80907. /** @hidden */
  80908. readonly _isMesh: boolean;
  80909. /**
  80910. * Returns a description of this mesh
  80911. * @param fullDetails define if full details about this mesh must be used
  80912. * @returns a descriptive string representing this mesh
  80913. */
  80914. toString(fullDetails?: boolean): string;
  80915. /** @hidden */
  80916. _unBindEffect(): void;
  80917. /**
  80918. * Gets a boolean indicating if this mesh has LOD
  80919. */
  80920. readonly hasLODLevels: boolean;
  80921. /**
  80922. * Gets the list of MeshLODLevel associated with the current mesh
  80923. * @returns an array of MeshLODLevel
  80924. */
  80925. getLODLevels(): MeshLODLevel[];
  80926. private _sortLODLevels;
  80927. /**
  80928. * Add a mesh as LOD level triggered at the given distance.
  80929. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80930. * @param distance The distance from the center of the object to show this level
  80931. * @param mesh The mesh to be added as LOD level (can be null)
  80932. * @return This mesh (for chaining)
  80933. */
  80934. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80935. /**
  80936. * Returns the LOD level mesh at the passed distance or null if not found.
  80937. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80938. * @param distance The distance from the center of the object to show this level
  80939. * @returns a Mesh or `null`
  80940. */
  80941. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80942. /**
  80943. * Remove a mesh from the LOD array
  80944. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80945. * @param mesh defines the mesh to be removed
  80946. * @return This mesh (for chaining)
  80947. */
  80948. removeLODLevel(mesh: Mesh): Mesh;
  80949. /**
  80950. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80951. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80952. * @param camera defines the camera to use to compute distance
  80953. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80954. * @return This mesh (for chaining)
  80955. */
  80956. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80957. /**
  80958. * Gets the mesh internal Geometry object
  80959. */
  80960. readonly geometry: Nullable<Geometry>;
  80961. /**
  80962. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80963. * @returns the total number of vertices
  80964. */
  80965. getTotalVertices(): number;
  80966. /**
  80967. * Returns the content of an associated vertex buffer
  80968. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80969. * - VertexBuffer.PositionKind
  80970. * - VertexBuffer.UVKind
  80971. * - VertexBuffer.UV2Kind
  80972. * - VertexBuffer.UV3Kind
  80973. * - VertexBuffer.UV4Kind
  80974. * - VertexBuffer.UV5Kind
  80975. * - VertexBuffer.UV6Kind
  80976. * - VertexBuffer.ColorKind
  80977. * - VertexBuffer.MatricesIndicesKind
  80978. * - VertexBuffer.MatricesIndicesExtraKind
  80979. * - VertexBuffer.MatricesWeightsKind
  80980. * - VertexBuffer.MatricesWeightsExtraKind
  80981. * @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
  80982. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80983. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80984. */
  80985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80986. /**
  80987. * Returns the mesh VertexBuffer object from the requested `kind`
  80988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80989. * - VertexBuffer.PositionKind
  80990. * - VertexBuffer.UVKind
  80991. * - VertexBuffer.UV2Kind
  80992. * - VertexBuffer.UV3Kind
  80993. * - VertexBuffer.UV4Kind
  80994. * - VertexBuffer.UV5Kind
  80995. * - VertexBuffer.UV6Kind
  80996. * - VertexBuffer.ColorKind
  80997. * - VertexBuffer.MatricesIndicesKind
  80998. * - VertexBuffer.MatricesIndicesExtraKind
  80999. * - VertexBuffer.MatricesWeightsKind
  81000. * - VertexBuffer.MatricesWeightsExtraKind
  81001. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81002. */
  81003. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81004. /**
  81005. * Tests if a specific vertex buffer is associated with this mesh
  81006. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81007. * - VertexBuffer.PositionKind
  81008. * - VertexBuffer.UVKind
  81009. * - VertexBuffer.UV2Kind
  81010. * - VertexBuffer.UV3Kind
  81011. * - VertexBuffer.UV4Kind
  81012. * - VertexBuffer.UV5Kind
  81013. * - VertexBuffer.UV6Kind
  81014. * - VertexBuffer.ColorKind
  81015. * - VertexBuffer.MatricesIndicesKind
  81016. * - VertexBuffer.MatricesIndicesExtraKind
  81017. * - VertexBuffer.MatricesWeightsKind
  81018. * - VertexBuffer.MatricesWeightsExtraKind
  81019. * @returns a boolean
  81020. */
  81021. isVerticesDataPresent(kind: string): boolean;
  81022. /**
  81023. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81024. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81025. * - VertexBuffer.PositionKind
  81026. * - VertexBuffer.UVKind
  81027. * - VertexBuffer.UV2Kind
  81028. * - VertexBuffer.UV3Kind
  81029. * - VertexBuffer.UV4Kind
  81030. * - VertexBuffer.UV5Kind
  81031. * - VertexBuffer.UV6Kind
  81032. * - VertexBuffer.ColorKind
  81033. * - VertexBuffer.MatricesIndicesKind
  81034. * - VertexBuffer.MatricesIndicesExtraKind
  81035. * - VertexBuffer.MatricesWeightsKind
  81036. * - VertexBuffer.MatricesWeightsExtraKind
  81037. * @returns a boolean
  81038. */
  81039. isVertexBufferUpdatable(kind: string): boolean;
  81040. /**
  81041. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81042. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81043. * - VertexBuffer.PositionKind
  81044. * - VertexBuffer.UVKind
  81045. * - VertexBuffer.UV2Kind
  81046. * - VertexBuffer.UV3Kind
  81047. * - VertexBuffer.UV4Kind
  81048. * - VertexBuffer.UV5Kind
  81049. * - VertexBuffer.UV6Kind
  81050. * - VertexBuffer.ColorKind
  81051. * - VertexBuffer.MatricesIndicesKind
  81052. * - VertexBuffer.MatricesIndicesExtraKind
  81053. * - VertexBuffer.MatricesWeightsKind
  81054. * - VertexBuffer.MatricesWeightsExtraKind
  81055. * @returns an array of strings
  81056. */
  81057. getVerticesDataKinds(): string[];
  81058. /**
  81059. * Returns a positive integer : the total number of indices in this mesh geometry.
  81060. * @returns the numner of indices or zero if the mesh has no geometry.
  81061. */
  81062. getTotalIndices(): number;
  81063. /**
  81064. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81065. * @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.
  81066. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81067. * @returns the indices array or an empty array if the mesh has no geometry
  81068. */
  81069. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81070. readonly isBlocked: boolean;
  81071. /**
  81072. * Determine if the current mesh is ready to be rendered
  81073. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81074. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81075. * @returns true if all associated assets are ready (material, textures, shaders)
  81076. */
  81077. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81078. /**
  81079. * 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.
  81080. */
  81081. readonly areNormalsFrozen: boolean;
  81082. /**
  81083. * 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.
  81084. * @returns the current mesh
  81085. */
  81086. freezeNormals(): Mesh;
  81087. /**
  81088. * 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
  81089. * @returns the current mesh
  81090. */
  81091. unfreezeNormals(): Mesh;
  81092. /**
  81093. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81094. */
  81095. overridenInstanceCount: number;
  81096. /** @hidden */
  81097. _preActivate(): Mesh;
  81098. /** @hidden */
  81099. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81100. /** @hidden */
  81101. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81102. /**
  81103. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81104. * This means the mesh underlying bounding box and sphere are recomputed.
  81105. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81106. * @returns the current mesh
  81107. */
  81108. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81109. /** @hidden */
  81110. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81111. /**
  81112. * This function will subdivide the mesh into multiple submeshes
  81113. * @param count defines the expected number of submeshes
  81114. */
  81115. subdivide(count: number): void;
  81116. /**
  81117. * Copy a FloatArray into a specific associated vertex buffer
  81118. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81119. * - VertexBuffer.PositionKind
  81120. * - VertexBuffer.UVKind
  81121. * - VertexBuffer.UV2Kind
  81122. * - VertexBuffer.UV3Kind
  81123. * - VertexBuffer.UV4Kind
  81124. * - VertexBuffer.UV5Kind
  81125. * - VertexBuffer.UV6Kind
  81126. * - VertexBuffer.ColorKind
  81127. * - VertexBuffer.MatricesIndicesKind
  81128. * - VertexBuffer.MatricesIndicesExtraKind
  81129. * - VertexBuffer.MatricesWeightsKind
  81130. * - VertexBuffer.MatricesWeightsExtraKind
  81131. * @param data defines the data source
  81132. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81133. * @param stride defines the data stride size (can be null)
  81134. * @returns the current mesh
  81135. */
  81136. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81137. /**
  81138. * Flags an associated vertex buffer as updatable
  81139. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81140. * - VertexBuffer.PositionKind
  81141. * - VertexBuffer.UVKind
  81142. * - VertexBuffer.UV2Kind
  81143. * - VertexBuffer.UV3Kind
  81144. * - VertexBuffer.UV4Kind
  81145. * - VertexBuffer.UV5Kind
  81146. * - VertexBuffer.UV6Kind
  81147. * - VertexBuffer.ColorKind
  81148. * - VertexBuffer.MatricesIndicesKind
  81149. * - VertexBuffer.MatricesIndicesExtraKind
  81150. * - VertexBuffer.MatricesWeightsKind
  81151. * - VertexBuffer.MatricesWeightsExtraKind
  81152. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81153. */
  81154. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81155. /**
  81156. * Sets the mesh global Vertex Buffer
  81157. * @param buffer defines the buffer to use
  81158. * @returns the current mesh
  81159. */
  81160. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81161. /**
  81162. * Update a specific associated vertex buffer
  81163. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81164. * - VertexBuffer.PositionKind
  81165. * - VertexBuffer.UVKind
  81166. * - VertexBuffer.UV2Kind
  81167. * - VertexBuffer.UV3Kind
  81168. * - VertexBuffer.UV4Kind
  81169. * - VertexBuffer.UV5Kind
  81170. * - VertexBuffer.UV6Kind
  81171. * - VertexBuffer.ColorKind
  81172. * - VertexBuffer.MatricesIndicesKind
  81173. * - VertexBuffer.MatricesIndicesExtraKind
  81174. * - VertexBuffer.MatricesWeightsKind
  81175. * - VertexBuffer.MatricesWeightsExtraKind
  81176. * @param data defines the data source
  81177. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81178. * @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)
  81179. * @returns the current mesh
  81180. */
  81181. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81182. /**
  81183. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81184. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81185. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81186. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81187. * @returns the current mesh
  81188. */
  81189. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81190. /**
  81191. * Creates a un-shared specific occurence of the geometry for the mesh.
  81192. * @returns the current mesh
  81193. */
  81194. makeGeometryUnique(): Mesh;
  81195. /**
  81196. * Set the index buffer of this mesh
  81197. * @param indices defines the source data
  81198. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81199. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81200. * @returns the current mesh
  81201. */
  81202. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81203. /**
  81204. * Update the current index buffer
  81205. * @param indices defines the source data
  81206. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81207. * @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)
  81208. * @returns the current mesh
  81209. */
  81210. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81211. /**
  81212. * Invert the geometry to move from a right handed system to a left handed one.
  81213. * @returns the current mesh
  81214. */
  81215. toLeftHanded(): Mesh;
  81216. /** @hidden */
  81217. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81218. /** @hidden */
  81219. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81220. /**
  81221. * Registers for this mesh a javascript function called just before the rendering process
  81222. * @param func defines the function to call before rendering this mesh
  81223. * @returns the current mesh
  81224. */
  81225. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81226. /**
  81227. * Disposes a previously registered javascript function called before the rendering
  81228. * @param func defines the function to remove
  81229. * @returns the current mesh
  81230. */
  81231. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81232. /**
  81233. * Registers for this mesh a javascript function called just after the rendering is complete
  81234. * @param func defines the function to call after rendering this mesh
  81235. * @returns the current mesh
  81236. */
  81237. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81238. /**
  81239. * Disposes a previously registered javascript function called after the rendering.
  81240. * @param func defines the function to remove
  81241. * @returns the current mesh
  81242. */
  81243. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81244. /** @hidden */
  81245. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81246. /** @hidden */
  81247. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81248. /** @hidden */
  81249. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81250. /** @hidden */
  81251. _freeze(): void;
  81252. /** @hidden */
  81253. _unFreeze(): void;
  81254. /**
  81255. * 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
  81256. * @param subMesh defines the subMesh to render
  81257. * @param enableAlphaMode defines if alpha mode can be changed
  81258. * @returns the current mesh
  81259. */
  81260. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81261. private _onBeforeDraw;
  81262. /**
  81263. * Renormalize the mesh and patch it up if there are no weights
  81264. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81265. * However in the case of zero weights then we set just a single influence to 1.
  81266. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81267. */
  81268. cleanMatrixWeights(): void;
  81269. private normalizeSkinFourWeights;
  81270. private normalizeSkinWeightsAndExtra;
  81271. /**
  81272. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81273. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81274. * the user know there was an issue with importing the mesh
  81275. * @returns a validation object with skinned, valid and report string
  81276. */
  81277. validateSkinning(): {
  81278. skinned: boolean;
  81279. valid: boolean;
  81280. report: string;
  81281. };
  81282. /** @hidden */
  81283. _checkDelayState(): Mesh;
  81284. private _queueLoad;
  81285. /**
  81286. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81287. * A mesh is in the frustum if its bounding box intersects the frustum
  81288. * @param frustumPlanes defines the frustum to test
  81289. * @returns true if the mesh is in the frustum planes
  81290. */
  81291. isInFrustum(frustumPlanes: Plane[]): boolean;
  81292. /**
  81293. * Sets the mesh material by the material or multiMaterial `id` property
  81294. * @param id is a string identifying the material or the multiMaterial
  81295. * @returns the current mesh
  81296. */
  81297. setMaterialByID(id: string): Mesh;
  81298. /**
  81299. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81300. * @returns an array of IAnimatable
  81301. */
  81302. getAnimatables(): IAnimatable[];
  81303. /**
  81304. * Modifies the mesh geometry according to the passed transformation matrix.
  81305. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81306. * The mesh normals are modified using the same transformation.
  81307. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81308. * @param transform defines the transform matrix to use
  81309. * @see http://doc.babylonjs.com/resources/baking_transformations
  81310. * @returns the current mesh
  81311. */
  81312. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81313. /**
  81314. * Modifies the mesh geometry according to its own current World Matrix.
  81315. * The mesh World Matrix is then reset.
  81316. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81317. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81318. * @see http://doc.babylonjs.com/resources/baking_transformations
  81319. * @returns the current mesh
  81320. */
  81321. bakeCurrentTransformIntoVertices(): Mesh;
  81322. /** @hidden */
  81323. readonly _positions: Nullable<Vector3[]>;
  81324. /** @hidden */
  81325. _resetPointsArrayCache(): Mesh;
  81326. /** @hidden */
  81327. _generatePointsArray(): boolean;
  81328. /**
  81329. * Returns a new Mesh object generated from the current mesh properties.
  81330. * This method must not get confused with createInstance()
  81331. * @param name is a string, the name given to the new mesh
  81332. * @param newParent can be any Node object (default `null`)
  81333. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81334. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81335. * @returns a new mesh
  81336. */
  81337. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81338. /**
  81339. * Releases resources associated with this mesh.
  81340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81342. */
  81343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81344. /**
  81345. * Modifies the mesh geometry according to a displacement map.
  81346. * 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.
  81347. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81348. * @param url is a string, the URL from the image file is to be downloaded.
  81349. * @param minHeight is the lower limit of the displacement.
  81350. * @param maxHeight is the upper limit of the displacement.
  81351. * @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.
  81352. * @param uvOffset is an optional vector2 used to offset UV.
  81353. * @param uvScale is an optional vector2 used to scale UV.
  81354. * @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.
  81355. * @returns the Mesh.
  81356. */
  81357. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81358. /**
  81359. * Modifies the mesh geometry according to a displacementMap buffer.
  81360. * 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.
  81361. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81362. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81363. * @param heightMapWidth is the width of the buffer image.
  81364. * @param heightMapHeight is the height of the buffer image.
  81365. * @param minHeight is the lower limit of the displacement.
  81366. * @param maxHeight is the upper limit of the displacement.
  81367. * @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.
  81368. * @param uvOffset is an optional vector2 used to offset UV.
  81369. * @param uvScale is an optional vector2 used to scale UV.
  81370. * @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.
  81371. * @returns the Mesh.
  81372. */
  81373. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81374. /**
  81375. * Modify the mesh to get a flat shading rendering.
  81376. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81377. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81378. * @returns current mesh
  81379. */
  81380. convertToFlatShadedMesh(): Mesh;
  81381. /**
  81382. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81383. * In other words, more vertices, no more indices and a single bigger VBO.
  81384. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81385. * @returns current mesh
  81386. */
  81387. convertToUnIndexedMesh(): Mesh;
  81388. /**
  81389. * Inverses facet orientations.
  81390. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81391. * @param flipNormals will also inverts the normals
  81392. * @returns current mesh
  81393. */
  81394. flipFaces(flipNormals?: boolean): Mesh;
  81395. /**
  81396. * Increase the number of facets and hence vertices in a mesh
  81397. * Vertex normals are interpolated from existing vertex normals
  81398. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81399. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81400. */
  81401. increaseVertices(numberPerEdge: number): void;
  81402. /**
  81403. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81404. * This will undo any application of covertToFlatShadedMesh
  81405. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81406. */
  81407. forceSharedVertices(): void;
  81408. /** @hidden */
  81409. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81410. /** @hidden */
  81411. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81412. /**
  81413. * Creates a new InstancedMesh object from the mesh model.
  81414. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81415. * @param name defines the name of the new instance
  81416. * @returns a new InstancedMesh
  81417. */
  81418. createInstance(name: string): InstancedMesh;
  81419. /**
  81420. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81421. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81422. * @returns the current mesh
  81423. */
  81424. synchronizeInstances(): Mesh;
  81425. /**
  81426. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81427. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81428. * This should be used together with the simplification to avoid disappearing triangles.
  81429. * @param successCallback an optional success callback to be called after the optimization finished.
  81430. * @returns the current mesh
  81431. */
  81432. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81433. /**
  81434. * Serialize current mesh
  81435. * @param serializationObject defines the object which will receive the serialization data
  81436. */
  81437. serialize(serializationObject: any): void;
  81438. /** @hidden */
  81439. _syncGeometryWithMorphTargetManager(): void;
  81440. /** @hidden */
  81441. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81442. /**
  81443. * Returns a new Mesh object parsed from the source provided.
  81444. * @param parsedMesh is the source
  81445. * @param scene defines the hosting scene
  81446. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81447. * @returns a new Mesh
  81448. */
  81449. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81450. /**
  81451. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81452. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81453. * @param name defines the name of the mesh to create
  81454. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81455. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81456. * @param closePath creates a seam between the first and the last points of each path of the path array
  81457. * @param offset is taken in account only if the `pathArray` is containing a single path
  81458. * @param scene defines the hosting scene
  81459. * @param updatable defines if the mesh must be flagged as updatable
  81460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81461. * @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)
  81462. * @returns a new Mesh
  81463. */
  81464. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81465. /**
  81466. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81467. * @param name defines the name of the mesh to create
  81468. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81469. * @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
  81470. * @param scene defines the hosting scene
  81471. * @param updatable defines if the mesh must be flagged as updatable
  81472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81473. * @returns a new Mesh
  81474. */
  81475. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81476. /**
  81477. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81478. * @param name defines the name of the mesh to create
  81479. * @param size sets the size (float) of each box side (default 1)
  81480. * @param scene defines the hosting scene
  81481. * @param updatable defines if the mesh must be flagged as updatable
  81482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81483. * @returns a new Mesh
  81484. */
  81485. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81486. /**
  81487. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81488. * @param name defines the name of the mesh to create
  81489. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81490. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81491. * @param scene defines the hosting scene
  81492. * @param updatable defines if the mesh must be flagged as updatable
  81493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81494. * @returns a new Mesh
  81495. */
  81496. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81497. /**
  81498. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81499. * @param name defines the name of the mesh to create
  81500. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81501. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81502. * @param scene defines the hosting scene
  81503. * @returns a new Mesh
  81504. */
  81505. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81506. /**
  81507. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81508. * @param name defines the name of the mesh to create
  81509. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81510. * @param diameterTop set the top cap diameter (floats, default 1)
  81511. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81512. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81513. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81514. * @param scene defines the hosting scene
  81515. * @param updatable defines if the mesh must be flagged as updatable
  81516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81517. * @returns a new Mesh
  81518. */
  81519. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81520. /**
  81521. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81522. * @param name defines the name of the mesh to create
  81523. * @param diameter sets the diameter size (float) of the torus (default 1)
  81524. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81525. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81526. * @param scene defines the hosting scene
  81527. * @param updatable defines if the mesh must be flagged as updatable
  81528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81529. * @returns a new Mesh
  81530. */
  81531. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81532. /**
  81533. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81534. * @param name defines the name of the mesh to create
  81535. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81536. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81537. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81538. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81539. * @param p the number of windings on X axis (positive integers, default 2)
  81540. * @param q the number of windings on Y axis (positive integers, default 3)
  81541. * @param scene defines the hosting scene
  81542. * @param updatable defines if the mesh must be flagged as updatable
  81543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81544. * @returns a new Mesh
  81545. */
  81546. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81547. /**
  81548. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81549. * @param name defines the name of the mesh to create
  81550. * @param points is an array successive Vector3
  81551. * @param scene defines the hosting scene
  81552. * @param updatable defines if the mesh must be flagged as updatable
  81553. * @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).
  81554. * @returns a new Mesh
  81555. */
  81556. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81557. /**
  81558. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81559. * @param name defines the name of the mesh to create
  81560. * @param points is an array successive Vector3
  81561. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81562. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81563. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81564. * @param scene defines the hosting scene
  81565. * @param updatable defines if the mesh must be flagged as updatable
  81566. * @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)
  81567. * @returns a new Mesh
  81568. */
  81569. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81570. /**
  81571. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81572. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81573. * 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.
  81574. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81575. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81576. * Remember you can only change the shape positions, not their number when updating a polygon.
  81577. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81578. * @param name defines the name of the mesh to create
  81579. * @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
  81580. * @param scene defines the hosting scene
  81581. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81582. * @param updatable defines if the mesh must be flagged as updatable
  81583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81584. * @param earcutInjection can be used to inject your own earcut reference
  81585. * @returns a new Mesh
  81586. */
  81587. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81588. /**
  81589. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81590. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81591. * @param name defines the name of the mesh to create
  81592. * @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
  81593. * @param depth defines the height of extrusion
  81594. * @param scene defines the hosting scene
  81595. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81596. * @param updatable defines if the mesh must be flagged as updatable
  81597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81598. * @param earcutInjection can be used to inject your own earcut reference
  81599. * @returns a new Mesh
  81600. */
  81601. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81602. /**
  81603. * Creates an extruded shape mesh.
  81604. * 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
  81605. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81606. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81607. * @param name defines the name of the mesh to create
  81608. * @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
  81609. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81610. * @param scale is the value to scale the shape
  81611. * @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
  81612. * @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
  81613. * @param scene defines the hosting scene
  81614. * @param updatable defines if the mesh must be flagged as updatable
  81615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81616. * @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)
  81617. * @returns a new Mesh
  81618. */
  81619. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81620. /**
  81621. * Creates an custom extruded shape mesh.
  81622. * The custom extrusion is a parametric shape.
  81623. * It has no predefined shape. Its final shape will depend on the input parameters.
  81624. * Please consider using the same method from the MeshBuilder class instead
  81625. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81626. * @param name defines the name of the mesh to create
  81627. * @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
  81628. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81629. * @param scaleFunction is a custom Javascript function called on each path point
  81630. * @param rotationFunction is a custom Javascript function called on each path point
  81631. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81632. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81633. * @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
  81634. * @param scene defines the hosting scene
  81635. * @param updatable defines if the mesh must be flagged as updatable
  81636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81637. * @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)
  81638. * @returns a new Mesh
  81639. */
  81640. 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;
  81641. /**
  81642. * Creates lathe mesh.
  81643. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81644. * Please consider using the same method from the MeshBuilder class instead
  81645. * @param name defines the name of the mesh to create
  81646. * @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
  81647. * @param radius is the radius value of the lathe
  81648. * @param tessellation is the side number of the lathe.
  81649. * @param scene defines the hosting scene
  81650. * @param updatable defines if the mesh must be flagged as updatable
  81651. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81652. * @returns a new Mesh
  81653. */
  81654. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81655. /**
  81656. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81657. * @param name defines the name of the mesh to create
  81658. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81659. * @param scene defines the hosting scene
  81660. * @param updatable defines if the mesh must be flagged as updatable
  81661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81662. * @returns a new Mesh
  81663. */
  81664. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81665. /**
  81666. * Creates a ground mesh.
  81667. * Please consider using the same method from the MeshBuilder class instead
  81668. * @param name defines the name of the mesh to create
  81669. * @param width set the width of the ground
  81670. * @param height set the height of the ground
  81671. * @param subdivisions sets the number of subdivisions per side
  81672. * @param scene defines the hosting scene
  81673. * @param updatable defines if the mesh must be flagged as updatable
  81674. * @returns a new Mesh
  81675. */
  81676. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81677. /**
  81678. * Creates a tiled ground mesh.
  81679. * Please consider using the same method from the MeshBuilder class instead
  81680. * @param name defines the name of the mesh to create
  81681. * @param xmin set the ground minimum X coordinate
  81682. * @param zmin set the ground minimum Y coordinate
  81683. * @param xmax set the ground maximum X coordinate
  81684. * @param zmax set the ground maximum Z coordinate
  81685. * @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
  81686. * @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
  81687. * @param scene defines the hosting scene
  81688. * @param updatable defines if the mesh must be flagged as updatable
  81689. * @returns a new Mesh
  81690. */
  81691. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81692. w: number;
  81693. h: number;
  81694. }, precision: {
  81695. w: number;
  81696. h: number;
  81697. }, scene: Scene, updatable?: boolean): Mesh;
  81698. /**
  81699. * Creates a ground mesh from a height map.
  81700. * Please consider using the same method from the MeshBuilder class instead
  81701. * @see http://doc.babylonjs.com/babylon101/height_map
  81702. * @param name defines the name of the mesh to create
  81703. * @param url sets the URL of the height map image resource
  81704. * @param width set the ground width size
  81705. * @param height set the ground height size
  81706. * @param subdivisions sets the number of subdivision per side
  81707. * @param minHeight is the minimum altitude on the ground
  81708. * @param maxHeight is the maximum altitude on the ground
  81709. * @param scene defines the hosting scene
  81710. * @param updatable defines if the mesh must be flagged as updatable
  81711. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81712. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81713. * @returns a new Mesh
  81714. */
  81715. 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;
  81716. /**
  81717. * Creates a tube mesh.
  81718. * The tube is a parametric shape.
  81719. * It has no predefined shape. Its final shape will depend on the input parameters.
  81720. * Please consider using the same method from the MeshBuilder class instead
  81721. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81722. * @param name defines the name of the mesh to create
  81723. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81724. * @param radius sets the tube radius size
  81725. * @param tessellation is the number of sides on the tubular surface
  81726. * @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
  81727. * @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
  81728. * @param scene defines the hosting scene
  81729. * @param updatable defines if the mesh must be flagged as updatable
  81730. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81731. * @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)
  81732. * @returns a new Mesh
  81733. */
  81734. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81735. (i: number, distance: number): number;
  81736. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81737. /**
  81738. * Creates a polyhedron mesh.
  81739. * Please consider using the same method from the MeshBuilder class instead.
  81740. * * 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
  81741. * * The parameter `size` (positive float, default 1) sets the polygon size
  81742. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81743. * * 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`
  81744. * * 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
  81745. * * 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)`)
  81746. * * 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
  81747. * * 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
  81748. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81749. * * If you create a double-sided mesh, you can choose what parts of 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
  81750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81751. * @param name defines the name of the mesh to create
  81752. * @param options defines the options used to create the mesh
  81753. * @param scene defines the hosting scene
  81754. * @returns a new Mesh
  81755. */
  81756. static CreatePolyhedron(name: string, options: {
  81757. type?: number;
  81758. size?: number;
  81759. sizeX?: number;
  81760. sizeY?: number;
  81761. sizeZ?: number;
  81762. custom?: any;
  81763. faceUV?: Vector4[];
  81764. faceColors?: Color4[];
  81765. updatable?: boolean;
  81766. sideOrientation?: number;
  81767. }, scene: Scene): Mesh;
  81768. /**
  81769. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81770. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81771. * * 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`)
  81772. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81773. * * 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
  81774. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81775. * * If you create a double-sided mesh, you can choose what parts of 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
  81776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81777. * @param name defines the name of the mesh
  81778. * @param options defines the options used to create the mesh
  81779. * @param scene defines the hosting scene
  81780. * @returns a new Mesh
  81781. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81782. */
  81783. static CreateIcoSphere(name: string, options: {
  81784. radius?: number;
  81785. flat?: boolean;
  81786. subdivisions?: number;
  81787. sideOrientation?: number;
  81788. updatable?: boolean;
  81789. }, scene: Scene): Mesh;
  81790. /**
  81791. * Creates a decal mesh.
  81792. * Please consider using the same method from the MeshBuilder class instead.
  81793. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81794. * @param name defines the name of the mesh
  81795. * @param sourceMesh defines the mesh receiving the decal
  81796. * @param position sets the position of the decal in world coordinates
  81797. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81798. * @param size sets the decal scaling
  81799. * @param angle sets the angle to rotate the decal
  81800. * @returns a new Mesh
  81801. */
  81802. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81803. /**
  81804. * Prepare internal position array for software CPU skinning
  81805. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81806. */
  81807. setPositionsForCPUSkinning(): Float32Array;
  81808. /**
  81809. * Prepare internal normal array for software CPU skinning
  81810. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81811. */
  81812. setNormalsForCPUSkinning(): Float32Array;
  81813. /**
  81814. * Updates the vertex buffer by applying transformation from the bones
  81815. * @param skeleton defines the skeleton to apply to current mesh
  81816. * @returns the current mesh
  81817. */
  81818. applySkeleton(skeleton: Skeleton): Mesh;
  81819. /**
  81820. * 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
  81821. * @param meshes defines the list of meshes to scan
  81822. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81823. */
  81824. static MinMax(meshes: AbstractMesh[]): {
  81825. min: Vector3;
  81826. max: Vector3;
  81827. };
  81828. /**
  81829. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81830. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81831. * @returns a vector3
  81832. */
  81833. static Center(meshesOrMinMaxVector: {
  81834. min: Vector3;
  81835. max: Vector3;
  81836. } | AbstractMesh[]): Vector3;
  81837. /**
  81838. * Merge the array of meshes into a single mesh for performance reasons.
  81839. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81840. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81841. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81842. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81843. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81844. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81845. * @returns a new mesh
  81846. */
  81847. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81848. /** @hidden */
  81849. addInstance(instance: InstancedMesh): void;
  81850. /** @hidden */
  81851. removeInstance(instance: InstancedMesh): void;
  81852. }
  81853. }
  81854. declare module BABYLON {
  81855. /**
  81856. * Base class for the main features of a material in Babylon.js
  81857. */
  81858. export class Material implements IAnimatable {
  81859. /**
  81860. * Returns the triangle fill mode
  81861. */
  81862. static readonly TriangleFillMode: number;
  81863. /**
  81864. * Returns the wireframe mode
  81865. */
  81866. static readonly WireFrameFillMode: number;
  81867. /**
  81868. * Returns the point fill mode
  81869. */
  81870. static readonly PointFillMode: number;
  81871. /**
  81872. * Returns the point list draw mode
  81873. */
  81874. static readonly PointListDrawMode: number;
  81875. /**
  81876. * Returns the line list draw mode
  81877. */
  81878. static readonly LineListDrawMode: number;
  81879. /**
  81880. * Returns the line loop draw mode
  81881. */
  81882. static readonly LineLoopDrawMode: number;
  81883. /**
  81884. * Returns the line strip draw mode
  81885. */
  81886. static readonly LineStripDrawMode: number;
  81887. /**
  81888. * Returns the triangle strip draw mode
  81889. */
  81890. static readonly TriangleStripDrawMode: number;
  81891. /**
  81892. * Returns the triangle fan draw mode
  81893. */
  81894. static readonly TriangleFanDrawMode: number;
  81895. /**
  81896. * Stores the clock-wise side orientation
  81897. */
  81898. static readonly ClockWiseSideOrientation: number;
  81899. /**
  81900. * Stores the counter clock-wise side orientation
  81901. */
  81902. static readonly CounterClockWiseSideOrientation: number;
  81903. /**
  81904. * The dirty texture flag value
  81905. */
  81906. static readonly TextureDirtyFlag: number;
  81907. /**
  81908. * The dirty light flag value
  81909. */
  81910. static readonly LightDirtyFlag: number;
  81911. /**
  81912. * The dirty fresnel flag value
  81913. */
  81914. static readonly FresnelDirtyFlag: number;
  81915. /**
  81916. * The dirty attribute flag value
  81917. */
  81918. static readonly AttributesDirtyFlag: number;
  81919. /**
  81920. * The dirty misc flag value
  81921. */
  81922. static readonly MiscDirtyFlag: number;
  81923. /**
  81924. * The all dirty flag value
  81925. */
  81926. static readonly AllDirtyFlag: number;
  81927. /**
  81928. * The ID of the material
  81929. */
  81930. id: string;
  81931. /**
  81932. * Gets or sets the unique id of the material
  81933. */
  81934. uniqueId: number;
  81935. /**
  81936. * The name of the material
  81937. */
  81938. name: string;
  81939. /**
  81940. * Gets or sets user defined metadata
  81941. */
  81942. metadata: any;
  81943. /**
  81944. * For internal use only. Please do not use.
  81945. */
  81946. reservedDataStore: any;
  81947. /**
  81948. * Specifies if the ready state should be checked on each call
  81949. */
  81950. checkReadyOnEveryCall: boolean;
  81951. /**
  81952. * Specifies if the ready state should be checked once
  81953. */
  81954. checkReadyOnlyOnce: boolean;
  81955. /**
  81956. * The state of the material
  81957. */
  81958. state: string;
  81959. /**
  81960. * The alpha value of the material
  81961. */
  81962. protected _alpha: number;
  81963. /**
  81964. * List of inspectable custom properties (used by the Inspector)
  81965. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81966. */
  81967. inspectableCustomProperties: IInspectable[];
  81968. /**
  81969. * Sets the alpha value of the material
  81970. */
  81971. /**
  81972. * Gets the alpha value of the material
  81973. */
  81974. alpha: number;
  81975. /**
  81976. * Specifies if back face culling is enabled
  81977. */
  81978. protected _backFaceCulling: boolean;
  81979. /**
  81980. * Sets the back-face culling state
  81981. */
  81982. /**
  81983. * Gets the back-face culling state
  81984. */
  81985. backFaceCulling: boolean;
  81986. /**
  81987. * Stores the value for side orientation
  81988. */
  81989. sideOrientation: number;
  81990. /**
  81991. * Callback triggered when the material is compiled
  81992. */
  81993. onCompiled: Nullable<(effect: Effect) => void>;
  81994. /**
  81995. * Callback triggered when an error occurs
  81996. */
  81997. onError: Nullable<(effect: Effect, errors: string) => void>;
  81998. /**
  81999. * Callback triggered to get the render target textures
  82000. */
  82001. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82002. /**
  82003. * Gets a boolean indicating that current material needs to register RTT
  82004. */
  82005. readonly hasRenderTargetTextures: boolean;
  82006. /**
  82007. * Specifies if the material should be serialized
  82008. */
  82009. doNotSerialize: boolean;
  82010. /**
  82011. * @hidden
  82012. */
  82013. _storeEffectOnSubMeshes: boolean;
  82014. /**
  82015. * Stores the animations for the material
  82016. */
  82017. animations: Nullable<Array<Animation>>;
  82018. /**
  82019. * An event triggered when the material is disposed
  82020. */
  82021. onDisposeObservable: Observable<Material>;
  82022. /**
  82023. * An observer which watches for dispose events
  82024. */
  82025. private _onDisposeObserver;
  82026. private _onUnBindObservable;
  82027. /**
  82028. * Called during a dispose event
  82029. */
  82030. onDispose: () => void;
  82031. private _onBindObservable;
  82032. /**
  82033. * An event triggered when the material is bound
  82034. */
  82035. readonly onBindObservable: Observable<AbstractMesh>;
  82036. /**
  82037. * An observer which watches for bind events
  82038. */
  82039. private _onBindObserver;
  82040. /**
  82041. * Called during a bind event
  82042. */
  82043. onBind: (Mesh: AbstractMesh) => void;
  82044. /**
  82045. * An event triggered when the material is unbound
  82046. */
  82047. readonly onUnBindObservable: Observable<Material>;
  82048. /**
  82049. * Stores the value of the alpha mode
  82050. */
  82051. private _alphaMode;
  82052. /**
  82053. * Sets the value of the alpha mode.
  82054. *
  82055. * | Value | Type | Description |
  82056. * | --- | --- | --- |
  82057. * | 0 | ALPHA_DISABLE | |
  82058. * | 1 | ALPHA_ADD | |
  82059. * | 2 | ALPHA_COMBINE | |
  82060. * | 3 | ALPHA_SUBTRACT | |
  82061. * | 4 | ALPHA_MULTIPLY | |
  82062. * | 5 | ALPHA_MAXIMIZED | |
  82063. * | 6 | ALPHA_ONEONE | |
  82064. * | 7 | ALPHA_PREMULTIPLIED | |
  82065. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82066. * | 9 | ALPHA_INTERPOLATE | |
  82067. * | 10 | ALPHA_SCREENMODE | |
  82068. *
  82069. */
  82070. /**
  82071. * Gets the value of the alpha mode
  82072. */
  82073. alphaMode: number;
  82074. /**
  82075. * Stores the state of the need depth pre-pass value
  82076. */
  82077. private _needDepthPrePass;
  82078. /**
  82079. * Sets the need depth pre-pass value
  82080. */
  82081. /**
  82082. * Gets the depth pre-pass value
  82083. */
  82084. needDepthPrePass: boolean;
  82085. /**
  82086. * Specifies if depth writing should be disabled
  82087. */
  82088. disableDepthWrite: boolean;
  82089. /**
  82090. * Specifies if depth writing should be forced
  82091. */
  82092. forceDepthWrite: boolean;
  82093. /**
  82094. * Specifies if there should be a separate pass for culling
  82095. */
  82096. separateCullingPass: boolean;
  82097. /**
  82098. * Stores the state specifing if fog should be enabled
  82099. */
  82100. private _fogEnabled;
  82101. /**
  82102. * Sets the state for enabling fog
  82103. */
  82104. /**
  82105. * Gets the value of the fog enabled state
  82106. */
  82107. fogEnabled: boolean;
  82108. /**
  82109. * Stores the size of points
  82110. */
  82111. pointSize: number;
  82112. /**
  82113. * Stores the z offset value
  82114. */
  82115. zOffset: number;
  82116. /**
  82117. * Gets a value specifying if wireframe mode is enabled
  82118. */
  82119. /**
  82120. * Sets the state of wireframe mode
  82121. */
  82122. wireframe: boolean;
  82123. /**
  82124. * Gets the value specifying if point clouds are enabled
  82125. */
  82126. /**
  82127. * Sets the state of point cloud mode
  82128. */
  82129. pointsCloud: boolean;
  82130. /**
  82131. * Gets the material fill mode
  82132. */
  82133. /**
  82134. * Sets the material fill mode
  82135. */
  82136. fillMode: number;
  82137. /**
  82138. * @hidden
  82139. * Stores the effects for the material
  82140. */
  82141. _effect: Nullable<Effect>;
  82142. /**
  82143. * @hidden
  82144. * Specifies if the material was previously ready
  82145. */
  82146. _wasPreviouslyReady: boolean;
  82147. /**
  82148. * Specifies if uniform buffers should be used
  82149. */
  82150. private _useUBO;
  82151. /**
  82152. * Stores a reference to the scene
  82153. */
  82154. private _scene;
  82155. /**
  82156. * Stores the fill mode state
  82157. */
  82158. private _fillMode;
  82159. /**
  82160. * Specifies if the depth write state should be cached
  82161. */
  82162. private _cachedDepthWriteState;
  82163. /**
  82164. * Stores the uniform buffer
  82165. */
  82166. protected _uniformBuffer: UniformBuffer;
  82167. /** @hidden */
  82168. _indexInSceneMaterialArray: number;
  82169. /** @hidden */
  82170. meshMap: Nullable<{
  82171. [id: string]: AbstractMesh | undefined;
  82172. }>;
  82173. /**
  82174. * Creates a material instance
  82175. * @param name defines the name of the material
  82176. * @param scene defines the scene to reference
  82177. * @param doNotAdd specifies if the material should be added to the scene
  82178. */
  82179. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82180. /**
  82181. * Returns a string representation of the current material
  82182. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82183. * @returns a string with material information
  82184. */
  82185. toString(fullDetails?: boolean): string;
  82186. /**
  82187. * Gets the class name of the material
  82188. * @returns a string with the class name of the material
  82189. */
  82190. getClassName(): string;
  82191. /**
  82192. * Specifies if updates for the material been locked
  82193. */
  82194. readonly isFrozen: boolean;
  82195. /**
  82196. * Locks updates for the material
  82197. */
  82198. freeze(): void;
  82199. /**
  82200. * Unlocks updates for the material
  82201. */
  82202. unfreeze(): void;
  82203. /**
  82204. * Specifies if the material is ready to be used
  82205. * @param mesh defines the mesh to check
  82206. * @param useInstances specifies if instances should be used
  82207. * @returns a boolean indicating if the material is ready to be used
  82208. */
  82209. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82210. /**
  82211. * Specifies that the submesh is ready to be used
  82212. * @param mesh defines the mesh to check
  82213. * @param subMesh defines which submesh to check
  82214. * @param useInstances specifies that instances should be used
  82215. * @returns a boolean indicating that the submesh is ready or not
  82216. */
  82217. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82218. /**
  82219. * Returns the material effect
  82220. * @returns the effect associated with the material
  82221. */
  82222. getEffect(): Nullable<Effect>;
  82223. /**
  82224. * Returns the current scene
  82225. * @returns a Scene
  82226. */
  82227. getScene(): Scene;
  82228. /**
  82229. * Specifies if the material will require alpha blending
  82230. * @returns a boolean specifying if alpha blending is needed
  82231. */
  82232. needAlphaBlending(): boolean;
  82233. /**
  82234. * Specifies if the mesh will require alpha blending
  82235. * @param mesh defines the mesh to check
  82236. * @returns a boolean specifying if alpha blending is needed for the mesh
  82237. */
  82238. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82239. /**
  82240. * Specifies if this material should be rendered in alpha test mode
  82241. * @returns a boolean specifying if an alpha test is needed.
  82242. */
  82243. needAlphaTesting(): boolean;
  82244. /**
  82245. * Gets the texture used for the alpha test
  82246. * @returns the texture to use for alpha testing
  82247. */
  82248. getAlphaTestTexture(): Nullable<BaseTexture>;
  82249. /**
  82250. * Marks the material to indicate that it needs to be re-calculated
  82251. */
  82252. markDirty(): void;
  82253. /** @hidden */
  82254. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82255. /**
  82256. * Binds the material to the mesh
  82257. * @param world defines the world transformation matrix
  82258. * @param mesh defines the mesh to bind the material to
  82259. */
  82260. bind(world: Matrix, mesh?: Mesh): void;
  82261. /**
  82262. * Binds the submesh to the material
  82263. * @param world defines the world transformation matrix
  82264. * @param mesh defines the mesh containing the submesh
  82265. * @param subMesh defines the submesh to bind the material to
  82266. */
  82267. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82268. /**
  82269. * Binds the world matrix to the material
  82270. * @param world defines the world transformation matrix
  82271. */
  82272. bindOnlyWorldMatrix(world: Matrix): void;
  82273. /**
  82274. * Binds the scene's uniform buffer to the effect.
  82275. * @param effect defines the effect to bind to the scene uniform buffer
  82276. * @param sceneUbo defines the uniform buffer storing scene data
  82277. */
  82278. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82279. /**
  82280. * Binds the view matrix to the effect
  82281. * @param effect defines the effect to bind the view matrix to
  82282. */
  82283. bindView(effect: Effect): void;
  82284. /**
  82285. * Binds the view projection matrix to the effect
  82286. * @param effect defines the effect to bind the view projection matrix to
  82287. */
  82288. bindViewProjection(effect: Effect): void;
  82289. /**
  82290. * Specifies if material alpha testing should be turned on for the mesh
  82291. * @param mesh defines the mesh to check
  82292. */
  82293. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82294. /**
  82295. * Processes to execute after binding the material to a mesh
  82296. * @param mesh defines the rendered mesh
  82297. */
  82298. protected _afterBind(mesh?: Mesh): void;
  82299. /**
  82300. * Unbinds the material from the mesh
  82301. */
  82302. unbind(): void;
  82303. /**
  82304. * Gets the active textures from the material
  82305. * @returns an array of textures
  82306. */
  82307. getActiveTextures(): BaseTexture[];
  82308. /**
  82309. * Specifies if the material uses a texture
  82310. * @param texture defines the texture to check against the material
  82311. * @returns a boolean specifying if the material uses the texture
  82312. */
  82313. hasTexture(texture: BaseTexture): boolean;
  82314. /**
  82315. * Makes a duplicate of the material, and gives it a new name
  82316. * @param name defines the new name for the duplicated material
  82317. * @returns the cloned material
  82318. */
  82319. clone(name: string): Nullable<Material>;
  82320. /**
  82321. * Gets the meshes bound to the material
  82322. * @returns an array of meshes bound to the material
  82323. */
  82324. getBindedMeshes(): AbstractMesh[];
  82325. /**
  82326. * Force shader compilation
  82327. * @param mesh defines the mesh associated with this material
  82328. * @param onCompiled defines a function to execute once the material is compiled
  82329. * @param options defines the options to configure the compilation
  82330. */
  82331. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82332. clipPlane: boolean;
  82333. }>): void;
  82334. /**
  82335. * Force shader compilation
  82336. * @param mesh defines the mesh that will use this material
  82337. * @param options defines additional options for compiling the shaders
  82338. * @returns a promise that resolves when the compilation completes
  82339. */
  82340. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82341. clipPlane: boolean;
  82342. }>): Promise<void>;
  82343. private static readonly _ImageProcessingDirtyCallBack;
  82344. private static readonly _TextureDirtyCallBack;
  82345. private static readonly _FresnelDirtyCallBack;
  82346. private static readonly _MiscDirtyCallBack;
  82347. private static readonly _LightsDirtyCallBack;
  82348. private static readonly _AttributeDirtyCallBack;
  82349. private static _FresnelAndMiscDirtyCallBack;
  82350. private static _TextureAndMiscDirtyCallBack;
  82351. private static readonly _DirtyCallbackArray;
  82352. private static readonly _RunDirtyCallBacks;
  82353. /**
  82354. * Marks a define in the material to indicate that it needs to be re-computed
  82355. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82356. */
  82357. markAsDirty(flag: number): void;
  82358. /**
  82359. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82360. * @param func defines a function which checks material defines against the submeshes
  82361. */
  82362. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82363. /**
  82364. * Indicates that image processing needs to be re-calculated for all submeshes
  82365. */
  82366. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82367. /**
  82368. * Indicates that textures need to be re-calculated for all submeshes
  82369. */
  82370. protected _markAllSubMeshesAsTexturesDirty(): void;
  82371. /**
  82372. * Indicates that fresnel needs to be re-calculated for all submeshes
  82373. */
  82374. protected _markAllSubMeshesAsFresnelDirty(): void;
  82375. /**
  82376. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82377. */
  82378. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82379. /**
  82380. * Indicates that lights need to be re-calculated for all submeshes
  82381. */
  82382. protected _markAllSubMeshesAsLightsDirty(): void;
  82383. /**
  82384. * Indicates that attributes need to be re-calculated for all submeshes
  82385. */
  82386. protected _markAllSubMeshesAsAttributesDirty(): void;
  82387. /**
  82388. * Indicates that misc needs to be re-calculated for all submeshes
  82389. */
  82390. protected _markAllSubMeshesAsMiscDirty(): void;
  82391. /**
  82392. * Indicates that textures and misc need to be re-calculated for all submeshes
  82393. */
  82394. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82395. /**
  82396. * Disposes the material
  82397. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82398. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82399. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82400. */
  82401. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82402. /** @hidden */
  82403. private releaseVertexArrayObject;
  82404. /**
  82405. * Serializes this material
  82406. * @returns the serialized material object
  82407. */
  82408. serialize(): any;
  82409. /**
  82410. * Creates a material from parsed material data
  82411. * @param parsedMaterial defines parsed material data
  82412. * @param scene defines the hosting scene
  82413. * @param rootUrl defines the root URL to use to load textures
  82414. * @returns a new material
  82415. */
  82416. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82417. }
  82418. }
  82419. declare module BABYLON {
  82420. /**
  82421. * Base class for submeshes
  82422. */
  82423. export class BaseSubMesh {
  82424. /** @hidden */
  82425. _materialDefines: Nullable<MaterialDefines>;
  82426. /** @hidden */
  82427. _materialEffect: Nullable<Effect>;
  82428. /**
  82429. * Gets associated effect
  82430. */
  82431. readonly effect: Nullable<Effect>;
  82432. /**
  82433. * Sets associated effect (effect used to render this submesh)
  82434. * @param effect defines the effect to associate with
  82435. * @param defines defines the set of defines used to compile this effect
  82436. */
  82437. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82438. }
  82439. /**
  82440. * Defines a subdivision inside a mesh
  82441. */
  82442. export class SubMesh extends BaseSubMesh implements ICullable {
  82443. /** the material index to use */
  82444. materialIndex: number;
  82445. /** vertex index start */
  82446. verticesStart: number;
  82447. /** vertices count */
  82448. verticesCount: number;
  82449. /** index start */
  82450. indexStart: number;
  82451. /** indices count */
  82452. indexCount: number;
  82453. /** @hidden */
  82454. _linesIndexCount: number;
  82455. private _mesh;
  82456. private _renderingMesh;
  82457. private _boundingInfo;
  82458. private _linesIndexBuffer;
  82459. /** @hidden */
  82460. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82461. /** @hidden */
  82462. _trianglePlanes: Plane[];
  82463. /** @hidden */
  82464. _lastColliderTransformMatrix: Nullable<Matrix>;
  82465. /** @hidden */
  82466. _renderId: number;
  82467. /** @hidden */
  82468. _alphaIndex: number;
  82469. /** @hidden */
  82470. _distanceToCamera: number;
  82471. /** @hidden */
  82472. _id: number;
  82473. private _currentMaterial;
  82474. /**
  82475. * Add a new submesh to a mesh
  82476. * @param materialIndex defines the material index to use
  82477. * @param verticesStart defines vertex index start
  82478. * @param verticesCount defines vertices count
  82479. * @param indexStart defines index start
  82480. * @param indexCount defines indices count
  82481. * @param mesh defines the parent mesh
  82482. * @param renderingMesh defines an optional rendering mesh
  82483. * @param createBoundingBox defines if bounding box should be created for this submesh
  82484. * @returns the new submesh
  82485. */
  82486. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82487. /**
  82488. * Creates a new submesh
  82489. * @param materialIndex defines the material index to use
  82490. * @param verticesStart defines vertex index start
  82491. * @param verticesCount defines vertices count
  82492. * @param indexStart defines index start
  82493. * @param indexCount defines indices count
  82494. * @param mesh defines the parent mesh
  82495. * @param renderingMesh defines an optional rendering mesh
  82496. * @param createBoundingBox defines if bounding box should be created for this submesh
  82497. */
  82498. constructor(
  82499. /** the material index to use */
  82500. materialIndex: number,
  82501. /** vertex index start */
  82502. verticesStart: number,
  82503. /** vertices count */
  82504. verticesCount: number,
  82505. /** index start */
  82506. indexStart: number,
  82507. /** indices count */
  82508. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82509. /**
  82510. * Returns true if this submesh covers the entire parent mesh
  82511. * @ignorenaming
  82512. */
  82513. readonly IsGlobal: boolean;
  82514. /**
  82515. * Returns the submesh BoudingInfo object
  82516. * @returns current bounding info (or mesh's one if the submesh is global)
  82517. */
  82518. getBoundingInfo(): BoundingInfo;
  82519. /**
  82520. * Sets the submesh BoundingInfo
  82521. * @param boundingInfo defines the new bounding info to use
  82522. * @returns the SubMesh
  82523. */
  82524. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82525. /**
  82526. * Returns the mesh of the current submesh
  82527. * @return the parent mesh
  82528. */
  82529. getMesh(): AbstractMesh;
  82530. /**
  82531. * Returns the rendering mesh of the submesh
  82532. * @returns the rendering mesh (could be different from parent mesh)
  82533. */
  82534. getRenderingMesh(): Mesh;
  82535. /**
  82536. * Returns the submesh material
  82537. * @returns null or the current material
  82538. */
  82539. getMaterial(): Nullable<Material>;
  82540. /**
  82541. * Sets a new updated BoundingInfo object to the submesh
  82542. * @param data defines an optional position array to use to determine the bounding info
  82543. * @returns the SubMesh
  82544. */
  82545. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82546. /** @hidden */
  82547. _checkCollision(collider: Collider): boolean;
  82548. /**
  82549. * Updates the submesh BoundingInfo
  82550. * @param world defines the world matrix to use to update the bounding info
  82551. * @returns the submesh
  82552. */
  82553. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82554. /**
  82555. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82556. * @param frustumPlanes defines the frustum planes
  82557. * @returns true if the submesh is intersecting with the frustum
  82558. */
  82559. isInFrustum(frustumPlanes: Plane[]): boolean;
  82560. /**
  82561. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82562. * @param frustumPlanes defines the frustum planes
  82563. * @returns true if the submesh is inside the frustum
  82564. */
  82565. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82566. /**
  82567. * Renders the submesh
  82568. * @param enableAlphaMode defines if alpha needs to be used
  82569. * @returns the submesh
  82570. */
  82571. render(enableAlphaMode: boolean): SubMesh;
  82572. /**
  82573. * @hidden
  82574. */
  82575. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82576. /**
  82577. * Checks if the submesh intersects with a ray
  82578. * @param ray defines the ray to test
  82579. * @returns true is the passed ray intersects the submesh bounding box
  82580. */
  82581. canIntersects(ray: Ray): boolean;
  82582. /**
  82583. * Intersects current submesh with a ray
  82584. * @param ray defines the ray to test
  82585. * @param positions defines mesh's positions array
  82586. * @param indices defines mesh's indices array
  82587. * @param fastCheck defines if only bounding info should be used
  82588. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82589. * @returns intersection info or null if no intersection
  82590. */
  82591. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82592. /** @hidden */
  82593. private _intersectLines;
  82594. /** @hidden */
  82595. private _intersectTriangles;
  82596. /** @hidden */
  82597. _rebuild(): void;
  82598. /**
  82599. * Creates a new submesh from the passed mesh
  82600. * @param newMesh defines the new hosting mesh
  82601. * @param newRenderingMesh defines an optional rendering mesh
  82602. * @returns the new submesh
  82603. */
  82604. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82605. /**
  82606. * Release associated resources
  82607. */
  82608. dispose(): void;
  82609. /**
  82610. * Gets the class name
  82611. * @returns the string "SubMesh".
  82612. */
  82613. getClassName(): string;
  82614. /**
  82615. * Creates a new submesh from indices data
  82616. * @param materialIndex the index of the main mesh material
  82617. * @param startIndex the index where to start the copy in the mesh indices array
  82618. * @param indexCount the number of indices to copy then from the startIndex
  82619. * @param mesh the main mesh to create the submesh from
  82620. * @param renderingMesh the optional rendering mesh
  82621. * @returns a new submesh
  82622. */
  82623. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82624. }
  82625. }
  82626. declare module BABYLON {
  82627. /**
  82628. * Class used to store geometry data (vertex buffers + index buffer)
  82629. */
  82630. export class Geometry implements IGetSetVerticesData {
  82631. /**
  82632. * Gets or sets the ID of the geometry
  82633. */
  82634. id: string;
  82635. /**
  82636. * Gets or sets the unique ID of the geometry
  82637. */
  82638. uniqueId: number;
  82639. /**
  82640. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82641. */
  82642. delayLoadState: number;
  82643. /**
  82644. * Gets the file containing the data to load when running in delay load state
  82645. */
  82646. delayLoadingFile: Nullable<string>;
  82647. /**
  82648. * Callback called when the geometry is updated
  82649. */
  82650. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82651. private _scene;
  82652. private _engine;
  82653. private _meshes;
  82654. private _totalVertices;
  82655. /** @hidden */
  82656. _indices: IndicesArray;
  82657. /** @hidden */
  82658. _vertexBuffers: {
  82659. [key: string]: VertexBuffer;
  82660. };
  82661. private _isDisposed;
  82662. private _extend;
  82663. private _boundingBias;
  82664. /** @hidden */
  82665. _delayInfo: Array<string>;
  82666. private _indexBuffer;
  82667. private _indexBufferIsUpdatable;
  82668. /** @hidden */
  82669. _boundingInfo: Nullable<BoundingInfo>;
  82670. /** @hidden */
  82671. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82672. /** @hidden */
  82673. _softwareSkinningFrameId: number;
  82674. private _vertexArrayObjects;
  82675. private _updatable;
  82676. /** @hidden */
  82677. _positions: Nullable<Vector3[]>;
  82678. /**
  82679. * 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
  82680. */
  82681. /**
  82682. * 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
  82683. */
  82684. boundingBias: Vector2;
  82685. /**
  82686. * Static function used to attach a new empty geometry to a mesh
  82687. * @param mesh defines the mesh to attach the geometry to
  82688. * @returns the new Geometry
  82689. */
  82690. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82691. /**
  82692. * Creates a new geometry
  82693. * @param id defines the unique ID
  82694. * @param scene defines the hosting scene
  82695. * @param vertexData defines the VertexData used to get geometry data
  82696. * @param updatable defines if geometry must be updatable (false by default)
  82697. * @param mesh defines the mesh that will be associated with the geometry
  82698. */
  82699. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82700. /**
  82701. * Gets the current extend of the geometry
  82702. */
  82703. readonly extend: {
  82704. minimum: Vector3;
  82705. maximum: Vector3;
  82706. };
  82707. /**
  82708. * Gets the hosting scene
  82709. * @returns the hosting Scene
  82710. */
  82711. getScene(): Scene;
  82712. /**
  82713. * Gets the hosting engine
  82714. * @returns the hosting Engine
  82715. */
  82716. getEngine(): Engine;
  82717. /**
  82718. * Defines if the geometry is ready to use
  82719. * @returns true if the geometry is ready to be used
  82720. */
  82721. isReady(): boolean;
  82722. /**
  82723. * Gets a value indicating that the geometry should not be serialized
  82724. */
  82725. readonly doNotSerialize: boolean;
  82726. /** @hidden */
  82727. _rebuild(): void;
  82728. /**
  82729. * Affects all geometry data in one call
  82730. * @param vertexData defines the geometry data
  82731. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82732. */
  82733. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82734. /**
  82735. * Set specific vertex data
  82736. * @param kind defines the data kind (Position, normal, etc...)
  82737. * @param data defines the vertex data to use
  82738. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82739. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82740. */
  82741. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82742. /**
  82743. * Removes a specific vertex data
  82744. * @param kind defines the data kind (Position, normal, etc...)
  82745. */
  82746. removeVerticesData(kind: string): void;
  82747. /**
  82748. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82749. * @param buffer defines the vertex buffer to use
  82750. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82751. */
  82752. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82753. /**
  82754. * Update a specific vertex buffer
  82755. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82756. * It will do nothing if the buffer is not updatable
  82757. * @param kind defines the data kind (Position, normal, etc...)
  82758. * @param data defines the data to use
  82759. * @param offset defines the offset in the target buffer where to store the data
  82760. * @param useBytes set to true if the offset is in bytes
  82761. */
  82762. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82763. /**
  82764. * Update a specific vertex buffer
  82765. * This function will create a new buffer if the current one is not updatable
  82766. * @param kind defines the data kind (Position, normal, etc...)
  82767. * @param data defines the data to use
  82768. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82769. */
  82770. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82771. private _updateBoundingInfo;
  82772. /** @hidden */
  82773. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82774. /**
  82775. * Gets total number of vertices
  82776. * @returns the total number of vertices
  82777. */
  82778. getTotalVertices(): number;
  82779. /**
  82780. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82781. * @param kind defines the data kind (Position, normal, etc...)
  82782. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82783. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82784. * @returns a float array containing vertex data
  82785. */
  82786. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82787. /**
  82788. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82789. * @param kind defines the data kind (Position, normal, etc...)
  82790. * @returns true if the vertex buffer with the specified kind is updatable
  82791. */
  82792. isVertexBufferUpdatable(kind: string): boolean;
  82793. /**
  82794. * Gets a specific vertex buffer
  82795. * @param kind defines the data kind (Position, normal, etc...)
  82796. * @returns a VertexBuffer
  82797. */
  82798. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82799. /**
  82800. * Returns all vertex buffers
  82801. * @return an object holding all vertex buffers indexed by kind
  82802. */
  82803. getVertexBuffers(): Nullable<{
  82804. [key: string]: VertexBuffer;
  82805. }>;
  82806. /**
  82807. * Gets a boolean indicating if specific vertex buffer is present
  82808. * @param kind defines the data kind (Position, normal, etc...)
  82809. * @returns true if data is present
  82810. */
  82811. isVerticesDataPresent(kind: string): boolean;
  82812. /**
  82813. * Gets a list of all attached data kinds (Position, normal, etc...)
  82814. * @returns a list of string containing all kinds
  82815. */
  82816. getVerticesDataKinds(): string[];
  82817. /**
  82818. * Update index buffer
  82819. * @param indices defines the indices to store in the index buffer
  82820. * @param offset defines the offset in the target buffer where to store the data
  82821. * @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)
  82822. */
  82823. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82824. /**
  82825. * Creates a new index buffer
  82826. * @param indices defines the indices to store in the index buffer
  82827. * @param totalVertices defines the total number of vertices (could be null)
  82828. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82829. */
  82830. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82831. /**
  82832. * Return the total number of indices
  82833. * @returns the total number of indices
  82834. */
  82835. getTotalIndices(): number;
  82836. /**
  82837. * Gets the index buffer array
  82838. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82839. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82840. * @returns the index buffer array
  82841. */
  82842. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82843. /**
  82844. * Gets the index buffer
  82845. * @return the index buffer
  82846. */
  82847. getIndexBuffer(): Nullable<DataBuffer>;
  82848. /** @hidden */
  82849. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82850. /**
  82851. * Release the associated resources for a specific mesh
  82852. * @param mesh defines the source mesh
  82853. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82854. */
  82855. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82856. /**
  82857. * Apply current geometry to a given mesh
  82858. * @param mesh defines the mesh to apply geometry to
  82859. */
  82860. applyToMesh(mesh: Mesh): void;
  82861. private _updateExtend;
  82862. private _applyToMesh;
  82863. private notifyUpdate;
  82864. /**
  82865. * Load the geometry if it was flagged as delay loaded
  82866. * @param scene defines the hosting scene
  82867. * @param onLoaded defines a callback called when the geometry is loaded
  82868. */
  82869. load(scene: Scene, onLoaded?: () => void): void;
  82870. private _queueLoad;
  82871. /**
  82872. * Invert the geometry to move from a right handed system to a left handed one.
  82873. */
  82874. toLeftHanded(): void;
  82875. /** @hidden */
  82876. _resetPointsArrayCache(): void;
  82877. /** @hidden */
  82878. _generatePointsArray(): boolean;
  82879. /**
  82880. * Gets a value indicating if the geometry is disposed
  82881. * @returns true if the geometry was disposed
  82882. */
  82883. isDisposed(): boolean;
  82884. private _disposeVertexArrayObjects;
  82885. /**
  82886. * Free all associated resources
  82887. */
  82888. dispose(): void;
  82889. /**
  82890. * Clone the current geometry into a new geometry
  82891. * @param id defines the unique ID of the new geometry
  82892. * @returns a new geometry object
  82893. */
  82894. copy(id: string): Geometry;
  82895. /**
  82896. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82897. * @return a JSON representation of the current geometry data (without the vertices data)
  82898. */
  82899. serialize(): any;
  82900. private toNumberArray;
  82901. /**
  82902. * Serialize all vertices data into a JSON oject
  82903. * @returns a JSON representation of the current geometry data
  82904. */
  82905. serializeVerticeData(): any;
  82906. /**
  82907. * Extracts a clone of a mesh geometry
  82908. * @param mesh defines the source mesh
  82909. * @param id defines the unique ID of the new geometry object
  82910. * @returns the new geometry object
  82911. */
  82912. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82913. /**
  82914. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82915. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82916. * Be aware Math.random() could cause collisions, but:
  82917. * "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"
  82918. * @returns a string containing a new GUID
  82919. */
  82920. static RandomId(): string;
  82921. /** @hidden */
  82922. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82923. private static _CleanMatricesWeights;
  82924. /**
  82925. * Create a new geometry from persisted data (Using .babylon file format)
  82926. * @param parsedVertexData defines the persisted data
  82927. * @param scene defines the hosting scene
  82928. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82929. * @returns the new geometry object
  82930. */
  82931. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82932. }
  82933. }
  82934. declare module BABYLON {
  82935. /**
  82936. * Define an interface for all classes that will get and set the data on vertices
  82937. */
  82938. export interface IGetSetVerticesData {
  82939. /**
  82940. * Gets a boolean indicating if specific vertex data is present
  82941. * @param kind defines the vertex data kind to use
  82942. * @returns true is data kind is present
  82943. */
  82944. isVerticesDataPresent(kind: string): boolean;
  82945. /**
  82946. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82947. * @param kind defines the data kind (Position, normal, etc...)
  82948. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82949. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82950. * @returns a float array containing vertex data
  82951. */
  82952. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82953. /**
  82954. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82955. * @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.
  82956. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82957. * @returns the indices array or an empty array if the mesh has no geometry
  82958. */
  82959. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82960. /**
  82961. * Set specific vertex data
  82962. * @param kind defines the data kind (Position, normal, etc...)
  82963. * @param data defines the vertex data to use
  82964. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82965. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82966. */
  82967. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82968. /**
  82969. * Update a specific associated vertex buffer
  82970. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82971. * - VertexBuffer.PositionKind
  82972. * - VertexBuffer.UVKind
  82973. * - VertexBuffer.UV2Kind
  82974. * - VertexBuffer.UV3Kind
  82975. * - VertexBuffer.UV4Kind
  82976. * - VertexBuffer.UV5Kind
  82977. * - VertexBuffer.UV6Kind
  82978. * - VertexBuffer.ColorKind
  82979. * - VertexBuffer.MatricesIndicesKind
  82980. * - VertexBuffer.MatricesIndicesExtraKind
  82981. * - VertexBuffer.MatricesWeightsKind
  82982. * - VertexBuffer.MatricesWeightsExtraKind
  82983. * @param data defines the data source
  82984. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82985. * @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)
  82986. */
  82987. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82988. /**
  82989. * Creates a new index buffer
  82990. * @param indices defines the indices to store in the index buffer
  82991. * @param totalVertices defines the total number of vertices (could be null)
  82992. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82993. */
  82994. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82995. }
  82996. /**
  82997. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82998. */
  82999. export class VertexData {
  83000. /**
  83001. * Mesh side orientation : usually the external or front surface
  83002. */
  83003. static readonly FRONTSIDE: number;
  83004. /**
  83005. * Mesh side orientation : usually the internal or back surface
  83006. */
  83007. static readonly BACKSIDE: number;
  83008. /**
  83009. * Mesh side orientation : both internal and external or front and back surfaces
  83010. */
  83011. static readonly DOUBLESIDE: number;
  83012. /**
  83013. * Mesh side orientation : by default, `FRONTSIDE`
  83014. */
  83015. static readonly DEFAULTSIDE: number;
  83016. /**
  83017. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83018. */
  83019. positions: Nullable<FloatArray>;
  83020. /**
  83021. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83022. */
  83023. normals: Nullable<FloatArray>;
  83024. /**
  83025. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83026. */
  83027. tangents: Nullable<FloatArray>;
  83028. /**
  83029. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83030. */
  83031. uvs: Nullable<FloatArray>;
  83032. /**
  83033. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83034. */
  83035. uvs2: Nullable<FloatArray>;
  83036. /**
  83037. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83038. */
  83039. uvs3: Nullable<FloatArray>;
  83040. /**
  83041. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83042. */
  83043. uvs4: Nullable<FloatArray>;
  83044. /**
  83045. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83046. */
  83047. uvs5: Nullable<FloatArray>;
  83048. /**
  83049. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83050. */
  83051. uvs6: Nullable<FloatArray>;
  83052. /**
  83053. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83054. */
  83055. colors: Nullable<FloatArray>;
  83056. /**
  83057. * 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).
  83058. */
  83059. matricesIndices: Nullable<FloatArray>;
  83060. /**
  83061. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83062. */
  83063. matricesWeights: Nullable<FloatArray>;
  83064. /**
  83065. * An array extending the number of possible indices
  83066. */
  83067. matricesIndicesExtra: Nullable<FloatArray>;
  83068. /**
  83069. * An array extending the number of possible weights when the number of indices is extended
  83070. */
  83071. matricesWeightsExtra: Nullable<FloatArray>;
  83072. /**
  83073. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83074. */
  83075. indices: Nullable<IndicesArray>;
  83076. /**
  83077. * Uses the passed data array to set the set the values for the specified kind of data
  83078. * @param data a linear array of floating numbers
  83079. * @param kind the type of data that is being set, eg positions, colors etc
  83080. */
  83081. set(data: FloatArray, kind: string): void;
  83082. /**
  83083. * Associates the vertexData to the passed Mesh.
  83084. * Sets it as updatable or not (default `false`)
  83085. * @param mesh the mesh the vertexData is applied to
  83086. * @param updatable when used and having the value true allows new data to update the vertexData
  83087. * @returns the VertexData
  83088. */
  83089. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83090. /**
  83091. * Associates the vertexData to the passed Geometry.
  83092. * Sets it as updatable or not (default `false`)
  83093. * @param geometry the geometry the vertexData is applied to
  83094. * @param updatable when used and having the value true allows new data to update the vertexData
  83095. * @returns VertexData
  83096. */
  83097. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83098. /**
  83099. * Updates the associated mesh
  83100. * @param mesh the mesh to be updated
  83101. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83102. * @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
  83103. * @returns VertexData
  83104. */
  83105. updateMesh(mesh: Mesh): VertexData;
  83106. /**
  83107. * Updates the associated geometry
  83108. * @param geometry the geometry to be updated
  83109. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83110. * @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
  83111. * @returns VertexData.
  83112. */
  83113. updateGeometry(geometry: Geometry): VertexData;
  83114. private _applyTo;
  83115. private _update;
  83116. /**
  83117. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83118. * @param matrix the transforming matrix
  83119. * @returns the VertexData
  83120. */
  83121. transform(matrix: Matrix): VertexData;
  83122. /**
  83123. * Merges the passed VertexData into the current one
  83124. * @param other the VertexData to be merged into the current one
  83125. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83126. * @returns the modified VertexData
  83127. */
  83128. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83129. private _mergeElement;
  83130. private _validate;
  83131. /**
  83132. * Serializes the VertexData
  83133. * @returns a serialized object
  83134. */
  83135. serialize(): any;
  83136. /**
  83137. * Extracts the vertexData from a mesh
  83138. * @param mesh the mesh from which to extract the VertexData
  83139. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83140. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83141. * @returns the object VertexData associated to the passed mesh
  83142. */
  83143. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83144. /**
  83145. * Extracts the vertexData from the geometry
  83146. * @param geometry the geometry from which to extract the VertexData
  83147. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83148. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83149. * @returns the object VertexData associated to the passed mesh
  83150. */
  83151. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83152. private static _ExtractFrom;
  83153. /**
  83154. * Creates the VertexData for a Ribbon
  83155. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83156. * * pathArray array of paths, each of which an array of successive Vector3
  83157. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83158. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83159. * * 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
  83160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83161. * * 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)
  83162. * * 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)
  83163. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83164. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83165. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83166. * @returns the VertexData of the ribbon
  83167. */
  83168. static CreateRibbon(options: {
  83169. pathArray: Vector3[][];
  83170. closeArray?: boolean;
  83171. closePath?: boolean;
  83172. offset?: number;
  83173. sideOrientation?: number;
  83174. frontUVs?: Vector4;
  83175. backUVs?: Vector4;
  83176. invertUV?: boolean;
  83177. uvs?: Vector2[];
  83178. colors?: Color4[];
  83179. }): VertexData;
  83180. /**
  83181. * Creates the VertexData for a box
  83182. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83183. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83184. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83185. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83186. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83187. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83188. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83190. * * 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)
  83191. * * 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)
  83192. * @returns the VertexData of the box
  83193. */
  83194. static CreateBox(options: {
  83195. size?: number;
  83196. width?: number;
  83197. height?: number;
  83198. depth?: number;
  83199. faceUV?: Vector4[];
  83200. faceColors?: Color4[];
  83201. sideOrientation?: number;
  83202. frontUVs?: Vector4;
  83203. backUVs?: Vector4;
  83204. }): VertexData;
  83205. /**
  83206. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83208. * * segments sets the number of horizontal strips optional, default 32
  83209. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83210. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83211. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83212. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83213. * * 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
  83214. * * 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
  83215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83216. * * 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)
  83217. * * 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)
  83218. * @returns the VertexData of the ellipsoid
  83219. */
  83220. static CreateSphere(options: {
  83221. segments?: number;
  83222. diameter?: number;
  83223. diameterX?: number;
  83224. diameterY?: number;
  83225. diameterZ?: number;
  83226. arc?: number;
  83227. slice?: number;
  83228. sideOrientation?: number;
  83229. frontUVs?: Vector4;
  83230. backUVs?: Vector4;
  83231. }): VertexData;
  83232. /**
  83233. * Creates the VertexData for a cylinder, cone or prism
  83234. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83235. * * height sets the height (y direction) of the cylinder, optional, default 2
  83236. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83237. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83238. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83239. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83240. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83241. * * 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
  83242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83243. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83244. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83245. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83247. * * 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)
  83248. * * 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)
  83249. * @returns the VertexData of the cylinder, cone or prism
  83250. */
  83251. static CreateCylinder(options: {
  83252. height?: number;
  83253. diameterTop?: number;
  83254. diameterBottom?: number;
  83255. diameter?: number;
  83256. tessellation?: number;
  83257. subdivisions?: number;
  83258. arc?: number;
  83259. faceColors?: Color4[];
  83260. faceUV?: Vector4[];
  83261. hasRings?: boolean;
  83262. enclose?: boolean;
  83263. sideOrientation?: number;
  83264. frontUVs?: Vector4;
  83265. backUVs?: Vector4;
  83266. }): VertexData;
  83267. /**
  83268. * Creates the VertexData for a torus
  83269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83270. * * diameter the diameter of the torus, optional default 1
  83271. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83272. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83274. * * 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)
  83275. * * 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)
  83276. * @returns the VertexData of the torus
  83277. */
  83278. static CreateTorus(options: {
  83279. diameter?: number;
  83280. thickness?: number;
  83281. tessellation?: number;
  83282. sideOrientation?: number;
  83283. frontUVs?: Vector4;
  83284. backUVs?: Vector4;
  83285. }): VertexData;
  83286. /**
  83287. * Creates the VertexData of the LineSystem
  83288. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83289. * - lines an array of lines, each line being an array of successive Vector3
  83290. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83291. * @returns the VertexData of the LineSystem
  83292. */
  83293. static CreateLineSystem(options: {
  83294. lines: Vector3[][];
  83295. colors?: Nullable<Color4[][]>;
  83296. }): VertexData;
  83297. /**
  83298. * Create the VertexData for a DashedLines
  83299. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83300. * - points an array successive Vector3
  83301. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83302. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83303. * - dashNb the intended total number of dashes, optional, default 200
  83304. * @returns the VertexData for the DashedLines
  83305. */
  83306. static CreateDashedLines(options: {
  83307. points: Vector3[];
  83308. dashSize?: number;
  83309. gapSize?: number;
  83310. dashNb?: number;
  83311. }): VertexData;
  83312. /**
  83313. * Creates the VertexData for a Ground
  83314. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83315. * - width the width (x direction) of the ground, optional, default 1
  83316. * - height the height (z direction) of the ground, optional, default 1
  83317. * - subdivisions the number of subdivisions per side, optional, default 1
  83318. * @returns the VertexData of the Ground
  83319. */
  83320. static CreateGround(options: {
  83321. width?: number;
  83322. height?: number;
  83323. subdivisions?: number;
  83324. subdivisionsX?: number;
  83325. subdivisionsY?: number;
  83326. }): VertexData;
  83327. /**
  83328. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83330. * * xmin the ground minimum X coordinate, optional, default -1
  83331. * * zmin the ground minimum Z coordinate, optional, default -1
  83332. * * xmax the ground maximum X coordinate, optional, default 1
  83333. * * zmax the ground maximum Z coordinate, optional, default 1
  83334. * * 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}
  83335. * * 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}
  83336. * @returns the VertexData of the TiledGround
  83337. */
  83338. static CreateTiledGround(options: {
  83339. xmin: number;
  83340. zmin: number;
  83341. xmax: number;
  83342. zmax: number;
  83343. subdivisions?: {
  83344. w: number;
  83345. h: number;
  83346. };
  83347. precision?: {
  83348. w: number;
  83349. h: number;
  83350. };
  83351. }): VertexData;
  83352. /**
  83353. * Creates the VertexData of the Ground designed from a heightmap
  83354. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83355. * * width the width (x direction) of the ground
  83356. * * height the height (z direction) of the ground
  83357. * * subdivisions the number of subdivisions per side
  83358. * * minHeight the minimum altitude on the ground, optional, default 0
  83359. * * maxHeight the maximum altitude on the ground, optional default 1
  83360. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83361. * * buffer the array holding the image color data
  83362. * * bufferWidth the width of image
  83363. * * bufferHeight the height of image
  83364. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83365. * @returns the VertexData of the Ground designed from a heightmap
  83366. */
  83367. static CreateGroundFromHeightMap(options: {
  83368. width: number;
  83369. height: number;
  83370. subdivisions: number;
  83371. minHeight: number;
  83372. maxHeight: number;
  83373. colorFilter: Color3;
  83374. buffer: Uint8Array;
  83375. bufferWidth: number;
  83376. bufferHeight: number;
  83377. alphaFilter: number;
  83378. }): VertexData;
  83379. /**
  83380. * Creates the VertexData for a Plane
  83381. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83382. * * size sets the width and height of the plane to the value of size, optional default 1
  83383. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83384. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83386. * * 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)
  83387. * * 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)
  83388. * @returns the VertexData of the box
  83389. */
  83390. static CreatePlane(options: {
  83391. size?: number;
  83392. width?: number;
  83393. height?: number;
  83394. sideOrientation?: number;
  83395. frontUVs?: Vector4;
  83396. backUVs?: Vector4;
  83397. }): VertexData;
  83398. /**
  83399. * Creates the VertexData of the Disc or regular Polygon
  83400. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83401. * * radius the radius of the disc, optional default 0.5
  83402. * * tessellation the number of polygon sides, optional, default 64
  83403. * * 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
  83404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83405. * * 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)
  83406. * * 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)
  83407. * @returns the VertexData of the box
  83408. */
  83409. static CreateDisc(options: {
  83410. radius?: number;
  83411. tessellation?: number;
  83412. arc?: number;
  83413. sideOrientation?: number;
  83414. frontUVs?: Vector4;
  83415. backUVs?: Vector4;
  83416. }): VertexData;
  83417. /**
  83418. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83419. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83420. * @param polygon a mesh built from polygonTriangulation.build()
  83421. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83422. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83423. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83424. * @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)
  83425. * @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)
  83426. * @returns the VertexData of the Polygon
  83427. */
  83428. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83429. /**
  83430. * Creates the VertexData of the IcoSphere
  83431. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83432. * * radius the radius of the IcoSphere, optional default 1
  83433. * * radiusX allows stretching in the x direction, optional, default radius
  83434. * * radiusY allows stretching in the y direction, optional, default radius
  83435. * * radiusZ allows stretching in the z direction, optional, default radius
  83436. * * flat when true creates a flat shaded mesh, optional, default true
  83437. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83439. * * 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)
  83440. * * 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)
  83441. * @returns the VertexData of the IcoSphere
  83442. */
  83443. static CreateIcoSphere(options: {
  83444. radius?: number;
  83445. radiusX?: number;
  83446. radiusY?: number;
  83447. radiusZ?: number;
  83448. flat?: boolean;
  83449. subdivisions?: number;
  83450. sideOrientation?: number;
  83451. frontUVs?: Vector4;
  83452. backUVs?: Vector4;
  83453. }): VertexData;
  83454. /**
  83455. * Creates the VertexData for a Polyhedron
  83456. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83457. * * type provided types are:
  83458. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83459. * * 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)
  83460. * * size the size of the IcoSphere, optional default 1
  83461. * * sizeX allows stretching in the x direction, optional, default size
  83462. * * sizeY allows stretching in the y direction, optional, default size
  83463. * * sizeZ allows stretching in the z direction, optional, default size
  83464. * * 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
  83465. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83466. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83467. * * flat when true creates a flat shaded mesh, optional, default true
  83468. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83470. * * 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)
  83471. * * 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)
  83472. * @returns the VertexData of the Polyhedron
  83473. */
  83474. static CreatePolyhedron(options: {
  83475. type?: number;
  83476. size?: number;
  83477. sizeX?: number;
  83478. sizeY?: number;
  83479. sizeZ?: number;
  83480. custom?: any;
  83481. faceUV?: Vector4[];
  83482. faceColors?: Color4[];
  83483. flat?: boolean;
  83484. sideOrientation?: number;
  83485. frontUVs?: Vector4;
  83486. backUVs?: Vector4;
  83487. }): VertexData;
  83488. /**
  83489. * Creates the VertexData for a TorusKnot
  83490. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83491. * * radius the radius of the torus knot, optional, default 2
  83492. * * tube the thickness of the tube, optional, default 0.5
  83493. * * radialSegments the number of sides on each tube segments, optional, default 32
  83494. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83495. * * p the number of windings around the z axis, optional, default 2
  83496. * * q the number of windings around the x axis, optional, default 3
  83497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83498. * * 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)
  83499. * * 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)
  83500. * @returns the VertexData of the Torus Knot
  83501. */
  83502. static CreateTorusKnot(options: {
  83503. radius?: number;
  83504. tube?: number;
  83505. radialSegments?: number;
  83506. tubularSegments?: number;
  83507. p?: number;
  83508. q?: number;
  83509. sideOrientation?: number;
  83510. frontUVs?: Vector4;
  83511. backUVs?: Vector4;
  83512. }): VertexData;
  83513. /**
  83514. * Compute normals for given positions and indices
  83515. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83516. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83517. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83518. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83519. * * facetNormals : optional array of facet normals (vector3)
  83520. * * facetPositions : optional array of facet positions (vector3)
  83521. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83522. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83523. * * bInfo : optional bounding info, required for facetPartitioning computation
  83524. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83525. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83526. * * useRightHandedSystem: optional boolean to for right handed system computation
  83527. * * depthSort : optional boolean to enable the facet depth sort computation
  83528. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83529. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83530. */
  83531. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83532. facetNormals?: any;
  83533. facetPositions?: any;
  83534. facetPartitioning?: any;
  83535. ratio?: number;
  83536. bInfo?: any;
  83537. bbSize?: Vector3;
  83538. subDiv?: any;
  83539. useRightHandedSystem?: boolean;
  83540. depthSort?: boolean;
  83541. distanceTo?: Vector3;
  83542. depthSortedFacets?: any;
  83543. }): void;
  83544. /** @hidden */
  83545. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83546. /**
  83547. * Applies VertexData created from the imported parameters to the geometry
  83548. * @param parsedVertexData the parsed data from an imported file
  83549. * @param geometry the geometry to apply the VertexData to
  83550. */
  83551. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83552. }
  83553. }
  83554. declare module BABYLON {
  83555. /**
  83556. * Class containing static functions to help procedurally build meshes
  83557. */
  83558. export class DiscBuilder {
  83559. /**
  83560. * Creates a plane polygonal mesh. By default, this is a disc
  83561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83562. * * 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
  83563. * * 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
  83564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83567. * @param name defines the name of the mesh
  83568. * @param options defines the options used to create the mesh
  83569. * @param scene defines the hosting scene
  83570. * @returns the plane polygonal mesh
  83571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83572. */
  83573. static CreateDisc(name: string, options: {
  83574. radius?: number;
  83575. tessellation?: number;
  83576. arc?: number;
  83577. updatable?: boolean;
  83578. sideOrientation?: number;
  83579. frontUVs?: Vector4;
  83580. backUVs?: Vector4;
  83581. }, scene?: Nullable<Scene>): Mesh;
  83582. }
  83583. }
  83584. declare module BABYLON {
  83585. /**
  83586. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83587. *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.
  83588. * The SPS is also a particle system. It provides some methods to manage the particles.
  83589. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83590. *
  83591. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83592. */
  83593. export class SolidParticleSystem implements IDisposable {
  83594. /**
  83595. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83596. * Example : var p = SPS.particles[i];
  83597. */
  83598. particles: SolidParticle[];
  83599. /**
  83600. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83601. */
  83602. nbParticles: number;
  83603. /**
  83604. * If the particles must ever face the camera (default false). Useful for planar particles.
  83605. */
  83606. billboard: boolean;
  83607. /**
  83608. * Recompute normals when adding a shape
  83609. */
  83610. recomputeNormals: boolean;
  83611. /**
  83612. * This a counter ofr your own usage. It's not set by any SPS functions.
  83613. */
  83614. counter: number;
  83615. /**
  83616. * The SPS name. This name is also given to the underlying mesh.
  83617. */
  83618. name: string;
  83619. /**
  83620. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83621. */
  83622. mesh: Mesh;
  83623. /**
  83624. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83625. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83626. */
  83627. vars: any;
  83628. /**
  83629. * This array is populated when the SPS is set as 'pickable'.
  83630. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83631. * Each element of this array is an object `{idx: int, faceId: int}`.
  83632. * `idx` is the picked particle index in the `SPS.particles` array
  83633. * `faceId` is the picked face index counted within this particle.
  83634. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83635. */
  83636. pickedParticles: {
  83637. idx: number;
  83638. faceId: number;
  83639. }[];
  83640. /**
  83641. * This array is populated when `enableDepthSort` is set to true.
  83642. * Each element of this array is an instance of the class DepthSortedParticle.
  83643. */
  83644. depthSortedParticles: DepthSortedParticle[];
  83645. /**
  83646. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83647. * @hidden
  83648. */
  83649. _bSphereOnly: boolean;
  83650. /**
  83651. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83652. * @hidden
  83653. */
  83654. _bSphereRadiusFactor: number;
  83655. private _scene;
  83656. private _positions;
  83657. private _indices;
  83658. private _normals;
  83659. private _colors;
  83660. private _uvs;
  83661. private _indices32;
  83662. private _positions32;
  83663. private _normals32;
  83664. private _fixedNormal32;
  83665. private _colors32;
  83666. private _uvs32;
  83667. private _index;
  83668. private _updatable;
  83669. private _pickable;
  83670. private _isVisibilityBoxLocked;
  83671. private _alwaysVisible;
  83672. private _depthSort;
  83673. private _shapeCounter;
  83674. private _copy;
  83675. private _color;
  83676. private _computeParticleColor;
  83677. private _computeParticleTexture;
  83678. private _computeParticleRotation;
  83679. private _computeParticleVertex;
  83680. private _computeBoundingBox;
  83681. private _depthSortParticles;
  83682. private _camera;
  83683. private _mustUnrotateFixedNormals;
  83684. private _particlesIntersect;
  83685. private _needs32Bits;
  83686. /**
  83687. * Creates a SPS (Solid Particle System) object.
  83688. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83689. * @param scene (Scene) is the scene in which the SPS is added.
  83690. * @param options defines the options of the sps e.g.
  83691. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83692. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83693. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83694. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83695. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83696. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83697. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83698. */
  83699. constructor(name: string, scene: Scene, options?: {
  83700. updatable?: boolean;
  83701. isPickable?: boolean;
  83702. enableDepthSort?: boolean;
  83703. particleIntersection?: boolean;
  83704. boundingSphereOnly?: boolean;
  83705. bSphereRadiusFactor?: number;
  83706. });
  83707. /**
  83708. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83709. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83710. * @returns the created mesh
  83711. */
  83712. buildMesh(): Mesh;
  83713. /**
  83714. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83715. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83716. * Thus the particles generated from `digest()` have their property `position` set yet.
  83717. * @param mesh ( Mesh ) is the mesh to be digested
  83718. * @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
  83719. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83720. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83721. * @returns the current SPS
  83722. */
  83723. digest(mesh: Mesh, options?: {
  83724. facetNb?: number;
  83725. number?: number;
  83726. delta?: number;
  83727. }): SolidParticleSystem;
  83728. private _unrotateFixedNormals;
  83729. private _resetCopy;
  83730. private _meshBuilder;
  83731. private _posToShape;
  83732. private _uvsToShapeUV;
  83733. private _addParticle;
  83734. /**
  83735. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83736. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83737. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83738. * @param nb (positive integer) the number of particles to be created from this model
  83739. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83740. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83741. * @returns the number of shapes in the system
  83742. */
  83743. addShape(mesh: Mesh, nb: number, options?: {
  83744. positionFunction?: any;
  83745. vertexFunction?: any;
  83746. }): number;
  83747. private _rebuildParticle;
  83748. /**
  83749. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83750. * @returns the SPS.
  83751. */
  83752. rebuildMesh(): SolidParticleSystem;
  83753. /**
  83754. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83755. * This method calls `updateParticle()` for each particle of the SPS.
  83756. * For an animated SPS, it is usually called within the render loop.
  83757. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83758. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83759. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83760. * @returns the SPS.
  83761. */
  83762. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83763. /**
  83764. * Disposes the SPS.
  83765. */
  83766. dispose(): void;
  83767. /**
  83768. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83769. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83770. * @returns the SPS.
  83771. */
  83772. refreshVisibleSize(): SolidParticleSystem;
  83773. /**
  83774. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83775. * @param size the size (float) of the visibility box
  83776. * note : this doesn't lock the SPS mesh bounding box.
  83777. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83778. */
  83779. setVisibilityBox(size: number): void;
  83780. /**
  83781. * Gets whether the SPS as always visible or not
  83782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83783. */
  83784. /**
  83785. * Sets the SPS as always visible or not
  83786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83787. */
  83788. isAlwaysVisible: boolean;
  83789. /**
  83790. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83792. */
  83793. /**
  83794. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83796. */
  83797. isVisibilityBoxLocked: boolean;
  83798. /**
  83799. * Tells to `setParticles()` to compute the particle rotations or not.
  83800. * Default value : true. The SPS is faster when it's set to false.
  83801. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83802. */
  83803. /**
  83804. * Gets if `setParticles()` computes the particle rotations or not.
  83805. * Default value : true. The SPS is faster when it's set to false.
  83806. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83807. */
  83808. computeParticleRotation: boolean;
  83809. /**
  83810. * Tells to `setParticles()` to compute the particle colors or not.
  83811. * Default value : true. The SPS is faster when it's set to false.
  83812. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83813. */
  83814. /**
  83815. * Gets if `setParticles()` computes the particle colors or not.
  83816. * Default value : true. The SPS is faster when it's set to false.
  83817. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83818. */
  83819. computeParticleColor: boolean;
  83820. /**
  83821. * Gets if `setParticles()` computes the particle textures or not.
  83822. * Default value : true. The SPS is faster when it's set to false.
  83823. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83824. */
  83825. computeParticleTexture: boolean;
  83826. /**
  83827. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83828. * Default value : false. The SPS is faster when it's set to false.
  83829. * Note : the particle custom vertex positions aren't stored values.
  83830. */
  83831. /**
  83832. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83833. * Default value : false. The SPS is faster when it's set to false.
  83834. * Note : the particle custom vertex positions aren't stored values.
  83835. */
  83836. computeParticleVertex: boolean;
  83837. /**
  83838. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83839. */
  83840. /**
  83841. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83842. */
  83843. computeBoundingBox: boolean;
  83844. /**
  83845. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83846. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83847. * Default : `true`
  83848. */
  83849. /**
  83850. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83851. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83852. * Default : `true`
  83853. */
  83854. depthSortParticles: boolean;
  83855. /**
  83856. * This function does nothing. It may be overwritten to set all the particle first values.
  83857. * The SPS doesn't call this function, you may have to call it by your own.
  83858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83859. */
  83860. initParticles(): void;
  83861. /**
  83862. * This function does nothing. It may be overwritten to recycle a particle.
  83863. * The SPS doesn't call this function, you may have to call it by your own.
  83864. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83865. * @param particle The particle to recycle
  83866. * @returns the recycled particle
  83867. */
  83868. recycleParticle(particle: SolidParticle): SolidParticle;
  83869. /**
  83870. * Updates a particle : this function should be overwritten by the user.
  83871. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83873. * @example : just set a particle position or velocity and recycle conditions
  83874. * @param particle The particle to update
  83875. * @returns the updated particle
  83876. */
  83877. updateParticle(particle: SolidParticle): SolidParticle;
  83878. /**
  83879. * Updates a vertex of a particle : it can be overwritten by the user.
  83880. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83881. * @param particle the current particle
  83882. * @param vertex the current index of the current particle
  83883. * @param pt the index of the current vertex in the particle shape
  83884. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83885. * @example : just set a vertex particle position
  83886. * @returns the updated vertex
  83887. */
  83888. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83889. /**
  83890. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83891. * This does nothing and may be overwritten by the user.
  83892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83894. * @param update the boolean update value actually passed to setParticles()
  83895. */
  83896. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83897. /**
  83898. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83899. * This will be passed three parameters.
  83900. * This does nothing and may be overwritten by the user.
  83901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83903. * @param update the boolean update value actually passed to setParticles()
  83904. */
  83905. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * Represents one particle of a solid particle system.
  83911. */
  83912. export class SolidParticle {
  83913. /**
  83914. * particle global index
  83915. */
  83916. idx: number;
  83917. /**
  83918. * The color of the particle
  83919. */
  83920. color: Nullable<Color4>;
  83921. /**
  83922. * The world space position of the particle.
  83923. */
  83924. position: Vector3;
  83925. /**
  83926. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83927. */
  83928. rotation: Vector3;
  83929. /**
  83930. * The world space rotation quaternion of the particle.
  83931. */
  83932. rotationQuaternion: Nullable<Quaternion>;
  83933. /**
  83934. * The scaling of the particle.
  83935. */
  83936. scaling: Vector3;
  83937. /**
  83938. * The uvs of the particle.
  83939. */
  83940. uvs: Vector4;
  83941. /**
  83942. * The current speed of the particle.
  83943. */
  83944. velocity: Vector3;
  83945. /**
  83946. * The pivot point in the particle local space.
  83947. */
  83948. pivot: Vector3;
  83949. /**
  83950. * Must the particle be translated from its pivot point in its local space ?
  83951. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83952. * Default : false
  83953. */
  83954. translateFromPivot: boolean;
  83955. /**
  83956. * Is the particle active or not ?
  83957. */
  83958. alive: boolean;
  83959. /**
  83960. * Is the particle visible or not ?
  83961. */
  83962. isVisible: boolean;
  83963. /**
  83964. * Index of this particle in the global "positions" array (Internal use)
  83965. * @hidden
  83966. */
  83967. _pos: number;
  83968. /**
  83969. * @hidden Index of this particle in the global "indices" array (Internal use)
  83970. */
  83971. _ind: number;
  83972. /**
  83973. * @hidden ModelShape of this particle (Internal use)
  83974. */
  83975. _model: ModelShape;
  83976. /**
  83977. * ModelShape id of this particle
  83978. */
  83979. shapeId: number;
  83980. /**
  83981. * Index of the particle in its shape id (Internal use)
  83982. */
  83983. idxInShape: number;
  83984. /**
  83985. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83986. */
  83987. _modelBoundingInfo: BoundingInfo;
  83988. /**
  83989. * @hidden Particle BoundingInfo object (Internal use)
  83990. */
  83991. _boundingInfo: BoundingInfo;
  83992. /**
  83993. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83994. */
  83995. _sps: SolidParticleSystem;
  83996. /**
  83997. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83998. */
  83999. _stillInvisible: boolean;
  84000. /**
  84001. * @hidden Last computed particle rotation matrix
  84002. */
  84003. _rotationMatrix: number[];
  84004. /**
  84005. * Parent particle Id, if any.
  84006. * Default null.
  84007. */
  84008. parentId: Nullable<number>;
  84009. /**
  84010. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84011. * The possible values are :
  84012. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84013. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84014. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84015. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84016. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84017. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84018. * */
  84019. cullingStrategy: number;
  84020. /**
  84021. * @hidden Internal global position in the SPS.
  84022. */
  84023. _globalPosition: Vector3;
  84024. /**
  84025. * Creates a Solid Particle object.
  84026. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84027. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84028. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84029. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84030. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84031. * @param shapeId (integer) is the model shape identifier in the SPS.
  84032. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84033. * @param sps defines the sps it is associated to
  84034. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84035. */
  84036. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84037. /**
  84038. * Legacy support, changed scale to scaling
  84039. */
  84040. /**
  84041. * Legacy support, changed scale to scaling
  84042. */
  84043. scale: Vector3;
  84044. /**
  84045. * Legacy support, changed quaternion to rotationQuaternion
  84046. */
  84047. /**
  84048. * Legacy support, changed quaternion to rotationQuaternion
  84049. */
  84050. quaternion: Nullable<Quaternion>;
  84051. /**
  84052. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84053. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84054. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84055. * @returns true if it intersects
  84056. */
  84057. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84058. /**
  84059. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84060. * A particle is in the frustum if its bounding box intersects the frustum
  84061. * @param frustumPlanes defines the frustum to test
  84062. * @returns true if the particle is in the frustum planes
  84063. */
  84064. isInFrustum(frustumPlanes: Plane[]): boolean;
  84065. /**
  84066. * get the rotation matrix of the particle
  84067. * @hidden
  84068. */
  84069. getRotationMatrix(m: Matrix): void;
  84070. }
  84071. /**
  84072. * Represents the shape of the model used by one particle of a solid particle system.
  84073. * SPS internal tool, don't use it manually.
  84074. */
  84075. export class ModelShape {
  84076. /**
  84077. * The shape id
  84078. * @hidden
  84079. */
  84080. shapeID: number;
  84081. /**
  84082. * flat array of model positions (internal use)
  84083. * @hidden
  84084. */
  84085. _shape: Vector3[];
  84086. /**
  84087. * flat array of model UVs (internal use)
  84088. * @hidden
  84089. */
  84090. _shapeUV: number[];
  84091. /**
  84092. * length of the shape in the model indices array (internal use)
  84093. * @hidden
  84094. */
  84095. _indicesLength: number;
  84096. /**
  84097. * Custom position function (internal use)
  84098. * @hidden
  84099. */
  84100. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84101. /**
  84102. * Custom vertex function (internal use)
  84103. * @hidden
  84104. */
  84105. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84106. /**
  84107. * 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.
  84108. * SPS internal tool, don't use it manually.
  84109. * @hidden
  84110. */
  84111. 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>);
  84112. }
  84113. /**
  84114. * Represents a Depth Sorted Particle in the solid particle system.
  84115. */
  84116. export class DepthSortedParticle {
  84117. /**
  84118. * Index of the particle in the "indices" array
  84119. */
  84120. ind: number;
  84121. /**
  84122. * Length of the particle shape in the "indices" array
  84123. */
  84124. indicesLength: number;
  84125. /**
  84126. * Squared distance from the particle to the camera
  84127. */
  84128. sqDistance: number;
  84129. }
  84130. }
  84131. declare module BABYLON {
  84132. /**
  84133. * Class used to store all common mesh properties
  84134. */
  84135. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84136. /** No occlusion */
  84137. static OCCLUSION_TYPE_NONE: number;
  84138. /** Occlusion set to optimisitic */
  84139. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84140. /** Occlusion set to strict */
  84141. static OCCLUSION_TYPE_STRICT: number;
  84142. /** Use an accurante occlusion algorithm */
  84143. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84144. /** Use a conservative occlusion algorithm */
  84145. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84146. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84147. * Test order :
  84148. * Is the bounding sphere outside the frustum ?
  84149. * If not, are the bounding box vertices outside the frustum ?
  84150. * It not, then the cullable object is in the frustum.
  84151. */
  84152. static readonly CULLINGSTRATEGY_STANDARD: number;
  84153. /** Culling strategy : Bounding Sphere Only.
  84154. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84155. * It's also less accurate than the standard because some not visible objects can still be selected.
  84156. * Test : is the bounding sphere outside the frustum ?
  84157. * If not, then the cullable object is in the frustum.
  84158. */
  84159. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84160. /** Culling strategy : Optimistic Inclusion.
  84161. * This in an inclusion test first, then the standard exclusion test.
  84162. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84163. * 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.
  84164. * Anyway, it's as accurate as the standard strategy.
  84165. * Test :
  84166. * Is the cullable object bounding sphere center in the frustum ?
  84167. * If not, apply the default culling strategy.
  84168. */
  84169. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84170. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84171. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84172. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84173. * 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.
  84174. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84175. * Test :
  84176. * Is the cullable object bounding sphere center in the frustum ?
  84177. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84178. */
  84179. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84180. /**
  84181. * No billboard
  84182. */
  84183. static readonly BILLBOARDMODE_NONE: number;
  84184. /** Billboard on X axis */
  84185. static readonly BILLBOARDMODE_X: number;
  84186. /** Billboard on Y axis */
  84187. static readonly BILLBOARDMODE_Y: number;
  84188. /** Billboard on Z axis */
  84189. static readonly BILLBOARDMODE_Z: number;
  84190. /** Billboard on all axes */
  84191. static readonly BILLBOARDMODE_ALL: number;
  84192. private _facetData;
  84193. /**
  84194. * The culling strategy to use to check whether the mesh must be rendered or not.
  84195. * This value can be changed at any time and will be used on the next render mesh selection.
  84196. * The possible values are :
  84197. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84198. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84199. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84200. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84201. * Please read each static variable documentation to get details about the culling process.
  84202. * */
  84203. cullingStrategy: number;
  84204. /**
  84205. * Gets the number of facets in the mesh
  84206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84207. */
  84208. readonly facetNb: number;
  84209. /**
  84210. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84212. */
  84213. partitioningSubdivisions: number;
  84214. /**
  84215. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84216. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84218. */
  84219. partitioningBBoxRatio: number;
  84220. /**
  84221. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84222. * Works only for updatable meshes.
  84223. * Doesn't work with multi-materials
  84224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84225. */
  84226. mustDepthSortFacets: boolean;
  84227. /**
  84228. * The location (Vector3) where the facet depth sort must be computed from.
  84229. * By default, the active camera position.
  84230. * Used only when facet depth sort is enabled
  84231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84232. */
  84233. facetDepthSortFrom: Vector3;
  84234. /**
  84235. * gets a boolean indicating if facetData is enabled
  84236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84237. */
  84238. readonly isFacetDataEnabled: boolean;
  84239. /** @hidden */
  84240. _updateNonUniformScalingState(value: boolean): boolean;
  84241. /**
  84242. * An event triggered when this mesh collides with another one
  84243. */
  84244. onCollideObservable: Observable<AbstractMesh>;
  84245. private _onCollideObserver;
  84246. /** Set a function to call when this mesh collides with another one */
  84247. onCollide: () => void;
  84248. /**
  84249. * An event triggered when the collision's position changes
  84250. */
  84251. onCollisionPositionChangeObservable: Observable<Vector3>;
  84252. private _onCollisionPositionChangeObserver;
  84253. /** Set a function to call when the collision's position changes */
  84254. onCollisionPositionChange: () => void;
  84255. /**
  84256. * An event triggered when material is changed
  84257. */
  84258. onMaterialChangedObservable: Observable<AbstractMesh>;
  84259. /**
  84260. * Gets or sets the orientation for POV movement & rotation
  84261. */
  84262. definedFacingForward: boolean;
  84263. /** @hidden */
  84264. _occlusionQuery: Nullable<WebGLQuery>;
  84265. private _visibility;
  84266. /** @hidden */
  84267. _isActive: boolean;
  84268. /** @hidden */
  84269. _onlyForInstances: boolean;
  84270. /** @hidden */
  84271. _renderingGroup: Nullable<RenderingGroup>;
  84272. /**
  84273. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84274. */
  84275. /**
  84276. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84277. */
  84278. visibility: number;
  84279. /** Gets or sets the alpha index used to sort transparent meshes
  84280. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84281. */
  84282. alphaIndex: number;
  84283. /**
  84284. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84285. */
  84286. isVisible: boolean;
  84287. /**
  84288. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84289. */
  84290. isPickable: boolean;
  84291. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84292. showSubMeshesBoundingBox: boolean;
  84293. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84294. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84295. */
  84296. isBlocker: boolean;
  84297. /**
  84298. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84299. */
  84300. enablePointerMoveEvents: boolean;
  84301. /**
  84302. * Specifies the rendering group id for this mesh (0 by default)
  84303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84304. */
  84305. renderingGroupId: number;
  84306. private _material;
  84307. /** Gets or sets current material */
  84308. material: Nullable<Material>;
  84309. private _receiveShadows;
  84310. /**
  84311. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84312. * @see http://doc.babylonjs.com/babylon101/shadows
  84313. */
  84314. receiveShadows: boolean;
  84315. /** Defines color to use when rendering outline */
  84316. outlineColor: Color3;
  84317. /** Define width to use when rendering outline */
  84318. outlineWidth: number;
  84319. /** Defines color to use when rendering overlay */
  84320. overlayColor: Color3;
  84321. /** Defines alpha to use when rendering overlay */
  84322. overlayAlpha: number;
  84323. private _hasVertexAlpha;
  84324. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84325. hasVertexAlpha: boolean;
  84326. private _useVertexColors;
  84327. /** 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) */
  84328. useVertexColors: boolean;
  84329. private _computeBonesUsingShaders;
  84330. /**
  84331. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84332. */
  84333. computeBonesUsingShaders: boolean;
  84334. private _numBoneInfluencers;
  84335. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84336. numBoneInfluencers: number;
  84337. private _applyFog;
  84338. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84339. applyFog: boolean;
  84340. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84341. useOctreeForRenderingSelection: boolean;
  84342. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84343. useOctreeForPicking: boolean;
  84344. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84345. useOctreeForCollisions: boolean;
  84346. private _layerMask;
  84347. /**
  84348. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84349. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84350. */
  84351. layerMask: number;
  84352. /**
  84353. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84354. */
  84355. alwaysSelectAsActiveMesh: boolean;
  84356. /**
  84357. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84358. */
  84359. doNotSyncBoundingInfo: boolean;
  84360. /**
  84361. * Gets or sets the current action manager
  84362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84363. */
  84364. actionManager: Nullable<AbstractActionManager>;
  84365. private _checkCollisions;
  84366. private _collisionMask;
  84367. private _collisionGroup;
  84368. /**
  84369. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84371. */
  84372. ellipsoid: Vector3;
  84373. /**
  84374. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84375. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84376. */
  84377. ellipsoidOffset: Vector3;
  84378. private _collider;
  84379. private _oldPositionForCollisions;
  84380. private _diffPositionForCollisions;
  84381. /**
  84382. * Gets or sets a collision mask used to mask collisions (default is -1).
  84383. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84384. */
  84385. collisionMask: number;
  84386. /**
  84387. * Gets or sets the current collision group mask (-1 by default).
  84388. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84389. */
  84390. collisionGroup: number;
  84391. /**
  84392. * Defines edge width used when edgesRenderer is enabled
  84393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84394. */
  84395. edgesWidth: number;
  84396. /**
  84397. * Defines edge color used when edgesRenderer is enabled
  84398. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84399. */
  84400. edgesColor: Color4;
  84401. /** @hidden */
  84402. _edgesRenderer: Nullable<IEdgesRenderer>;
  84403. /** @hidden */
  84404. _masterMesh: Nullable<AbstractMesh>;
  84405. /** @hidden */
  84406. _boundingInfo: Nullable<BoundingInfo>;
  84407. /** @hidden */
  84408. _renderId: number;
  84409. /**
  84410. * Gets or sets the list of subMeshes
  84411. * @see http://doc.babylonjs.com/how_to/multi_materials
  84412. */
  84413. subMeshes: SubMesh[];
  84414. /** @hidden */
  84415. _intersectionsInProgress: AbstractMesh[];
  84416. /** @hidden */
  84417. _unIndexed: boolean;
  84418. /** @hidden */
  84419. _lightSources: Light[];
  84420. /** Gets the list of lights affecting that mesh */
  84421. readonly lightSources: Light[];
  84422. /** @hidden */
  84423. readonly _positions: Nullable<Vector3[]>;
  84424. /** @hidden */
  84425. _waitingActions: Nullable<any>;
  84426. /** @hidden */
  84427. _waitingFreezeWorldMatrix: Nullable<boolean>;
  84428. private _skeleton;
  84429. /** @hidden */
  84430. _bonesTransformMatrices: Nullable<Float32Array>;
  84431. /**
  84432. * Gets or sets a skeleton to apply skining transformations
  84433. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84434. */
  84435. skeleton: Nullable<Skeleton>;
  84436. /**
  84437. * An event triggered when the mesh is rebuilt.
  84438. */
  84439. onRebuildObservable: Observable<AbstractMesh>;
  84440. /**
  84441. * Creates a new AbstractMesh
  84442. * @param name defines the name of the mesh
  84443. * @param scene defines the hosting scene
  84444. */
  84445. constructor(name: string, scene?: Nullable<Scene>);
  84446. /**
  84447. * Returns the string "AbstractMesh"
  84448. * @returns "AbstractMesh"
  84449. */
  84450. getClassName(): string;
  84451. /**
  84452. * Gets a string representation of the current mesh
  84453. * @param fullDetails defines a boolean indicating if full details must be included
  84454. * @returns a string representation of the current mesh
  84455. */
  84456. toString(fullDetails?: boolean): string;
  84457. /**
  84458. * @hidden
  84459. */
  84460. protected _getEffectiveParent(): Nullable<Node>;
  84461. /** @hidden */
  84462. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84463. /** @hidden */
  84464. _rebuild(): void;
  84465. /** @hidden */
  84466. _resyncLightSources(): void;
  84467. /** @hidden */
  84468. _resyncLighSource(light: Light): void;
  84469. /** @hidden */
  84470. _unBindEffect(): void;
  84471. /** @hidden */
  84472. _removeLightSource(light: Light): void;
  84473. private _markSubMeshesAsDirty;
  84474. /** @hidden */
  84475. _markSubMeshesAsLightDirty(): void;
  84476. /** @hidden */
  84477. _markSubMeshesAsAttributesDirty(): void;
  84478. /** @hidden */
  84479. _markSubMeshesAsMiscDirty(): void;
  84480. /**
  84481. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84482. */
  84483. scaling: Vector3;
  84484. /**
  84485. * Returns true if the mesh is blocked. Implemented by child classes
  84486. */
  84487. readonly isBlocked: boolean;
  84488. /**
  84489. * Returns the mesh itself by default. Implemented by child classes
  84490. * @param camera defines the camera to use to pick the right LOD level
  84491. * @returns the currentAbstractMesh
  84492. */
  84493. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84494. /**
  84495. * Returns 0 by default. Implemented by child classes
  84496. * @returns an integer
  84497. */
  84498. getTotalVertices(): number;
  84499. /**
  84500. * Returns a positive integer : the total number of indices in this mesh geometry.
  84501. * @returns the numner of indices or zero if the mesh has no geometry.
  84502. */
  84503. getTotalIndices(): number;
  84504. /**
  84505. * Returns null by default. Implemented by child classes
  84506. * @returns null
  84507. */
  84508. getIndices(): Nullable<IndicesArray>;
  84509. /**
  84510. * Returns the array of the requested vertex data kind. Implemented by child classes
  84511. * @param kind defines the vertex data kind to use
  84512. * @returns null
  84513. */
  84514. getVerticesData(kind: string): Nullable<FloatArray>;
  84515. /**
  84516. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84517. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84518. * Note that a new underlying VertexBuffer object is created each call.
  84519. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84520. * @param kind defines vertex data kind:
  84521. * * VertexBuffer.PositionKind
  84522. * * VertexBuffer.UVKind
  84523. * * VertexBuffer.UV2Kind
  84524. * * VertexBuffer.UV3Kind
  84525. * * VertexBuffer.UV4Kind
  84526. * * VertexBuffer.UV5Kind
  84527. * * VertexBuffer.UV6Kind
  84528. * * VertexBuffer.ColorKind
  84529. * * VertexBuffer.MatricesIndicesKind
  84530. * * VertexBuffer.MatricesIndicesExtraKind
  84531. * * VertexBuffer.MatricesWeightsKind
  84532. * * VertexBuffer.MatricesWeightsExtraKind
  84533. * @param data defines the data source
  84534. * @param updatable defines if the data must be flagged as updatable (or static)
  84535. * @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
  84536. * @returns the current mesh
  84537. */
  84538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84539. /**
  84540. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84541. * If the mesh has no geometry, it is simply returned as it is.
  84542. * @param kind defines vertex data kind:
  84543. * * VertexBuffer.PositionKind
  84544. * * VertexBuffer.UVKind
  84545. * * VertexBuffer.UV2Kind
  84546. * * VertexBuffer.UV3Kind
  84547. * * VertexBuffer.UV4Kind
  84548. * * VertexBuffer.UV5Kind
  84549. * * VertexBuffer.UV6Kind
  84550. * * VertexBuffer.ColorKind
  84551. * * VertexBuffer.MatricesIndicesKind
  84552. * * VertexBuffer.MatricesIndicesExtraKind
  84553. * * VertexBuffer.MatricesWeightsKind
  84554. * * VertexBuffer.MatricesWeightsExtraKind
  84555. * @param data defines the data source
  84556. * @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
  84557. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84558. * @returns the current mesh
  84559. */
  84560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84561. /**
  84562. * Sets the mesh indices,
  84563. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84564. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84565. * @param totalVertices Defines the total number of vertices
  84566. * @returns the current mesh
  84567. */
  84568. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84569. /**
  84570. * Gets a boolean indicating if specific vertex data is present
  84571. * @param kind defines the vertex data kind to use
  84572. * @returns true is data kind is present
  84573. */
  84574. isVerticesDataPresent(kind: string): boolean;
  84575. /**
  84576. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84577. * @returns a BoundingInfo
  84578. */
  84579. getBoundingInfo(): BoundingInfo;
  84580. /**
  84581. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84582. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84583. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84584. * @returns the current mesh
  84585. */
  84586. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84587. /**
  84588. * Overwrite the current bounding info
  84589. * @param boundingInfo defines the new bounding info
  84590. * @returns the current mesh
  84591. */
  84592. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84593. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84594. readonly useBones: boolean;
  84595. /** @hidden */
  84596. _preActivate(): void;
  84597. /** @hidden */
  84598. _preActivateForIntermediateRendering(renderId: number): void;
  84599. /** @hidden */
  84600. _activate(renderId: number): boolean;
  84601. /** @hidden */
  84602. _freeze(): void;
  84603. /** @hidden */
  84604. _unFreeze(): void;
  84605. /**
  84606. * Gets the current world matrix
  84607. * @returns a Matrix
  84608. */
  84609. getWorldMatrix(): Matrix;
  84610. /** @hidden */
  84611. _getWorldMatrixDeterminant(): number;
  84612. /**
  84613. * Perform relative position change from the point of view of behind the front of the mesh.
  84614. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84615. * Supports definition of mesh facing forward or backward
  84616. * @param amountRight defines the distance on the right axis
  84617. * @param amountUp defines the distance on the up axis
  84618. * @param amountForward defines the distance on the forward axis
  84619. * @returns the current mesh
  84620. */
  84621. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84622. /**
  84623. * Calculate relative position change from the point of view of behind the front of the mesh.
  84624. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84625. * Supports definition of mesh facing forward or backward
  84626. * @param amountRight defines the distance on the right axis
  84627. * @param amountUp defines the distance on the up axis
  84628. * @param amountForward defines the distance on the forward axis
  84629. * @returns the new displacement vector
  84630. */
  84631. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84632. /**
  84633. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84634. * Supports definition of mesh facing forward or backward
  84635. * @param flipBack defines the flip
  84636. * @param twirlClockwise defines the twirl
  84637. * @param tiltRight defines the tilt
  84638. * @returns the current mesh
  84639. */
  84640. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84641. /**
  84642. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84643. * Supports definition of mesh facing forward or backward.
  84644. * @param flipBack defines the flip
  84645. * @param twirlClockwise defines the twirl
  84646. * @param tiltRight defines the tilt
  84647. * @returns the new rotation vector
  84648. */
  84649. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84650. /**
  84651. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84652. * This means the mesh underlying bounding box and sphere are recomputed.
  84653. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84654. * @returns the current mesh
  84655. */
  84656. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84657. /** @hidden */
  84658. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84659. /** @hidden */
  84660. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84661. /** @hidden */
  84662. _updateBoundingInfo(): AbstractMesh;
  84663. /** @hidden */
  84664. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84665. /** @hidden */
  84666. protected _afterComputeWorldMatrix(): void;
  84667. /** @hidden */
  84668. readonly _effectiveMesh: AbstractMesh;
  84669. /**
  84670. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84671. * A mesh is in the frustum if its bounding box intersects the frustum
  84672. * @param frustumPlanes defines the frustum to test
  84673. * @returns true if the mesh is in the frustum planes
  84674. */
  84675. isInFrustum(frustumPlanes: Plane[]): boolean;
  84676. /**
  84677. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84678. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84679. * @param frustumPlanes defines the frustum to test
  84680. * @returns true if the mesh is completely in the frustum planes
  84681. */
  84682. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84683. /**
  84684. * True if the mesh intersects another mesh or a SolidParticle object
  84685. * @param mesh defines a target mesh or SolidParticle to test
  84686. * @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)
  84687. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84688. * @returns true if there is an intersection
  84689. */
  84690. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84691. /**
  84692. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84693. * @param point defines the point to test
  84694. * @returns true if there is an intersection
  84695. */
  84696. intersectsPoint(point: Vector3): boolean;
  84697. /**
  84698. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84699. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84700. */
  84701. checkCollisions: boolean;
  84702. /**
  84703. * Gets Collider object used to compute collisions (not physics)
  84704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84705. */
  84706. readonly collider: Nullable<Collider>;
  84707. /**
  84708. * Move the mesh using collision engine
  84709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84710. * @param displacement defines the requested displacement vector
  84711. * @returns the current mesh
  84712. */
  84713. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84714. private _onCollisionPositionChange;
  84715. /** @hidden */
  84716. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84717. /** @hidden */
  84718. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84719. /** @hidden */
  84720. _checkCollision(collider: Collider): AbstractMesh;
  84721. /** @hidden */
  84722. _generatePointsArray(): boolean;
  84723. /**
  84724. * Checks if the passed Ray intersects with the mesh
  84725. * @param ray defines the ray to use
  84726. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84728. * @returns the picking info
  84729. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84730. */
  84731. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84732. /**
  84733. * Clones the current mesh
  84734. * @param name defines the mesh name
  84735. * @param newParent defines the new mesh parent
  84736. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84737. * @returns the new mesh
  84738. */
  84739. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84740. /**
  84741. * Disposes all the submeshes of the current meshnp
  84742. * @returns the current mesh
  84743. */
  84744. releaseSubMeshes(): AbstractMesh;
  84745. /**
  84746. * Releases resources associated with this abstract mesh.
  84747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84749. */
  84750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84751. /**
  84752. * Adds the passed mesh as a child to the current mesh
  84753. * @param mesh defines the child mesh
  84754. * @returns the current mesh
  84755. */
  84756. addChild(mesh: AbstractMesh): AbstractMesh;
  84757. /**
  84758. * Removes the passed mesh from the current mesh children list
  84759. * @param mesh defines the child mesh
  84760. * @returns the current mesh
  84761. */
  84762. removeChild(mesh: AbstractMesh): AbstractMesh;
  84763. /** @hidden */
  84764. private _initFacetData;
  84765. /**
  84766. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84767. * This method can be called within the render loop.
  84768. * 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
  84769. * @returns the current mesh
  84770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84771. */
  84772. updateFacetData(): AbstractMesh;
  84773. /**
  84774. * Returns the facetLocalNormals array.
  84775. * The normals are expressed in the mesh local spac
  84776. * @returns an array of Vector3
  84777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84778. */
  84779. getFacetLocalNormals(): Vector3[];
  84780. /**
  84781. * Returns the facetLocalPositions array.
  84782. * The facet positions are expressed in the mesh local space
  84783. * @returns an array of Vector3
  84784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84785. */
  84786. getFacetLocalPositions(): Vector3[];
  84787. /**
  84788. * Returns the facetLocalPartioning array
  84789. * @returns an array of array of numbers
  84790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84791. */
  84792. getFacetLocalPartitioning(): number[][];
  84793. /**
  84794. * Returns the i-th facet position in the world system.
  84795. * This method allocates a new Vector3 per call
  84796. * @param i defines the facet index
  84797. * @returns a new Vector3
  84798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84799. */
  84800. getFacetPosition(i: number): Vector3;
  84801. /**
  84802. * Sets the reference Vector3 with the i-th facet position in the world system
  84803. * @param i defines the facet index
  84804. * @param ref defines the target vector
  84805. * @returns the current mesh
  84806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84807. */
  84808. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84809. /**
  84810. * Returns the i-th facet normal in the world system.
  84811. * This method allocates a new Vector3 per call
  84812. * @param i defines the facet index
  84813. * @returns a new Vector3
  84814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84815. */
  84816. getFacetNormal(i: number): Vector3;
  84817. /**
  84818. * Sets the reference Vector3 with the i-th facet normal in the world system
  84819. * @param i defines the facet index
  84820. * @param ref defines the target vector
  84821. * @returns the current mesh
  84822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84823. */
  84824. getFacetNormalToRef(i: number, ref: Vector3): this;
  84825. /**
  84826. * 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)
  84827. * @param x defines x coordinate
  84828. * @param y defines y coordinate
  84829. * @param z defines z coordinate
  84830. * @returns the array of facet indexes
  84831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84832. */
  84833. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84834. /**
  84835. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84836. * @param projected sets as the (x,y,z) world projection on the facet
  84837. * @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
  84838. * @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
  84839. * @param x defines x coordinate
  84840. * @param y defines y coordinate
  84841. * @param z defines z coordinate
  84842. * @returns the face index if found (or null instead)
  84843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84844. */
  84845. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84846. /**
  84847. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84848. * @param projected sets as the (x,y,z) local projection on the facet
  84849. * @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
  84850. * @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
  84851. * @param x defines x coordinate
  84852. * @param y defines y coordinate
  84853. * @param z defines z coordinate
  84854. * @returns the face index if found (or null instead)
  84855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84856. */
  84857. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84858. /**
  84859. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84860. * @returns the parameters
  84861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84862. */
  84863. getFacetDataParameters(): any;
  84864. /**
  84865. * Disables the feature FacetData and frees the related memory
  84866. * @returns the current mesh
  84867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84868. */
  84869. disableFacetData(): AbstractMesh;
  84870. /**
  84871. * Updates the AbstractMesh indices array
  84872. * @param indices defines the data source
  84873. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84874. * @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)
  84875. * @returns the current mesh
  84876. */
  84877. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84878. /**
  84879. * Creates new normals data for the mesh
  84880. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84881. * @returns the current mesh
  84882. */
  84883. createNormals(updatable: boolean): AbstractMesh;
  84884. /**
  84885. * Align the mesh with a normal
  84886. * @param normal defines the normal to use
  84887. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84888. * @returns the current mesh
  84889. */
  84890. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84891. /** @hidden */
  84892. _checkOcclusionQuery(): boolean;
  84893. }
  84894. }
  84895. declare module BABYLON {
  84896. /**
  84897. * Interface used to define ActionEvent
  84898. */
  84899. export interface IActionEvent {
  84900. /** The mesh or sprite that triggered the action */
  84901. source: any;
  84902. /** The X mouse cursor position at the time of the event */
  84903. pointerX: number;
  84904. /** The Y mouse cursor position at the time of the event */
  84905. pointerY: number;
  84906. /** The mesh that is currently pointed at (can be null) */
  84907. meshUnderPointer: Nullable<AbstractMesh>;
  84908. /** the original (browser) event that triggered the ActionEvent */
  84909. sourceEvent?: any;
  84910. /** additional data for the event */
  84911. additionalData?: any;
  84912. }
  84913. /**
  84914. * ActionEvent is the event being sent when an action is triggered.
  84915. */
  84916. export class ActionEvent implements IActionEvent {
  84917. /** The mesh or sprite that triggered the action */
  84918. source: any;
  84919. /** The X mouse cursor position at the time of the event */
  84920. pointerX: number;
  84921. /** The Y mouse cursor position at the time of the event */
  84922. pointerY: number;
  84923. /** The mesh that is currently pointed at (can be null) */
  84924. meshUnderPointer: Nullable<AbstractMesh>;
  84925. /** the original (browser) event that triggered the ActionEvent */
  84926. sourceEvent?: any;
  84927. /** additional data for the event */
  84928. additionalData?: any;
  84929. /**
  84930. * Creates a new ActionEvent
  84931. * @param source The mesh or sprite that triggered the action
  84932. * @param pointerX The X mouse cursor position at the time of the event
  84933. * @param pointerY The Y mouse cursor position at the time of the event
  84934. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84935. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84936. * @param additionalData additional data for the event
  84937. */
  84938. constructor(
  84939. /** The mesh or sprite that triggered the action */
  84940. source: any,
  84941. /** The X mouse cursor position at the time of the event */
  84942. pointerX: number,
  84943. /** The Y mouse cursor position at the time of the event */
  84944. pointerY: number,
  84945. /** The mesh that is currently pointed at (can be null) */
  84946. meshUnderPointer: Nullable<AbstractMesh>,
  84947. /** the original (browser) event that triggered the ActionEvent */
  84948. sourceEvent?: any,
  84949. /** additional data for the event */
  84950. additionalData?: any);
  84951. /**
  84952. * Helper function to auto-create an ActionEvent from a source mesh.
  84953. * @param source The source mesh that triggered the event
  84954. * @param evt The original (browser) event
  84955. * @param additionalData additional data for the event
  84956. * @returns the new ActionEvent
  84957. */
  84958. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84959. /**
  84960. * Helper function to auto-create an ActionEvent from a source sprite
  84961. * @param source The source sprite that triggered the event
  84962. * @param scene Scene associated with the sprite
  84963. * @param evt The original (browser) event
  84964. * @param additionalData additional data for the event
  84965. * @returns the new ActionEvent
  84966. */
  84967. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84968. /**
  84969. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84970. * @param scene the scene where the event occurred
  84971. * @param evt The original (browser) event
  84972. * @returns the new ActionEvent
  84973. */
  84974. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84975. /**
  84976. * Helper function to auto-create an ActionEvent from a primitive
  84977. * @param prim defines the target primitive
  84978. * @param pointerPos defines the pointer position
  84979. * @param evt The original (browser) event
  84980. * @param additionalData additional data for the event
  84981. * @returns the new ActionEvent
  84982. */
  84983. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84984. }
  84985. }
  84986. declare module BABYLON {
  84987. /**
  84988. * Abstract class used to decouple action Manager from scene and meshes.
  84989. * Do not instantiate.
  84990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84991. */
  84992. export abstract class AbstractActionManager implements IDisposable {
  84993. /** Gets the list of active triggers */
  84994. static Triggers: {
  84995. [key: string]: number;
  84996. };
  84997. /** Gets the cursor to use when hovering items */
  84998. hoverCursor: string;
  84999. /** Gets the list of actions */
  85000. actions: IAction[];
  85001. /**
  85002. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85003. */
  85004. isRecursive: boolean;
  85005. /**
  85006. * Releases all associated resources
  85007. */
  85008. abstract dispose(): void;
  85009. /**
  85010. * Does this action manager has pointer triggers
  85011. */
  85012. abstract readonly hasPointerTriggers: boolean;
  85013. /**
  85014. * Does this action manager has pick triggers
  85015. */
  85016. abstract readonly hasPickTriggers: boolean;
  85017. /**
  85018. * Process a specific trigger
  85019. * @param trigger defines the trigger to process
  85020. * @param evt defines the event details to be processed
  85021. */
  85022. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85023. /**
  85024. * Does this action manager handles actions of any of the given triggers
  85025. * @param triggers defines the triggers to be tested
  85026. * @return a boolean indicating whether one (or more) of the triggers is handled
  85027. */
  85028. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85029. /**
  85030. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85031. * speed.
  85032. * @param triggerA defines the trigger to be tested
  85033. * @param triggerB defines the trigger to be tested
  85034. * @return a boolean indicating whether one (or more) of the triggers is handled
  85035. */
  85036. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85037. /**
  85038. * Does this action manager handles actions of a given trigger
  85039. * @param trigger defines the trigger to be tested
  85040. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85041. * @return whether the trigger is handled
  85042. */
  85043. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85044. /**
  85045. * Serialize this manager to a JSON object
  85046. * @param name defines the property name to store this manager
  85047. * @returns a JSON representation of this manager
  85048. */
  85049. abstract serialize(name: string): any;
  85050. /**
  85051. * Registers an action to this action manager
  85052. * @param action defines the action to be registered
  85053. * @return the action amended (prepared) after registration
  85054. */
  85055. abstract registerAction(action: IAction): Nullable<IAction>;
  85056. /**
  85057. * Unregisters an action to this action manager
  85058. * @param action defines the action to be unregistered
  85059. * @return a boolean indicating whether the action has been unregistered
  85060. */
  85061. abstract unregisterAction(action: IAction): Boolean;
  85062. /**
  85063. * Does exist one action manager with at least one trigger
  85064. **/
  85065. static readonly HasTriggers: boolean;
  85066. /**
  85067. * Does exist one action manager with at least one pick trigger
  85068. **/
  85069. static readonly HasPickTriggers: boolean;
  85070. /**
  85071. * Does exist one action manager that handles actions of a given trigger
  85072. * @param trigger defines the trigger to be tested
  85073. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85074. **/
  85075. static HasSpecificTrigger(trigger: number): boolean;
  85076. }
  85077. }
  85078. declare module BABYLON {
  85079. /**
  85080. * Defines how a node can be built from a string name.
  85081. */
  85082. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85083. /**
  85084. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85085. */
  85086. export class Node implements IBehaviorAware<Node> {
  85087. /** @hidden */
  85088. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85089. private static _NodeConstructors;
  85090. /**
  85091. * Add a new node constructor
  85092. * @param type defines the type name of the node to construct
  85093. * @param constructorFunc defines the constructor function
  85094. */
  85095. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85096. /**
  85097. * Returns a node constructor based on type name
  85098. * @param type defines the type name
  85099. * @param name defines the new node name
  85100. * @param scene defines the hosting scene
  85101. * @param options defines optional options to transmit to constructors
  85102. * @returns the new constructor or null
  85103. */
  85104. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85105. /**
  85106. * Gets or sets the name of the node
  85107. */
  85108. name: string;
  85109. /**
  85110. * Gets or sets the id of the node
  85111. */
  85112. id: string;
  85113. /**
  85114. * Gets or sets the unique id of the node
  85115. */
  85116. uniqueId: number;
  85117. /**
  85118. * Gets or sets a string used to store user defined state for the node
  85119. */
  85120. state: string;
  85121. /**
  85122. * Gets or sets an object used to store user defined information for the node
  85123. */
  85124. metadata: any;
  85125. /**
  85126. * For internal use only. Please do not use.
  85127. */
  85128. reservedDataStore: any;
  85129. /**
  85130. * List of inspectable custom properties (used by the Inspector)
  85131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85132. */
  85133. inspectableCustomProperties: IInspectable[];
  85134. /**
  85135. * Gets or sets a boolean used to define if the node must be serialized
  85136. */
  85137. doNotSerialize: boolean;
  85138. /** @hidden */
  85139. _isDisposed: boolean;
  85140. /**
  85141. * Gets a list of Animations associated with the node
  85142. */
  85143. animations: Animation[];
  85144. protected _ranges: {
  85145. [name: string]: Nullable<AnimationRange>;
  85146. };
  85147. /**
  85148. * Callback raised when the node is ready to be used
  85149. */
  85150. onReady: Nullable<(node: Node) => void>;
  85151. private _isEnabled;
  85152. private _isParentEnabled;
  85153. private _isReady;
  85154. /** @hidden */
  85155. _currentRenderId: number;
  85156. private _parentUpdateId;
  85157. /** @hidden */
  85158. _childUpdateId: number;
  85159. /** @hidden */
  85160. _waitingParentId: Nullable<string>;
  85161. /** @hidden */
  85162. _scene: Scene;
  85163. /** @hidden */
  85164. _cache: any;
  85165. private _parentNode;
  85166. private _children;
  85167. /** @hidden */
  85168. _worldMatrix: Matrix;
  85169. /** @hidden */
  85170. _worldMatrixDeterminant: number;
  85171. /** @hidden */
  85172. _worldMatrixDeterminantIsDirty: boolean;
  85173. /** @hidden */
  85174. private _sceneRootNodesIndex;
  85175. /**
  85176. * Gets a boolean indicating if the node has been disposed
  85177. * @returns true if the node was disposed
  85178. */
  85179. isDisposed(): boolean;
  85180. /**
  85181. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85182. * @see https://doc.babylonjs.com/how_to/parenting
  85183. */
  85184. parent: Nullable<Node>;
  85185. private addToSceneRootNodes;
  85186. private removeFromSceneRootNodes;
  85187. private _animationPropertiesOverride;
  85188. /**
  85189. * Gets or sets the animation properties override
  85190. */
  85191. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85192. /**
  85193. * Gets a string idenfifying the name of the class
  85194. * @returns "Node" string
  85195. */
  85196. getClassName(): string;
  85197. /** @hidden */
  85198. readonly _isNode: boolean;
  85199. /**
  85200. * An event triggered when the mesh is disposed
  85201. */
  85202. onDisposeObservable: Observable<Node>;
  85203. private _onDisposeObserver;
  85204. /**
  85205. * Sets a callback that will be raised when the node will be disposed
  85206. */
  85207. onDispose: () => void;
  85208. /**
  85209. * Creates a new Node
  85210. * @param name the name and id to be given to this node
  85211. * @param scene the scene this node will be added to
  85212. * @param addToRootNodes the node will be added to scene.rootNodes
  85213. */
  85214. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85215. /**
  85216. * Gets the scene of the node
  85217. * @returns a scene
  85218. */
  85219. getScene(): Scene;
  85220. /**
  85221. * Gets the engine of the node
  85222. * @returns a Engine
  85223. */
  85224. getEngine(): Engine;
  85225. private _behaviors;
  85226. /**
  85227. * Attach a behavior to the node
  85228. * @see http://doc.babylonjs.com/features/behaviour
  85229. * @param behavior defines the behavior to attach
  85230. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85231. * @returns the current Node
  85232. */
  85233. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85234. /**
  85235. * Remove an attached behavior
  85236. * @see http://doc.babylonjs.com/features/behaviour
  85237. * @param behavior defines the behavior to attach
  85238. * @returns the current Node
  85239. */
  85240. removeBehavior(behavior: Behavior<Node>): Node;
  85241. /**
  85242. * Gets the list of attached behaviors
  85243. * @see http://doc.babylonjs.com/features/behaviour
  85244. */
  85245. readonly behaviors: Behavior<Node>[];
  85246. /**
  85247. * Gets an attached behavior by name
  85248. * @param name defines the name of the behavior to look for
  85249. * @see http://doc.babylonjs.com/features/behaviour
  85250. * @returns null if behavior was not found else the requested behavior
  85251. */
  85252. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85253. /**
  85254. * Returns the latest update of the World matrix
  85255. * @returns a Matrix
  85256. */
  85257. getWorldMatrix(): Matrix;
  85258. /** @hidden */
  85259. _getWorldMatrixDeterminant(): number;
  85260. /**
  85261. * Returns directly the latest state of the mesh World matrix.
  85262. * A Matrix is returned.
  85263. */
  85264. readonly worldMatrixFromCache: Matrix;
  85265. /** @hidden */
  85266. _initCache(): void;
  85267. /** @hidden */
  85268. updateCache(force?: boolean): void;
  85269. /** @hidden */
  85270. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85271. /** @hidden */
  85272. _updateCache(ignoreParentClass?: boolean): void;
  85273. /** @hidden */
  85274. _isSynchronized(): boolean;
  85275. /** @hidden */
  85276. _markSyncedWithParent(): void;
  85277. /** @hidden */
  85278. isSynchronizedWithParent(): boolean;
  85279. /** @hidden */
  85280. isSynchronized(): boolean;
  85281. /**
  85282. * Is this node ready to be used/rendered
  85283. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85284. * @return true if the node is ready
  85285. */
  85286. isReady(completeCheck?: boolean): boolean;
  85287. /**
  85288. * Is this node enabled?
  85289. * 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
  85290. * @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
  85291. * @return whether this node (and its parent) is enabled
  85292. */
  85293. isEnabled(checkAncestors?: boolean): boolean;
  85294. /** @hidden */
  85295. protected _syncParentEnabledState(): void;
  85296. /**
  85297. * Set the enabled state of this node
  85298. * @param value defines the new enabled state
  85299. */
  85300. setEnabled(value: boolean): void;
  85301. /**
  85302. * Is this node a descendant of the given node?
  85303. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85304. * @param ancestor defines the parent node to inspect
  85305. * @returns a boolean indicating if this node is a descendant of the given node
  85306. */
  85307. isDescendantOf(ancestor: Node): boolean;
  85308. /** @hidden */
  85309. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85310. /**
  85311. * Will return all nodes that have this node as ascendant
  85312. * @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
  85313. * @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
  85314. * @return all children nodes of all types
  85315. */
  85316. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85317. /**
  85318. * Get all child-meshes of this node
  85319. * @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)
  85320. * @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
  85321. * @returns an array of AbstractMesh
  85322. */
  85323. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85324. /**
  85325. * Get all direct children of this node
  85326. * @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
  85327. * @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)
  85328. * @returns an array of Node
  85329. */
  85330. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85331. /** @hidden */
  85332. _setReady(state: boolean): void;
  85333. /**
  85334. * Get an animation by name
  85335. * @param name defines the name of the animation to look for
  85336. * @returns null if not found else the requested animation
  85337. */
  85338. getAnimationByName(name: string): Nullable<Animation>;
  85339. /**
  85340. * Creates an animation range for this node
  85341. * @param name defines the name of the range
  85342. * @param from defines the starting key
  85343. * @param to defines the end key
  85344. */
  85345. createAnimationRange(name: string, from: number, to: number): void;
  85346. /**
  85347. * Delete a specific animation range
  85348. * @param name defines the name of the range to delete
  85349. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85350. */
  85351. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85352. /**
  85353. * Get an animation range by name
  85354. * @param name defines the name of the animation range to look for
  85355. * @returns null if not found else the requested animation range
  85356. */
  85357. getAnimationRange(name: string): Nullable<AnimationRange>;
  85358. /**
  85359. * Gets the list of all animation ranges defined on this node
  85360. * @returns an array
  85361. */
  85362. getAnimationRanges(): Nullable<AnimationRange>[];
  85363. /**
  85364. * Will start the animation sequence
  85365. * @param name defines the range frames for animation sequence
  85366. * @param loop defines if the animation should loop (false by default)
  85367. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85368. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85369. * @returns the object created for this animation. If range does not exist, it will return null
  85370. */
  85371. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85372. /**
  85373. * Serialize animation ranges into a JSON compatible object
  85374. * @returns serialization object
  85375. */
  85376. serializeAnimationRanges(): any;
  85377. /**
  85378. * Computes the world matrix of the node
  85379. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85380. * @returns the world matrix
  85381. */
  85382. computeWorldMatrix(force?: boolean): Matrix;
  85383. /**
  85384. * Releases resources associated with this node.
  85385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85387. */
  85388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85389. /**
  85390. * Parse animation range data from a serialization object and store them into a given node
  85391. * @param node defines where to store the animation ranges
  85392. * @param parsedNode defines the serialization object to read data from
  85393. * @param scene defines the hosting scene
  85394. */
  85395. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85396. /**
  85397. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85398. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85399. * @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
  85400. * @returns the new bounding vectors
  85401. */
  85402. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85403. min: Vector3;
  85404. max: Vector3;
  85405. };
  85406. }
  85407. }
  85408. declare module BABYLON {
  85409. /**
  85410. * @hidden
  85411. */
  85412. export class _IAnimationState {
  85413. key: number;
  85414. repeatCount: number;
  85415. workValue?: any;
  85416. loopMode?: number;
  85417. offsetValue?: any;
  85418. highLimitValue?: any;
  85419. }
  85420. /**
  85421. * Class used to store any kind of animation
  85422. */
  85423. export class Animation {
  85424. /**Name of the animation */
  85425. name: string;
  85426. /**Property to animate */
  85427. targetProperty: string;
  85428. /**The frames per second of the animation */
  85429. framePerSecond: number;
  85430. /**The data type of the animation */
  85431. dataType: number;
  85432. /**The loop mode of the animation */
  85433. loopMode?: number | undefined;
  85434. /**Specifies if blending should be enabled */
  85435. enableBlending?: boolean | undefined;
  85436. /**
  85437. * Use matrix interpolation instead of using direct key value when animating matrices
  85438. */
  85439. static AllowMatricesInterpolation: boolean;
  85440. /**
  85441. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85442. */
  85443. static AllowMatrixDecomposeForInterpolation: boolean;
  85444. /**
  85445. * Stores the key frames of the animation
  85446. */
  85447. private _keys;
  85448. /**
  85449. * Stores the easing function of the animation
  85450. */
  85451. private _easingFunction;
  85452. /**
  85453. * @hidden Internal use only
  85454. */
  85455. _runtimeAnimations: RuntimeAnimation[];
  85456. /**
  85457. * The set of event that will be linked to this animation
  85458. */
  85459. private _events;
  85460. /**
  85461. * Stores an array of target property paths
  85462. */
  85463. targetPropertyPath: string[];
  85464. /**
  85465. * Stores the blending speed of the animation
  85466. */
  85467. blendingSpeed: number;
  85468. /**
  85469. * Stores the animation ranges for the animation
  85470. */
  85471. private _ranges;
  85472. /**
  85473. * @hidden Internal use
  85474. */
  85475. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85476. /**
  85477. * Sets up an animation
  85478. * @param property The property to animate
  85479. * @param animationType The animation type to apply
  85480. * @param framePerSecond The frames per second of the animation
  85481. * @param easingFunction The easing function used in the animation
  85482. * @returns The created animation
  85483. */
  85484. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85485. /**
  85486. * Create and start an animation on a node
  85487. * @param name defines the name of the global animation that will be run on all nodes
  85488. * @param node defines the root node where the animation will take place
  85489. * @param targetProperty defines property to animate
  85490. * @param framePerSecond defines the number of frame per second yo use
  85491. * @param totalFrame defines the number of frames in total
  85492. * @param from defines the initial value
  85493. * @param to defines the final value
  85494. * @param loopMode defines which loop mode you want to use (off by default)
  85495. * @param easingFunction defines the easing function to use (linear by default)
  85496. * @param onAnimationEnd defines the callback to call when animation end
  85497. * @returns the animatable created for this animation
  85498. */
  85499. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85500. /**
  85501. * Create and start an animation on a node and its descendants
  85502. * @param name defines the name of the global animation that will be run on all nodes
  85503. * @param node defines the root node where the animation will take place
  85504. * @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
  85505. * @param targetProperty defines property to animate
  85506. * @param framePerSecond defines the number of frame per second to use
  85507. * @param totalFrame defines the number of frames in total
  85508. * @param from defines the initial value
  85509. * @param to defines the final value
  85510. * @param loopMode defines which loop mode you want to use (off by default)
  85511. * @param easingFunction defines the easing function to use (linear by default)
  85512. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85513. * @returns the list of animatables created for all nodes
  85514. * @example https://www.babylonjs-playground.com/#MH0VLI
  85515. */
  85516. 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[]>;
  85517. /**
  85518. * Creates a new animation, merges it with the existing animations and starts it
  85519. * @param name Name of the animation
  85520. * @param node Node which contains the scene that begins the animations
  85521. * @param targetProperty Specifies which property to animate
  85522. * @param framePerSecond The frames per second of the animation
  85523. * @param totalFrame The total number of frames
  85524. * @param from The frame at the beginning of the animation
  85525. * @param to The frame at the end of the animation
  85526. * @param loopMode Specifies the loop mode of the animation
  85527. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85528. * @param onAnimationEnd Callback to run once the animation is complete
  85529. * @returns Nullable animation
  85530. */
  85531. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85532. /**
  85533. * Transition property of an host to the target Value
  85534. * @param property The property to transition
  85535. * @param targetValue The target Value of the property
  85536. * @param host The object where the property to animate belongs
  85537. * @param scene Scene used to run the animation
  85538. * @param frameRate Framerate (in frame/s) to use
  85539. * @param transition The transition type we want to use
  85540. * @param duration The duration of the animation, in milliseconds
  85541. * @param onAnimationEnd Callback trigger at the end of the animation
  85542. * @returns Nullable animation
  85543. */
  85544. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85545. /**
  85546. * Return the array of runtime animations currently using this animation
  85547. */
  85548. readonly runtimeAnimations: RuntimeAnimation[];
  85549. /**
  85550. * Specifies if any of the runtime animations are currently running
  85551. */
  85552. readonly hasRunningRuntimeAnimations: boolean;
  85553. /**
  85554. * Initializes the animation
  85555. * @param name Name of the animation
  85556. * @param targetProperty Property to animate
  85557. * @param framePerSecond The frames per second of the animation
  85558. * @param dataType The data type of the animation
  85559. * @param loopMode The loop mode of the animation
  85560. * @param enableBlending Specifies if blending should be enabled
  85561. */
  85562. constructor(
  85563. /**Name of the animation */
  85564. name: string,
  85565. /**Property to animate */
  85566. targetProperty: string,
  85567. /**The frames per second of the animation */
  85568. framePerSecond: number,
  85569. /**The data type of the animation */
  85570. dataType: number,
  85571. /**The loop mode of the animation */
  85572. loopMode?: number | undefined,
  85573. /**Specifies if blending should be enabled */
  85574. enableBlending?: boolean | undefined);
  85575. /**
  85576. * Converts the animation to a string
  85577. * @param fullDetails support for multiple levels of logging within scene loading
  85578. * @returns String form of the animation
  85579. */
  85580. toString(fullDetails?: boolean): string;
  85581. /**
  85582. * Add an event to this animation
  85583. * @param event Event to add
  85584. */
  85585. addEvent(event: AnimationEvent): void;
  85586. /**
  85587. * Remove all events found at the given frame
  85588. * @param frame The frame to remove events from
  85589. */
  85590. removeEvents(frame: number): void;
  85591. /**
  85592. * Retrieves all the events from the animation
  85593. * @returns Events from the animation
  85594. */
  85595. getEvents(): AnimationEvent[];
  85596. /**
  85597. * Creates an animation range
  85598. * @param name Name of the animation range
  85599. * @param from Starting frame of the animation range
  85600. * @param to Ending frame of the animation
  85601. */
  85602. createRange(name: string, from: number, to: number): void;
  85603. /**
  85604. * Deletes an animation range by name
  85605. * @param name Name of the animation range to delete
  85606. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85607. */
  85608. deleteRange(name: string, deleteFrames?: boolean): void;
  85609. /**
  85610. * Gets the animation range by name, or null if not defined
  85611. * @param name Name of the animation range
  85612. * @returns Nullable animation range
  85613. */
  85614. getRange(name: string): Nullable<AnimationRange>;
  85615. /**
  85616. * Gets the key frames from the animation
  85617. * @returns The key frames of the animation
  85618. */
  85619. getKeys(): Array<IAnimationKey>;
  85620. /**
  85621. * Gets the highest frame rate of the animation
  85622. * @returns Highest frame rate of the animation
  85623. */
  85624. getHighestFrame(): number;
  85625. /**
  85626. * Gets the easing function of the animation
  85627. * @returns Easing function of the animation
  85628. */
  85629. getEasingFunction(): IEasingFunction;
  85630. /**
  85631. * Sets the easing function of the animation
  85632. * @param easingFunction A custom mathematical formula for animation
  85633. */
  85634. setEasingFunction(easingFunction: EasingFunction): void;
  85635. /**
  85636. * Interpolates a scalar linearly
  85637. * @param startValue Start value of the animation curve
  85638. * @param endValue End value of the animation curve
  85639. * @param gradient Scalar amount to interpolate
  85640. * @returns Interpolated scalar value
  85641. */
  85642. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85643. /**
  85644. * Interpolates a scalar cubically
  85645. * @param startValue Start value of the animation curve
  85646. * @param outTangent End tangent of the animation
  85647. * @param endValue End value of the animation curve
  85648. * @param inTangent Start tangent of the animation curve
  85649. * @param gradient Scalar amount to interpolate
  85650. * @returns Interpolated scalar value
  85651. */
  85652. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85653. /**
  85654. * Interpolates a quaternion using a spherical linear interpolation
  85655. * @param startValue Start value of the animation curve
  85656. * @param endValue End value of the animation curve
  85657. * @param gradient Scalar amount to interpolate
  85658. * @returns Interpolated quaternion value
  85659. */
  85660. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85661. /**
  85662. * Interpolates a quaternion cubically
  85663. * @param startValue Start value of the animation curve
  85664. * @param outTangent End tangent of the animation curve
  85665. * @param endValue End value of the animation curve
  85666. * @param inTangent Start tangent of the animation curve
  85667. * @param gradient Scalar amount to interpolate
  85668. * @returns Interpolated quaternion value
  85669. */
  85670. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85671. /**
  85672. * Interpolates a Vector3 linearl
  85673. * @param startValue Start value of the animation curve
  85674. * @param endValue End value of the animation curve
  85675. * @param gradient Scalar amount to interpolate
  85676. * @returns Interpolated scalar value
  85677. */
  85678. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85679. /**
  85680. * Interpolates a Vector3 cubically
  85681. * @param startValue Start value of the animation curve
  85682. * @param outTangent End tangent of the animation
  85683. * @param endValue End value of the animation curve
  85684. * @param inTangent Start tangent of the animation curve
  85685. * @param gradient Scalar amount to interpolate
  85686. * @returns InterpolatedVector3 value
  85687. */
  85688. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85689. /**
  85690. * Interpolates a Vector2 linearly
  85691. * @param startValue Start value of the animation curve
  85692. * @param endValue End value of the animation curve
  85693. * @param gradient Scalar amount to interpolate
  85694. * @returns Interpolated Vector2 value
  85695. */
  85696. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85697. /**
  85698. * Interpolates a Vector2 cubically
  85699. * @param startValue Start value of the animation curve
  85700. * @param outTangent End tangent of the animation
  85701. * @param endValue End value of the animation curve
  85702. * @param inTangent Start tangent of the animation curve
  85703. * @param gradient Scalar amount to interpolate
  85704. * @returns Interpolated Vector2 value
  85705. */
  85706. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85707. /**
  85708. * Interpolates a size linearly
  85709. * @param startValue Start value of the animation curve
  85710. * @param endValue End value of the animation curve
  85711. * @param gradient Scalar amount to interpolate
  85712. * @returns Interpolated Size value
  85713. */
  85714. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85715. /**
  85716. * Interpolates a Color3 linearly
  85717. * @param startValue Start value of the animation curve
  85718. * @param endValue End value of the animation curve
  85719. * @param gradient Scalar amount to interpolate
  85720. * @returns Interpolated Color3 value
  85721. */
  85722. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85723. /**
  85724. * @hidden Internal use only
  85725. */
  85726. _getKeyValue(value: any): any;
  85727. /**
  85728. * @hidden Internal use only
  85729. */
  85730. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85731. /**
  85732. * Defines the function to use to interpolate matrices
  85733. * @param startValue defines the start matrix
  85734. * @param endValue defines the end matrix
  85735. * @param gradient defines the gradient between both matrices
  85736. * @param result defines an optional target matrix where to store the interpolation
  85737. * @returns the interpolated matrix
  85738. */
  85739. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85740. /**
  85741. * Makes a copy of the animation
  85742. * @returns Cloned animation
  85743. */
  85744. clone(): Animation;
  85745. /**
  85746. * Sets the key frames of the animation
  85747. * @param values The animation key frames to set
  85748. */
  85749. setKeys(values: Array<IAnimationKey>): void;
  85750. /**
  85751. * Serializes the animation to an object
  85752. * @returns Serialized object
  85753. */
  85754. serialize(): any;
  85755. /**
  85756. * Float animation type
  85757. */
  85758. private static _ANIMATIONTYPE_FLOAT;
  85759. /**
  85760. * Vector3 animation type
  85761. */
  85762. private static _ANIMATIONTYPE_VECTOR3;
  85763. /**
  85764. * Quaternion animation type
  85765. */
  85766. private static _ANIMATIONTYPE_QUATERNION;
  85767. /**
  85768. * Matrix animation type
  85769. */
  85770. private static _ANIMATIONTYPE_MATRIX;
  85771. /**
  85772. * Color3 animation type
  85773. */
  85774. private static _ANIMATIONTYPE_COLOR3;
  85775. /**
  85776. * Vector2 animation type
  85777. */
  85778. private static _ANIMATIONTYPE_VECTOR2;
  85779. /**
  85780. * Size animation type
  85781. */
  85782. private static _ANIMATIONTYPE_SIZE;
  85783. /**
  85784. * Relative Loop Mode
  85785. */
  85786. private static _ANIMATIONLOOPMODE_RELATIVE;
  85787. /**
  85788. * Cycle Loop Mode
  85789. */
  85790. private static _ANIMATIONLOOPMODE_CYCLE;
  85791. /**
  85792. * Constant Loop Mode
  85793. */
  85794. private static _ANIMATIONLOOPMODE_CONSTANT;
  85795. /**
  85796. * Get the float animation type
  85797. */
  85798. static readonly ANIMATIONTYPE_FLOAT: number;
  85799. /**
  85800. * Get the Vector3 animation type
  85801. */
  85802. static readonly ANIMATIONTYPE_VECTOR3: number;
  85803. /**
  85804. * Get the Vector2 animation type
  85805. */
  85806. static readonly ANIMATIONTYPE_VECTOR2: number;
  85807. /**
  85808. * Get the Size animation type
  85809. */
  85810. static readonly ANIMATIONTYPE_SIZE: number;
  85811. /**
  85812. * Get the Quaternion animation type
  85813. */
  85814. static readonly ANIMATIONTYPE_QUATERNION: number;
  85815. /**
  85816. * Get the Matrix animation type
  85817. */
  85818. static readonly ANIMATIONTYPE_MATRIX: number;
  85819. /**
  85820. * Get the Color3 animation type
  85821. */
  85822. static readonly ANIMATIONTYPE_COLOR3: number;
  85823. /**
  85824. * Get the Relative Loop Mode
  85825. */
  85826. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85827. /**
  85828. * Get the Cycle Loop Mode
  85829. */
  85830. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85831. /**
  85832. * Get the Constant Loop Mode
  85833. */
  85834. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85835. /** @hidden */
  85836. static _UniversalLerp(left: any, right: any, amount: number): any;
  85837. /**
  85838. * Parses an animation object and creates an animation
  85839. * @param parsedAnimation Parsed animation object
  85840. * @returns Animation object
  85841. */
  85842. static Parse(parsedAnimation: any): Animation;
  85843. /**
  85844. * Appends the serialized animations from the source animations
  85845. * @param source Source containing the animations
  85846. * @param destination Target to store the animations
  85847. */
  85848. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85849. }
  85850. }
  85851. declare module BABYLON {
  85852. /**
  85853. * Base class of all the textures in babylon.
  85854. * It groups all the common properties the materials, post process, lights... might need
  85855. * in order to make a correct use of the texture.
  85856. */
  85857. export class BaseTexture implements IAnimatable {
  85858. /**
  85859. * Default anisotropic filtering level for the application.
  85860. * It is set to 4 as a good tradeoff between perf and quality.
  85861. */
  85862. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85863. /**
  85864. * Gets or sets the unique id of the texture
  85865. */
  85866. uniqueId: number;
  85867. /**
  85868. * Define the name of the texture.
  85869. */
  85870. name: string;
  85871. /**
  85872. * Gets or sets an object used to store user defined information.
  85873. */
  85874. metadata: any;
  85875. /**
  85876. * For internal use only. Please do not use.
  85877. */
  85878. reservedDataStore: any;
  85879. private _hasAlpha;
  85880. /**
  85881. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85882. */
  85883. hasAlpha: boolean;
  85884. /**
  85885. * Defines if the alpha value should be determined via the rgb values.
  85886. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85887. */
  85888. getAlphaFromRGB: boolean;
  85889. /**
  85890. * Intensity or strength of the texture.
  85891. * It is commonly used by materials to fine tune the intensity of the texture
  85892. */
  85893. level: number;
  85894. /**
  85895. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85896. * This is part of the texture as textures usually maps to one uv set.
  85897. */
  85898. coordinatesIndex: number;
  85899. private _coordinatesMode;
  85900. /**
  85901. * How a texture is mapped.
  85902. *
  85903. * | Value | Type | Description |
  85904. * | ----- | ----------------------------------- | ----------- |
  85905. * | 0 | EXPLICIT_MODE | |
  85906. * | 1 | SPHERICAL_MODE | |
  85907. * | 2 | PLANAR_MODE | |
  85908. * | 3 | CUBIC_MODE | |
  85909. * | 4 | PROJECTION_MODE | |
  85910. * | 5 | SKYBOX_MODE | |
  85911. * | 6 | INVCUBIC_MODE | |
  85912. * | 7 | EQUIRECTANGULAR_MODE | |
  85913. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85914. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85915. */
  85916. coordinatesMode: number;
  85917. /**
  85918. * | Value | Type | Description |
  85919. * | ----- | ------------------ | ----------- |
  85920. * | 0 | CLAMP_ADDRESSMODE | |
  85921. * | 1 | WRAP_ADDRESSMODE | |
  85922. * | 2 | MIRROR_ADDRESSMODE | |
  85923. */
  85924. wrapU: number;
  85925. /**
  85926. * | Value | Type | Description |
  85927. * | ----- | ------------------ | ----------- |
  85928. * | 0 | CLAMP_ADDRESSMODE | |
  85929. * | 1 | WRAP_ADDRESSMODE | |
  85930. * | 2 | MIRROR_ADDRESSMODE | |
  85931. */
  85932. wrapV: number;
  85933. /**
  85934. * | Value | Type | Description |
  85935. * | ----- | ------------------ | ----------- |
  85936. * | 0 | CLAMP_ADDRESSMODE | |
  85937. * | 1 | WRAP_ADDRESSMODE | |
  85938. * | 2 | MIRROR_ADDRESSMODE | |
  85939. */
  85940. wrapR: number;
  85941. /**
  85942. * With compliant hardware and browser (supporting anisotropic filtering)
  85943. * this defines the level of anisotropic filtering in the texture.
  85944. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85945. */
  85946. anisotropicFilteringLevel: number;
  85947. /**
  85948. * Define if the texture is a cube texture or if false a 2d texture.
  85949. */
  85950. isCube: boolean;
  85951. /**
  85952. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85953. */
  85954. is3D: boolean;
  85955. /**
  85956. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85957. * HDR texture are usually stored in linear space.
  85958. * This only impacts the PBR and Background materials
  85959. */
  85960. gammaSpace: boolean;
  85961. /**
  85962. * Gets whether or not the texture contains RGBD data.
  85963. */
  85964. readonly isRGBD: boolean;
  85965. /**
  85966. * Is Z inverted in the texture (useful in a cube texture).
  85967. */
  85968. invertZ: boolean;
  85969. /**
  85970. * Are mip maps generated for this texture or not.
  85971. */
  85972. readonly noMipmap: boolean;
  85973. /**
  85974. * @hidden
  85975. */
  85976. lodLevelInAlpha: boolean;
  85977. /**
  85978. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85979. */
  85980. lodGenerationOffset: number;
  85981. /**
  85982. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85983. */
  85984. lodGenerationScale: number;
  85985. /**
  85986. * Define if the texture is a render target.
  85987. */
  85988. isRenderTarget: boolean;
  85989. /**
  85990. * Define the unique id of the texture in the scene.
  85991. */
  85992. readonly uid: string;
  85993. /**
  85994. * Return a string representation of the texture.
  85995. * @returns the texture as a string
  85996. */
  85997. toString(): string;
  85998. /**
  85999. * Get the class name of the texture.
  86000. * @returns "BaseTexture"
  86001. */
  86002. getClassName(): string;
  86003. /**
  86004. * Define the list of animation attached to the texture.
  86005. */
  86006. animations: Animation[];
  86007. /**
  86008. * An event triggered when the texture is disposed.
  86009. */
  86010. onDisposeObservable: Observable<BaseTexture>;
  86011. private _onDisposeObserver;
  86012. /**
  86013. * Callback triggered when the texture has been disposed.
  86014. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86015. */
  86016. onDispose: () => void;
  86017. /**
  86018. * Define the current state of the loading sequence when in delayed load mode.
  86019. */
  86020. delayLoadState: number;
  86021. private _scene;
  86022. /** @hidden */
  86023. _texture: Nullable<InternalTexture>;
  86024. private _uid;
  86025. /**
  86026. * Define if the texture is preventinga material to render or not.
  86027. * If not and the texture is not ready, the engine will use a default black texture instead.
  86028. */
  86029. readonly isBlocking: boolean;
  86030. /**
  86031. * Instantiates a new BaseTexture.
  86032. * Base class of all the textures in babylon.
  86033. * It groups all the common properties the materials, post process, lights... might need
  86034. * in order to make a correct use of the texture.
  86035. * @param scene Define the scene the texture blongs to
  86036. */
  86037. constructor(scene: Nullable<Scene>);
  86038. /**
  86039. * Get the scene the texture belongs to.
  86040. * @returns the scene or null if undefined
  86041. */
  86042. getScene(): Nullable<Scene>;
  86043. /**
  86044. * Get the texture transform matrix used to offset tile the texture for istance.
  86045. * @returns the transformation matrix
  86046. */
  86047. getTextureMatrix(): Matrix;
  86048. /**
  86049. * Get the texture reflection matrix used to rotate/transform the reflection.
  86050. * @returns the reflection matrix
  86051. */
  86052. getReflectionTextureMatrix(): Matrix;
  86053. /**
  86054. * Get the underlying lower level texture from Babylon.
  86055. * @returns the insternal texture
  86056. */
  86057. getInternalTexture(): Nullable<InternalTexture>;
  86058. /**
  86059. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86060. * @returns true if ready or not blocking
  86061. */
  86062. isReadyOrNotBlocking(): boolean;
  86063. /**
  86064. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86065. * @returns true if fully ready
  86066. */
  86067. isReady(): boolean;
  86068. private _cachedSize;
  86069. /**
  86070. * Get the size of the texture.
  86071. * @returns the texture size.
  86072. */
  86073. getSize(): ISize;
  86074. /**
  86075. * Get the base size of the texture.
  86076. * It can be different from the size if the texture has been resized for POT for instance
  86077. * @returns the base size
  86078. */
  86079. getBaseSize(): ISize;
  86080. /**
  86081. * Update the sampling mode of the texture.
  86082. * Default is Trilinear mode.
  86083. *
  86084. * | Value | Type | Description |
  86085. * | ----- | ------------------ | ----------- |
  86086. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86087. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86088. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86089. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86090. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86091. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86092. * | 7 | NEAREST_LINEAR | |
  86093. * | 8 | NEAREST_NEAREST | |
  86094. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86095. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86096. * | 11 | LINEAR_LINEAR | |
  86097. * | 12 | LINEAR_NEAREST | |
  86098. *
  86099. * > _mag_: magnification filter (close to the viewer)
  86100. * > _min_: minification filter (far from the viewer)
  86101. * > _mip_: filter used between mip map levels
  86102. *@param samplingMode Define the new sampling mode of the texture
  86103. */
  86104. updateSamplingMode(samplingMode: number): void;
  86105. /**
  86106. * Scales the texture if is `canRescale()`
  86107. * @param ratio the resize factor we want to use to rescale
  86108. */
  86109. scale(ratio: number): void;
  86110. /**
  86111. * Get if the texture can rescale.
  86112. */
  86113. readonly canRescale: boolean;
  86114. /** @hidden */
  86115. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86116. /** @hidden */
  86117. _rebuild(): void;
  86118. /**
  86119. * Triggers the load sequence in delayed load mode.
  86120. */
  86121. delayLoad(): void;
  86122. /**
  86123. * Clones the texture.
  86124. * @returns the cloned texture
  86125. */
  86126. clone(): Nullable<BaseTexture>;
  86127. /**
  86128. * Get the texture underlying type (INT, FLOAT...)
  86129. */
  86130. readonly textureType: number;
  86131. /**
  86132. * Get the texture underlying format (RGB, RGBA...)
  86133. */
  86134. readonly textureFormat: number;
  86135. /**
  86136. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86137. * This will returns an RGBA array buffer containing either in values (0-255) or
  86138. * float values (0-1) depending of the underlying buffer type.
  86139. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86140. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86141. * @param buffer defines a user defined buffer to fill with data (can be null)
  86142. * @returns The Array buffer containing the pixels data.
  86143. */
  86144. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86145. /**
  86146. * Release and destroy the underlying lower level texture aka internalTexture.
  86147. */
  86148. releaseInternalTexture(): void;
  86149. /**
  86150. * Get the polynomial representation of the texture data.
  86151. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86152. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86153. */
  86154. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86155. /** @hidden */
  86156. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86157. /** @hidden */
  86158. readonly _lodTextureMid: Nullable<BaseTexture>;
  86159. /** @hidden */
  86160. readonly _lodTextureLow: Nullable<BaseTexture>;
  86161. /**
  86162. * Dispose the texture and release its associated resources.
  86163. */
  86164. dispose(): void;
  86165. /**
  86166. * Serialize the texture into a JSON representation that can be parsed later on.
  86167. * @returns the JSON representation of the texture
  86168. */
  86169. serialize(): any;
  86170. /**
  86171. * Helper function to be called back once a list of texture contains only ready textures.
  86172. * @param textures Define the list of textures to wait for
  86173. * @param callback Define the callback triggered once the entire list will be ready
  86174. */
  86175. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86176. }
  86177. }
  86178. declare module BABYLON {
  86179. /**
  86180. * Uniform buffer objects.
  86181. *
  86182. * Handles blocks of uniform on the GPU.
  86183. *
  86184. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86185. *
  86186. * For more information, please refer to :
  86187. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86188. */
  86189. export class UniformBuffer {
  86190. private _engine;
  86191. private _buffer;
  86192. private _data;
  86193. private _bufferData;
  86194. private _dynamic?;
  86195. private _uniformLocations;
  86196. private _uniformSizes;
  86197. private _uniformLocationPointer;
  86198. private _needSync;
  86199. private _noUBO;
  86200. private _currentEffect;
  86201. private static _MAX_UNIFORM_SIZE;
  86202. private static _tempBuffer;
  86203. /**
  86204. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86205. * This is dynamic to allow compat with webgl 1 and 2.
  86206. * You will need to pass the name of the uniform as well as the value.
  86207. */
  86208. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86209. /**
  86210. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86211. * This is dynamic to allow compat with webgl 1 and 2.
  86212. * You will need to pass the name of the uniform as well as the value.
  86213. */
  86214. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86215. /**
  86216. * Lambda to Update a single float in a uniform buffer.
  86217. * This is dynamic to allow compat with webgl 1 and 2.
  86218. * You will need to pass the name of the uniform as well as the value.
  86219. */
  86220. updateFloat: (name: string, x: number) => void;
  86221. /**
  86222. * Lambda to Update a vec2 of float in a uniform buffer.
  86223. * This is dynamic to allow compat with webgl 1 and 2.
  86224. * You will need to pass the name of the uniform as well as the value.
  86225. */
  86226. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86227. /**
  86228. * Lambda to Update a vec3 of float in a uniform buffer.
  86229. * This is dynamic to allow compat with webgl 1 and 2.
  86230. * You will need to pass the name of the uniform as well as the value.
  86231. */
  86232. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86233. /**
  86234. * Lambda to Update a vec4 of float in a uniform buffer.
  86235. * This is dynamic to allow compat with webgl 1 and 2.
  86236. * You will need to pass the name of the uniform as well as the value.
  86237. */
  86238. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86239. /**
  86240. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86241. * This is dynamic to allow compat with webgl 1 and 2.
  86242. * You will need to pass the name of the uniform as well as the value.
  86243. */
  86244. updateMatrix: (name: string, mat: Matrix) => void;
  86245. /**
  86246. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86247. * This is dynamic to allow compat with webgl 1 and 2.
  86248. * You will need to pass the name of the uniform as well as the value.
  86249. */
  86250. updateVector3: (name: string, vector: Vector3) => void;
  86251. /**
  86252. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86253. * This is dynamic to allow compat with webgl 1 and 2.
  86254. * You will need to pass the name of the uniform as well as the value.
  86255. */
  86256. updateVector4: (name: string, vector: Vector4) => void;
  86257. /**
  86258. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86259. * This is dynamic to allow compat with webgl 1 and 2.
  86260. * You will need to pass the name of the uniform as well as the value.
  86261. */
  86262. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86263. /**
  86264. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86265. * This is dynamic to allow compat with webgl 1 and 2.
  86266. * You will need to pass the name of the uniform as well as the value.
  86267. */
  86268. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86269. /**
  86270. * Instantiates a new Uniform buffer objects.
  86271. *
  86272. * Handles blocks of uniform on the GPU.
  86273. *
  86274. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86275. *
  86276. * For more information, please refer to :
  86277. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86278. * @param engine Define the engine the buffer is associated with
  86279. * @param data Define the data contained in the buffer
  86280. * @param dynamic Define if the buffer is updatable
  86281. */
  86282. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86283. /**
  86284. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86285. * or just falling back on setUniformXXX calls.
  86286. */
  86287. readonly useUbo: boolean;
  86288. /**
  86289. * Indicates if the WebGL underlying uniform buffer is in sync
  86290. * with the javascript cache data.
  86291. */
  86292. readonly isSync: boolean;
  86293. /**
  86294. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86295. * Also, a dynamic UniformBuffer will disable cache verification and always
  86296. * update the underlying WebGL uniform buffer to the GPU.
  86297. * @returns if Dynamic, otherwise false
  86298. */
  86299. isDynamic(): boolean;
  86300. /**
  86301. * The data cache on JS side.
  86302. * @returns the underlying data as a float array
  86303. */
  86304. getData(): Float32Array;
  86305. /**
  86306. * The underlying WebGL Uniform buffer.
  86307. * @returns the webgl buffer
  86308. */
  86309. getBuffer(): Nullable<DataBuffer>;
  86310. /**
  86311. * std140 layout specifies how to align data within an UBO structure.
  86312. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86313. * for specs.
  86314. */
  86315. private _fillAlignment;
  86316. /**
  86317. * Adds an uniform in the buffer.
  86318. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86319. * for the layout to be correct !
  86320. * @param name Name of the uniform, as used in the uniform block in the shader.
  86321. * @param size Data size, or data directly.
  86322. */
  86323. addUniform(name: string, size: number | number[]): void;
  86324. /**
  86325. * Adds a Matrix 4x4 to the uniform buffer.
  86326. * @param name Name of the uniform, as used in the uniform block in the shader.
  86327. * @param mat A 4x4 matrix.
  86328. */
  86329. addMatrix(name: string, mat: Matrix): void;
  86330. /**
  86331. * Adds a vec2 to the uniform buffer.
  86332. * @param name Name of the uniform, as used in the uniform block in the shader.
  86333. * @param x Define the x component value of the vec2
  86334. * @param y Define the y component value of the vec2
  86335. */
  86336. addFloat2(name: string, x: number, y: number): void;
  86337. /**
  86338. * Adds a vec3 to the uniform buffer.
  86339. * @param name Name of the uniform, as used in the uniform block in the shader.
  86340. * @param x Define the x component value of the vec3
  86341. * @param y Define the y component value of the vec3
  86342. * @param z Define the z component value of the vec3
  86343. */
  86344. addFloat3(name: string, x: number, y: number, z: number): void;
  86345. /**
  86346. * Adds a vec3 to the uniform buffer.
  86347. * @param name Name of the uniform, as used in the uniform block in the shader.
  86348. * @param color Define the vec3 from a Color
  86349. */
  86350. addColor3(name: string, color: Color3): void;
  86351. /**
  86352. * Adds a vec4 to the uniform buffer.
  86353. * @param name Name of the uniform, as used in the uniform block in the shader.
  86354. * @param color Define the rgb components from a Color
  86355. * @param alpha Define the a component of the vec4
  86356. */
  86357. addColor4(name: string, color: Color3, alpha: number): void;
  86358. /**
  86359. * Adds a vec3 to the uniform buffer.
  86360. * @param name Name of the uniform, as used in the uniform block in the shader.
  86361. * @param vector Define the vec3 components from a Vector
  86362. */
  86363. addVector3(name: string, vector: Vector3): void;
  86364. /**
  86365. * Adds a Matrix 3x3 to the uniform buffer.
  86366. * @param name Name of the uniform, as used in the uniform block in the shader.
  86367. */
  86368. addMatrix3x3(name: string): void;
  86369. /**
  86370. * Adds a Matrix 2x2 to the uniform buffer.
  86371. * @param name Name of the uniform, as used in the uniform block in the shader.
  86372. */
  86373. addMatrix2x2(name: string): void;
  86374. /**
  86375. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86376. */
  86377. create(): void;
  86378. /** @hidden */
  86379. _rebuild(): void;
  86380. /**
  86381. * Updates the WebGL Uniform Buffer on the GPU.
  86382. * If the `dynamic` flag is set to true, no cache comparison is done.
  86383. * Otherwise, the buffer will be updated only if the cache differs.
  86384. */
  86385. update(): void;
  86386. /**
  86387. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86388. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86389. * @param data Define the flattened data
  86390. * @param size Define the size of the data.
  86391. */
  86392. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86393. private _updateMatrix3x3ForUniform;
  86394. private _updateMatrix3x3ForEffect;
  86395. private _updateMatrix2x2ForEffect;
  86396. private _updateMatrix2x2ForUniform;
  86397. private _updateFloatForEffect;
  86398. private _updateFloatForUniform;
  86399. private _updateFloat2ForEffect;
  86400. private _updateFloat2ForUniform;
  86401. private _updateFloat3ForEffect;
  86402. private _updateFloat3ForUniform;
  86403. private _updateFloat4ForEffect;
  86404. private _updateFloat4ForUniform;
  86405. private _updateMatrixForEffect;
  86406. private _updateMatrixForUniform;
  86407. private _updateVector3ForEffect;
  86408. private _updateVector3ForUniform;
  86409. private _updateVector4ForEffect;
  86410. private _updateVector4ForUniform;
  86411. private _updateColor3ForEffect;
  86412. private _updateColor3ForUniform;
  86413. private _updateColor4ForEffect;
  86414. private _updateColor4ForUniform;
  86415. /**
  86416. * Sets a sampler uniform on the effect.
  86417. * @param name Define the name of the sampler.
  86418. * @param texture Define the texture to set in the sampler
  86419. */
  86420. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86421. /**
  86422. * Directly updates the value of the uniform in the cache AND on the GPU.
  86423. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86424. * @param data Define the flattened data
  86425. */
  86426. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86427. /**
  86428. * Binds this uniform buffer to an effect.
  86429. * @param effect Define the effect to bind the buffer to
  86430. * @param name Name of the uniform block in the shader.
  86431. */
  86432. bindToEffect(effect: Effect, name: string): void;
  86433. /**
  86434. * Disposes the uniform buffer.
  86435. */
  86436. dispose(): void;
  86437. }
  86438. }
  86439. declare module BABYLON {
  86440. /**
  86441. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86443. */
  86444. export class Analyser {
  86445. /**
  86446. * Gets or sets the smoothing
  86447. * @ignorenaming
  86448. */
  86449. SMOOTHING: number;
  86450. /**
  86451. * Gets or sets the FFT table size
  86452. * @ignorenaming
  86453. */
  86454. FFT_SIZE: number;
  86455. /**
  86456. * Gets or sets the bar graph amplitude
  86457. * @ignorenaming
  86458. */
  86459. BARGRAPHAMPLITUDE: number;
  86460. /**
  86461. * Gets or sets the position of the debug canvas
  86462. * @ignorenaming
  86463. */
  86464. DEBUGCANVASPOS: {
  86465. x: number;
  86466. y: number;
  86467. };
  86468. /**
  86469. * Gets or sets the debug canvas size
  86470. * @ignorenaming
  86471. */
  86472. DEBUGCANVASSIZE: {
  86473. width: number;
  86474. height: number;
  86475. };
  86476. private _byteFreqs;
  86477. private _byteTime;
  86478. private _floatFreqs;
  86479. private _webAudioAnalyser;
  86480. private _debugCanvas;
  86481. private _debugCanvasContext;
  86482. private _scene;
  86483. private _registerFunc;
  86484. private _audioEngine;
  86485. /**
  86486. * Creates a new analyser
  86487. * @param scene defines hosting scene
  86488. */
  86489. constructor(scene: Scene);
  86490. /**
  86491. * Get the number of data values you will have to play with for the visualization
  86492. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86493. * @returns a number
  86494. */
  86495. getFrequencyBinCount(): number;
  86496. /**
  86497. * Gets the current frequency data as a byte array
  86498. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86499. * @returns a Uint8Array
  86500. */
  86501. getByteFrequencyData(): Uint8Array;
  86502. /**
  86503. * Gets the current waveform as a byte array
  86504. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86505. * @returns a Uint8Array
  86506. */
  86507. getByteTimeDomainData(): Uint8Array;
  86508. /**
  86509. * Gets the current frequency data as a float array
  86510. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86511. * @returns a Float32Array
  86512. */
  86513. getFloatFrequencyData(): Float32Array;
  86514. /**
  86515. * Renders the debug canvas
  86516. */
  86517. drawDebugCanvas(): void;
  86518. /**
  86519. * Stops rendering the debug canvas and removes it
  86520. */
  86521. stopDebugCanvas(): void;
  86522. /**
  86523. * Connects two audio nodes
  86524. * @param inputAudioNode defines first node to connect
  86525. * @param outputAudioNode defines second node to connect
  86526. */
  86527. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86528. /**
  86529. * Releases all associated resources
  86530. */
  86531. dispose(): void;
  86532. }
  86533. }
  86534. declare module BABYLON {
  86535. /**
  86536. * This represents an audio engine and it is responsible
  86537. * to play, synchronize and analyse sounds throughout the application.
  86538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86539. */
  86540. export interface IAudioEngine extends IDisposable {
  86541. /**
  86542. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86543. */
  86544. readonly canUseWebAudio: boolean;
  86545. /**
  86546. * Gets the current AudioContext if available.
  86547. */
  86548. readonly audioContext: Nullable<AudioContext>;
  86549. /**
  86550. * The master gain node defines the global audio volume of your audio engine.
  86551. */
  86552. readonly masterGain: GainNode;
  86553. /**
  86554. * Gets whether or not mp3 are supported by your browser.
  86555. */
  86556. readonly isMP3supported: boolean;
  86557. /**
  86558. * Gets whether or not ogg are supported by your browser.
  86559. */
  86560. readonly isOGGsupported: boolean;
  86561. /**
  86562. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86563. * @ignoreNaming
  86564. */
  86565. WarnedWebAudioUnsupported: boolean;
  86566. /**
  86567. * Defines if the audio engine relies on a custom unlocked button.
  86568. * In this case, the embedded button will not be displayed.
  86569. */
  86570. useCustomUnlockedButton: boolean;
  86571. /**
  86572. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86573. */
  86574. readonly unlocked: boolean;
  86575. /**
  86576. * Event raised when audio has been unlocked on the browser.
  86577. */
  86578. onAudioUnlockedObservable: Observable<AudioEngine>;
  86579. /**
  86580. * Event raised when audio has been locked on the browser.
  86581. */
  86582. onAudioLockedObservable: Observable<AudioEngine>;
  86583. /**
  86584. * Flags the audio engine in Locked state.
  86585. * This happens due to new browser policies preventing audio to autoplay.
  86586. */
  86587. lock(): void;
  86588. /**
  86589. * Unlocks the audio engine once a user action has been done on the dom.
  86590. * This is helpful to resume play once browser policies have been satisfied.
  86591. */
  86592. unlock(): void;
  86593. }
  86594. /**
  86595. * This represents the default audio engine used in babylon.
  86596. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86598. */
  86599. export class AudioEngine implements IAudioEngine {
  86600. private _audioContext;
  86601. private _audioContextInitialized;
  86602. private _muteButton;
  86603. private _hostElement;
  86604. /**
  86605. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86606. */
  86607. canUseWebAudio: boolean;
  86608. /**
  86609. * The master gain node defines the global audio volume of your audio engine.
  86610. */
  86611. masterGain: GainNode;
  86612. /**
  86613. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86614. * @ignoreNaming
  86615. */
  86616. WarnedWebAudioUnsupported: boolean;
  86617. /**
  86618. * Gets whether or not mp3 are supported by your browser.
  86619. */
  86620. isMP3supported: boolean;
  86621. /**
  86622. * Gets whether or not ogg are supported by your browser.
  86623. */
  86624. isOGGsupported: boolean;
  86625. /**
  86626. * Gets whether audio has been unlocked on the device.
  86627. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86628. * a user interaction has happened.
  86629. */
  86630. unlocked: boolean;
  86631. /**
  86632. * Defines if the audio engine relies on a custom unlocked button.
  86633. * In this case, the embedded button will not be displayed.
  86634. */
  86635. useCustomUnlockedButton: boolean;
  86636. /**
  86637. * Event raised when audio has been unlocked on the browser.
  86638. */
  86639. onAudioUnlockedObservable: Observable<AudioEngine>;
  86640. /**
  86641. * Event raised when audio has been locked on the browser.
  86642. */
  86643. onAudioLockedObservable: Observable<AudioEngine>;
  86644. /**
  86645. * Gets the current AudioContext if available.
  86646. */
  86647. readonly audioContext: Nullable<AudioContext>;
  86648. private _connectedAnalyser;
  86649. /**
  86650. * Instantiates a new audio engine.
  86651. *
  86652. * There should be only one per page as some browsers restrict the number
  86653. * of audio contexts you can create.
  86654. * @param hostElement defines the host element where to display the mute icon if necessary
  86655. */
  86656. constructor(hostElement?: Nullable<HTMLElement>);
  86657. /**
  86658. * Flags the audio engine in Locked state.
  86659. * This happens due to new browser policies preventing audio to autoplay.
  86660. */
  86661. lock(): void;
  86662. /**
  86663. * Unlocks the audio engine once a user action has been done on the dom.
  86664. * This is helpful to resume play once browser policies have been satisfied.
  86665. */
  86666. unlock(): void;
  86667. private _resumeAudioContext;
  86668. private _initializeAudioContext;
  86669. private _tryToRun;
  86670. private _triggerRunningState;
  86671. private _triggerSuspendedState;
  86672. private _displayMuteButton;
  86673. private _moveButtonToTopLeft;
  86674. private _onResize;
  86675. private _hideMuteButton;
  86676. /**
  86677. * Destroy and release the resources associated with the audio ccontext.
  86678. */
  86679. dispose(): void;
  86680. /**
  86681. * Gets the global volume sets on the master gain.
  86682. * @returns the global volume if set or -1 otherwise
  86683. */
  86684. getGlobalVolume(): number;
  86685. /**
  86686. * Sets the global volume of your experience (sets on the master gain).
  86687. * @param newVolume Defines the new global volume of the application
  86688. */
  86689. setGlobalVolume(newVolume: number): void;
  86690. /**
  86691. * Connect the audio engine to an audio analyser allowing some amazing
  86692. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86694. * @param analyser The analyser to connect to the engine
  86695. */
  86696. connectToAnalyser(analyser: Analyser): void;
  86697. }
  86698. }
  86699. declare module BABYLON {
  86700. /**
  86701. * Interface used to present a loading screen while loading a scene
  86702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86703. */
  86704. export interface ILoadingScreen {
  86705. /**
  86706. * Function called to display the loading screen
  86707. */
  86708. displayLoadingUI: () => void;
  86709. /**
  86710. * Function called to hide the loading screen
  86711. */
  86712. hideLoadingUI: () => void;
  86713. /**
  86714. * Gets or sets the color to use for the background
  86715. */
  86716. loadingUIBackgroundColor: string;
  86717. /**
  86718. * Gets or sets the text to display while loading
  86719. */
  86720. loadingUIText: string;
  86721. }
  86722. /**
  86723. * Class used for the default loading screen
  86724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86725. */
  86726. export class DefaultLoadingScreen implements ILoadingScreen {
  86727. private _renderingCanvas;
  86728. private _loadingText;
  86729. private _loadingDivBackgroundColor;
  86730. private _loadingDiv;
  86731. private _loadingTextDiv;
  86732. /**
  86733. * Creates a new default loading screen
  86734. * @param _renderingCanvas defines the canvas used to render the scene
  86735. * @param _loadingText defines the default text to display
  86736. * @param _loadingDivBackgroundColor defines the default background color
  86737. */
  86738. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86739. /**
  86740. * Function called to display the loading screen
  86741. */
  86742. displayLoadingUI(): void;
  86743. /**
  86744. * Function called to hide the loading screen
  86745. */
  86746. hideLoadingUI(): void;
  86747. /**
  86748. * Gets or sets the text to display while loading
  86749. */
  86750. loadingUIText: string;
  86751. /**
  86752. * Gets or sets the color to use for the background
  86753. */
  86754. loadingUIBackgroundColor: string;
  86755. private _resizeLoadingUI;
  86756. }
  86757. }
  86758. declare module BABYLON {
  86759. /** @hidden */
  86760. export class WebGLPipelineContext implements IPipelineContext {
  86761. engine: Engine;
  86762. program: Nullable<WebGLProgram>;
  86763. context?: WebGLRenderingContext;
  86764. vertexShader?: WebGLShader;
  86765. fragmentShader?: WebGLShader;
  86766. isParallelCompiled: boolean;
  86767. onCompiled?: () => void;
  86768. transformFeedback?: WebGLTransformFeedback | null;
  86769. readonly isAsync: boolean;
  86770. readonly isReady: boolean;
  86771. }
  86772. }
  86773. declare module BABYLON {
  86774. /** @hidden */
  86775. export class WebGLDataBuffer extends DataBuffer {
  86776. private _buffer;
  86777. constructor(resource: WebGLBuffer);
  86778. readonly underlyingResource: any;
  86779. }
  86780. }
  86781. declare module BABYLON {
  86782. /**
  86783. * Settings for finer control over video usage
  86784. */
  86785. export interface VideoTextureSettings {
  86786. /**
  86787. * Applies `autoplay` to video, if specified
  86788. */
  86789. autoPlay?: boolean;
  86790. /**
  86791. * Applies `loop` to video, if specified
  86792. */
  86793. loop?: boolean;
  86794. /**
  86795. * Automatically updates internal texture from video at every frame in the render loop
  86796. */
  86797. autoUpdateTexture: boolean;
  86798. /**
  86799. * Image src displayed during the video loading or until the user interacts with the video.
  86800. */
  86801. poster?: string;
  86802. }
  86803. /**
  86804. * If you want to display a video in your scene, this is the special texture for that.
  86805. * This special texture works similar to other textures, with the exception of a few parameters.
  86806. * @see https://doc.babylonjs.com/how_to/video_texture
  86807. */
  86808. export class VideoTexture extends Texture {
  86809. /**
  86810. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86811. */
  86812. readonly autoUpdateTexture: boolean;
  86813. /**
  86814. * The video instance used by the texture internally
  86815. */
  86816. readonly video: HTMLVideoElement;
  86817. private _onUserActionRequestedObservable;
  86818. /**
  86819. * Event triggerd when a dom action is required by the user to play the video.
  86820. * This happens due to recent changes in browser policies preventing video to auto start.
  86821. */
  86822. readonly onUserActionRequestedObservable: Observable<Texture>;
  86823. private _generateMipMaps;
  86824. private _engine;
  86825. private _stillImageCaptured;
  86826. private _displayingPosterTexture;
  86827. private _settings;
  86828. private _createInternalTextureOnEvent;
  86829. /**
  86830. * Creates a video texture.
  86831. * If you want to display a video in your scene, this is the special texture for that.
  86832. * This special texture works similar to other textures, with the exception of a few parameters.
  86833. * @see https://doc.babylonjs.com/how_to/video_texture
  86834. * @param name optional name, will detect from video source, if not defined
  86835. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86836. * @param scene is obviously the current scene.
  86837. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86838. * @param invertY is false by default but can be used to invert video on Y axis
  86839. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86840. * @param settings allows finer control over video usage
  86841. */
  86842. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86843. private _getName;
  86844. private _getVideo;
  86845. private _createInternalTexture;
  86846. private reset;
  86847. /**
  86848. * @hidden Internal method to initiate `update`.
  86849. */
  86850. _rebuild(): void;
  86851. /**
  86852. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86853. */
  86854. update(): void;
  86855. /**
  86856. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86857. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86858. */
  86859. updateTexture(isVisible: boolean): void;
  86860. protected _updateInternalTexture: () => void;
  86861. /**
  86862. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86863. * @param url New url.
  86864. */
  86865. updateURL(url: string): void;
  86866. /**
  86867. * Dispose the texture and release its associated resources.
  86868. */
  86869. dispose(): void;
  86870. /**
  86871. * Creates a video texture straight from a stream.
  86872. * @param scene Define the scene the texture should be created in
  86873. * @param stream Define the stream the texture should be created from
  86874. * @returns The created video texture as a promise
  86875. */
  86876. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86877. /**
  86878. * Creates a video texture straight from your WebCam video feed.
  86879. * @param scene Define the scene the texture should be created in
  86880. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86881. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86882. * @returns The created video texture as a promise
  86883. */
  86884. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86885. minWidth: number;
  86886. maxWidth: number;
  86887. minHeight: number;
  86888. maxHeight: number;
  86889. deviceId: string;
  86890. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86891. /**
  86892. * Creates a video texture straight from your WebCam video feed.
  86893. * @param scene Define the scene the texture should be created in
  86894. * @param onReady Define a callback to triggered once the texture will be ready
  86895. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86896. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86897. */
  86898. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86899. minWidth: number;
  86900. maxWidth: number;
  86901. minHeight: number;
  86902. maxHeight: number;
  86903. deviceId: string;
  86904. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86905. }
  86906. }
  86907. declare module BABYLON {
  86908. /**
  86909. * Interface for attribute information associated with buffer instanciation
  86910. */
  86911. export class InstancingAttributeInfo {
  86912. /**
  86913. * Index/offset of the attribute in the vertex shader
  86914. */
  86915. index: number;
  86916. /**
  86917. * size of the attribute, 1, 2, 3 or 4
  86918. */
  86919. attributeSize: number;
  86920. /**
  86921. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86922. * default is FLOAT
  86923. */
  86924. attribyteType: number;
  86925. /**
  86926. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86927. */
  86928. normalized: boolean;
  86929. /**
  86930. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86931. */
  86932. offset: number;
  86933. /**
  86934. * Name of the GLSL attribute, for debugging purpose only
  86935. */
  86936. attributeName: string;
  86937. }
  86938. /**
  86939. * Define options used to create a depth texture
  86940. */
  86941. export class DepthTextureCreationOptions {
  86942. /** Specifies whether or not a stencil should be allocated in the texture */
  86943. generateStencil?: boolean;
  86944. /** Specifies whether or not bilinear filtering is enable on the texture */
  86945. bilinearFiltering?: boolean;
  86946. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86947. comparisonFunction?: number;
  86948. /** Specifies if the created texture is a cube texture */
  86949. isCube?: boolean;
  86950. }
  86951. /**
  86952. * Class used to describe the capabilities of the engine relatively to the current browser
  86953. */
  86954. export class EngineCapabilities {
  86955. /** Maximum textures units per fragment shader */
  86956. maxTexturesImageUnits: number;
  86957. /** Maximum texture units per vertex shader */
  86958. maxVertexTextureImageUnits: number;
  86959. /** Maximum textures units in the entire pipeline */
  86960. maxCombinedTexturesImageUnits: number;
  86961. /** Maximum texture size */
  86962. maxTextureSize: number;
  86963. /** Maximum cube texture size */
  86964. maxCubemapTextureSize: number;
  86965. /** Maximum render texture size */
  86966. maxRenderTextureSize: number;
  86967. /** Maximum number of vertex attributes */
  86968. maxVertexAttribs: number;
  86969. /** Maximum number of varyings */
  86970. maxVaryingVectors: number;
  86971. /** Maximum number of uniforms per vertex shader */
  86972. maxVertexUniformVectors: number;
  86973. /** Maximum number of uniforms per fragment shader */
  86974. maxFragmentUniformVectors: number;
  86975. /** Defines if standard derivates (dx/dy) are supported */
  86976. standardDerivatives: boolean;
  86977. /** Defines if s3tc texture compression is supported */
  86978. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86979. /** Defines if pvrtc texture compression is supported */
  86980. pvrtc: any;
  86981. /** Defines if etc1 texture compression is supported */
  86982. etc1: any;
  86983. /** Defines if etc2 texture compression is supported */
  86984. etc2: any;
  86985. /** Defines if astc texture compression is supported */
  86986. astc: any;
  86987. /** Defines if float textures are supported */
  86988. textureFloat: boolean;
  86989. /** Defines if vertex array objects are supported */
  86990. vertexArrayObject: boolean;
  86991. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86992. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86993. /** Gets the maximum level of anisotropy supported */
  86994. maxAnisotropy: number;
  86995. /** Defines if instancing is supported */
  86996. instancedArrays: boolean;
  86997. /** Defines if 32 bits indices are supported */
  86998. uintIndices: boolean;
  86999. /** Defines if high precision shaders are supported */
  87000. highPrecisionShaderSupported: boolean;
  87001. /** Defines if depth reading in the fragment shader is supported */
  87002. fragmentDepthSupported: boolean;
  87003. /** Defines if float texture linear filtering is supported*/
  87004. textureFloatLinearFiltering: boolean;
  87005. /** Defines if rendering to float textures is supported */
  87006. textureFloatRender: boolean;
  87007. /** Defines if half float textures are supported*/
  87008. textureHalfFloat: boolean;
  87009. /** Defines if half float texture linear filtering is supported*/
  87010. textureHalfFloatLinearFiltering: boolean;
  87011. /** Defines if rendering to half float textures is supported */
  87012. textureHalfFloatRender: boolean;
  87013. /** Defines if textureLOD shader command is supported */
  87014. textureLOD: boolean;
  87015. /** Defines if draw buffers extension is supported */
  87016. drawBuffersExtension: boolean;
  87017. /** Defines if depth textures are supported */
  87018. depthTextureExtension: boolean;
  87019. /** Defines if float color buffer are supported */
  87020. colorBufferFloat: boolean;
  87021. /** Gets disjoint timer query extension (null if not supported) */
  87022. timerQuery: EXT_disjoint_timer_query;
  87023. /** Defines if timestamp can be used with timer query */
  87024. canUseTimestampForTimerQuery: boolean;
  87025. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87026. multiview: any;
  87027. /** Function used to let the system compiles shaders in background */
  87028. parallelShaderCompile: {
  87029. COMPLETION_STATUS_KHR: number;
  87030. };
  87031. }
  87032. /** Interface defining initialization parameters for Engine class */
  87033. export interface EngineOptions extends WebGLContextAttributes {
  87034. /**
  87035. * Defines if the engine should no exceed a specified device ratio
  87036. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87037. */
  87038. limitDeviceRatio?: number;
  87039. /**
  87040. * Defines if webvr should be enabled automatically
  87041. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87042. */
  87043. autoEnableWebVR?: boolean;
  87044. /**
  87045. * Defines if webgl2 should be turned off even if supported
  87046. * @see http://doc.babylonjs.com/features/webgl2
  87047. */
  87048. disableWebGL2Support?: boolean;
  87049. /**
  87050. * Defines if webaudio should be initialized as well
  87051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87052. */
  87053. audioEngine?: boolean;
  87054. /**
  87055. * Defines if animations should run using a deterministic lock step
  87056. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87057. */
  87058. deterministicLockstep?: boolean;
  87059. /** Defines the maximum steps to use with deterministic lock step mode */
  87060. lockstepMaxSteps?: number;
  87061. /**
  87062. * Defines that engine should ignore context lost events
  87063. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87064. */
  87065. doNotHandleContextLost?: boolean;
  87066. /**
  87067. * Defines that engine should ignore modifying touch action attribute and style
  87068. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87069. */
  87070. doNotHandleTouchAction?: boolean;
  87071. /**
  87072. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87073. */
  87074. useHighPrecisionFloats?: boolean;
  87075. }
  87076. /**
  87077. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87078. */
  87079. export class Engine {
  87080. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87081. static ExceptionList: ({
  87082. key: string;
  87083. capture: string;
  87084. captureConstraint: number;
  87085. targets: string[];
  87086. } | {
  87087. key: string;
  87088. capture: null;
  87089. captureConstraint: null;
  87090. targets: string[];
  87091. })[];
  87092. /** Gets the list of created engines */
  87093. static readonly Instances: Engine[];
  87094. /**
  87095. * Gets the latest created engine
  87096. */
  87097. static readonly LastCreatedEngine: Nullable<Engine>;
  87098. /**
  87099. * Gets the latest created scene
  87100. */
  87101. static readonly LastCreatedScene: Nullable<Scene>;
  87102. /**
  87103. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87104. * @param flag defines which part of the materials must be marked as dirty
  87105. * @param predicate defines a predicate used to filter which materials should be affected
  87106. */
  87107. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87108. /**
  87109. * Hidden
  87110. */
  87111. static _TextureLoaders: IInternalTextureLoader[];
  87112. /** Defines that alpha blending is disabled */
  87113. static readonly ALPHA_DISABLE: number;
  87114. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87115. static readonly ALPHA_ADD: number;
  87116. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87117. static readonly ALPHA_COMBINE: number;
  87118. /** Defines that alpha blending to DEST - SRC * DEST */
  87119. static readonly ALPHA_SUBTRACT: number;
  87120. /** Defines that alpha blending to SRC * DEST */
  87121. static readonly ALPHA_MULTIPLY: number;
  87122. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87123. static readonly ALPHA_MAXIMIZED: number;
  87124. /** Defines that alpha blending to SRC + DEST */
  87125. static readonly ALPHA_ONEONE: number;
  87126. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87127. static readonly ALPHA_PREMULTIPLIED: number;
  87128. /**
  87129. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87130. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87131. */
  87132. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87133. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87134. static readonly ALPHA_INTERPOLATE: number;
  87135. /**
  87136. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87137. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87138. */
  87139. static readonly ALPHA_SCREENMODE: number;
  87140. /** Defines that the ressource is not delayed*/
  87141. static readonly DELAYLOADSTATE_NONE: number;
  87142. /** Defines that the ressource was successfully delay loaded */
  87143. static readonly DELAYLOADSTATE_LOADED: number;
  87144. /** Defines that the ressource is currently delay loading */
  87145. static readonly DELAYLOADSTATE_LOADING: number;
  87146. /** Defines that the ressource is delayed and has not started loading */
  87147. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87149. static readonly NEVER: number;
  87150. /** 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 */
  87151. static readonly ALWAYS: number;
  87152. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87153. static readonly LESS: number;
  87154. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87155. static readonly EQUAL: number;
  87156. /** 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 */
  87157. static readonly LEQUAL: number;
  87158. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87159. static readonly GREATER: number;
  87160. /** 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 */
  87161. static readonly GEQUAL: number;
  87162. /** 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 */
  87163. static readonly NOTEQUAL: number;
  87164. /** Passed to stencilOperation to specify that stencil value must be kept */
  87165. static readonly KEEP: number;
  87166. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87167. static readonly REPLACE: number;
  87168. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87169. static readonly INCR: number;
  87170. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87171. static readonly DECR: number;
  87172. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87173. static readonly INVERT: number;
  87174. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87175. static readonly INCR_WRAP: number;
  87176. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87177. static readonly DECR_WRAP: number;
  87178. /** Texture is not repeating outside of 0..1 UVs */
  87179. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87180. /** Texture is repeating outside of 0..1 UVs */
  87181. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87182. /** Texture is repeating and mirrored */
  87183. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87184. /** ALPHA */
  87185. static readonly TEXTUREFORMAT_ALPHA: number;
  87186. /** LUMINANCE */
  87187. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87188. /** LUMINANCE_ALPHA */
  87189. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87190. /** RGB */
  87191. static readonly TEXTUREFORMAT_RGB: number;
  87192. /** RGBA */
  87193. static readonly TEXTUREFORMAT_RGBA: number;
  87194. /** RED */
  87195. static readonly TEXTUREFORMAT_RED: number;
  87196. /** RED (2nd reference) */
  87197. static readonly TEXTUREFORMAT_R: number;
  87198. /** RG */
  87199. static readonly TEXTUREFORMAT_RG: number;
  87200. /** RED_INTEGER */
  87201. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87202. /** RED_INTEGER (2nd reference) */
  87203. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87204. /** RG_INTEGER */
  87205. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87206. /** RGB_INTEGER */
  87207. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87208. /** RGBA_INTEGER */
  87209. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87210. /** UNSIGNED_BYTE */
  87211. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87212. /** UNSIGNED_BYTE (2nd reference) */
  87213. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87214. /** FLOAT */
  87215. static readonly TEXTURETYPE_FLOAT: number;
  87216. /** HALF_FLOAT */
  87217. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87218. /** BYTE */
  87219. static readonly TEXTURETYPE_BYTE: number;
  87220. /** SHORT */
  87221. static readonly TEXTURETYPE_SHORT: number;
  87222. /** UNSIGNED_SHORT */
  87223. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87224. /** INT */
  87225. static readonly TEXTURETYPE_INT: number;
  87226. /** UNSIGNED_INT */
  87227. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87228. /** UNSIGNED_SHORT_4_4_4_4 */
  87229. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87230. /** UNSIGNED_SHORT_5_5_5_1 */
  87231. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87232. /** UNSIGNED_SHORT_5_6_5 */
  87233. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87234. /** UNSIGNED_INT_2_10_10_10_REV */
  87235. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87236. /** UNSIGNED_INT_24_8 */
  87237. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87238. /** UNSIGNED_INT_10F_11F_11F_REV */
  87239. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87240. /** UNSIGNED_INT_5_9_9_9_REV */
  87241. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87242. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87243. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87244. /** nearest is mag = nearest and min = nearest and mip = linear */
  87245. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87246. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87247. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87248. /** Trilinear is mag = linear and min = linear and mip = linear */
  87249. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87250. /** nearest is mag = nearest and min = nearest and mip = linear */
  87251. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87252. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87253. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87254. /** Trilinear is mag = linear and min = linear and mip = linear */
  87255. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87256. /** mag = nearest and min = nearest and mip = nearest */
  87257. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87258. /** mag = nearest and min = linear and mip = nearest */
  87259. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87260. /** mag = nearest and min = linear and mip = linear */
  87261. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87262. /** mag = nearest and min = linear and mip = none */
  87263. static readonly TEXTURE_NEAREST_LINEAR: number;
  87264. /** mag = nearest and min = nearest and mip = none */
  87265. static readonly TEXTURE_NEAREST_NEAREST: number;
  87266. /** mag = linear and min = nearest and mip = nearest */
  87267. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87268. /** mag = linear and min = nearest and mip = linear */
  87269. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87270. /** mag = linear and min = linear and mip = none */
  87271. static readonly TEXTURE_LINEAR_LINEAR: number;
  87272. /** mag = linear and min = nearest and mip = none */
  87273. static readonly TEXTURE_LINEAR_NEAREST: number;
  87274. /** Explicit coordinates mode */
  87275. static readonly TEXTURE_EXPLICIT_MODE: number;
  87276. /** Spherical coordinates mode */
  87277. static readonly TEXTURE_SPHERICAL_MODE: number;
  87278. /** Planar coordinates mode */
  87279. static readonly TEXTURE_PLANAR_MODE: number;
  87280. /** Cubic coordinates mode */
  87281. static readonly TEXTURE_CUBIC_MODE: number;
  87282. /** Projection coordinates mode */
  87283. static readonly TEXTURE_PROJECTION_MODE: number;
  87284. /** Skybox coordinates mode */
  87285. static readonly TEXTURE_SKYBOX_MODE: number;
  87286. /** Inverse Cubic coordinates mode */
  87287. static readonly TEXTURE_INVCUBIC_MODE: number;
  87288. /** Equirectangular coordinates mode */
  87289. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87290. /** Equirectangular Fixed coordinates mode */
  87291. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87292. /** Equirectangular Fixed Mirrored coordinates mode */
  87293. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87294. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87295. static readonly SCALEMODE_FLOOR: number;
  87296. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87297. static readonly SCALEMODE_NEAREST: number;
  87298. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87299. static readonly SCALEMODE_CEILING: number;
  87300. /**
  87301. * Returns the current npm package of the sdk
  87302. */
  87303. static readonly NpmPackage: string;
  87304. /**
  87305. * Returns the current version of the framework
  87306. */
  87307. static readonly Version: string;
  87308. /**
  87309. * Returns a string describing the current engine
  87310. */
  87311. readonly description: string;
  87312. /**
  87313. * Gets or sets the epsilon value used by collision engine
  87314. */
  87315. static CollisionsEpsilon: number;
  87316. /**
  87317. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87318. */
  87319. static ShadersRepository: string;
  87320. /**
  87321. * Method called to create the default loading screen.
  87322. * This can be overriden in your own app.
  87323. * @param canvas The rendering canvas element
  87324. * @returns The loading screen
  87325. */
  87326. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87327. /**
  87328. * Method called to create the default rescale post process on each engine.
  87329. */
  87330. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87331. /**
  87332. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87333. */
  87334. forcePOTTextures: boolean;
  87335. /**
  87336. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87337. */
  87338. isFullscreen: boolean;
  87339. /**
  87340. * Gets a boolean indicating if the pointer is currently locked
  87341. */
  87342. isPointerLock: boolean;
  87343. /**
  87344. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87345. */
  87346. cullBackFaces: boolean;
  87347. /**
  87348. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87349. */
  87350. renderEvenInBackground: boolean;
  87351. /**
  87352. * Gets or sets a boolean indicating that cache can be kept between frames
  87353. */
  87354. preventCacheWipeBetweenFrames: boolean;
  87355. /**
  87356. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87357. **/
  87358. enableOfflineSupport: boolean;
  87359. /**
  87360. * 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)
  87361. **/
  87362. disableManifestCheck: boolean;
  87363. /**
  87364. * Gets the list of created scenes
  87365. */
  87366. scenes: Scene[];
  87367. /**
  87368. * Event raised when a new scene is created
  87369. */
  87370. onNewSceneAddedObservable: Observable<Scene>;
  87371. /**
  87372. * Gets the list of created postprocesses
  87373. */
  87374. postProcesses: PostProcess[];
  87375. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87376. validateShaderPrograms: boolean;
  87377. /**
  87378. * Observable event triggered each time the rendering canvas is resized
  87379. */
  87380. onResizeObservable: Observable<Engine>;
  87381. /**
  87382. * Observable event triggered each time the canvas loses focus
  87383. */
  87384. onCanvasBlurObservable: Observable<Engine>;
  87385. /**
  87386. * Observable event triggered each time the canvas gains focus
  87387. */
  87388. onCanvasFocusObservable: Observable<Engine>;
  87389. /**
  87390. * Observable event triggered each time the canvas receives pointerout event
  87391. */
  87392. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87393. /**
  87394. * Observable event triggered before each texture is initialized
  87395. */
  87396. onBeforeTextureInitObservable: Observable<Texture>;
  87397. /**
  87398. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87399. */
  87400. disableUniformBuffers: boolean;
  87401. /** @hidden */
  87402. _uniformBuffers: UniformBuffer[];
  87403. /**
  87404. * Gets a boolean indicating that the engine supports uniform buffers
  87405. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87406. */
  87407. readonly supportsUniformBuffers: boolean;
  87408. /**
  87409. * Observable raised when the engine begins a new frame
  87410. */
  87411. onBeginFrameObservable: Observable<Engine>;
  87412. /**
  87413. * If set, will be used to request the next animation frame for the render loop
  87414. */
  87415. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87416. /**
  87417. * Observable raised when the engine ends the current frame
  87418. */
  87419. onEndFrameObservable: Observable<Engine>;
  87420. /**
  87421. * Observable raised when the engine is about to compile a shader
  87422. */
  87423. onBeforeShaderCompilationObservable: Observable<Engine>;
  87424. /**
  87425. * Observable raised when the engine has jsut compiled a shader
  87426. */
  87427. onAfterShaderCompilationObservable: Observable<Engine>;
  87428. /** @hidden */
  87429. _gl: WebGLRenderingContext;
  87430. private _renderingCanvas;
  87431. private _windowIsBackground;
  87432. private _webGLVersion;
  87433. protected _highPrecisionShadersAllowed: boolean;
  87434. /** @hidden */
  87435. readonly _shouldUseHighPrecisionShader: boolean;
  87436. /**
  87437. * Gets a boolean indicating that only power of 2 textures are supported
  87438. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87439. */
  87440. readonly needPOTTextures: boolean;
  87441. /** @hidden */
  87442. _badOS: boolean;
  87443. /** @hidden */
  87444. _badDesktopOS: boolean;
  87445. /**
  87446. * Gets the audio engine
  87447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87448. * @ignorenaming
  87449. */
  87450. static audioEngine: IAudioEngine;
  87451. /**
  87452. * Default AudioEngine factory responsible of creating the Audio Engine.
  87453. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87454. */
  87455. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87456. /**
  87457. * Default offline support factory responsible of creating a tool used to store data locally.
  87458. * By default, this will create a Database object if the workload has been embedded.
  87459. */
  87460. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87461. private _onFocus;
  87462. private _onBlur;
  87463. private _onCanvasPointerOut;
  87464. private _onCanvasBlur;
  87465. private _onCanvasFocus;
  87466. private _onFullscreenChange;
  87467. private _onPointerLockChange;
  87468. private _hardwareScalingLevel;
  87469. /** @hidden */
  87470. _caps: EngineCapabilities;
  87471. private _pointerLockRequested;
  87472. private _isStencilEnable;
  87473. private _colorWrite;
  87474. private _loadingScreen;
  87475. /** @hidden */
  87476. _drawCalls: PerfCounter;
  87477. private _glVersion;
  87478. private _glRenderer;
  87479. private _glVendor;
  87480. private _videoTextureSupported;
  87481. private _renderingQueueLaunched;
  87482. private _activeRenderLoops;
  87483. private _deterministicLockstep;
  87484. private _lockstepMaxSteps;
  87485. /**
  87486. * Observable signaled when a context lost event is raised
  87487. */
  87488. onContextLostObservable: Observable<Engine>;
  87489. /**
  87490. * Observable signaled when a context restored event is raised
  87491. */
  87492. onContextRestoredObservable: Observable<Engine>;
  87493. private _onContextLost;
  87494. private _onContextRestored;
  87495. private _contextWasLost;
  87496. /** @hidden */
  87497. _doNotHandleContextLost: boolean;
  87498. /**
  87499. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87501. */
  87502. doNotHandleContextLost: boolean;
  87503. private _performanceMonitor;
  87504. private _fps;
  87505. private _deltaTime;
  87506. /**
  87507. * Turn this value on if you want to pause FPS computation when in background
  87508. */
  87509. disablePerformanceMonitorInBackground: boolean;
  87510. /**
  87511. * Gets the performance monitor attached to this engine
  87512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87513. */
  87514. readonly performanceMonitor: PerformanceMonitor;
  87515. /**
  87516. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87517. */
  87518. disableVertexArrayObjects: boolean;
  87519. /** @hidden */
  87520. protected _depthCullingState: _DepthCullingState;
  87521. /** @hidden */
  87522. protected _stencilState: _StencilState;
  87523. /** @hidden */
  87524. protected _alphaState: _AlphaState;
  87525. /** @hidden */
  87526. protected _alphaMode: number;
  87527. /** @hidden */
  87528. _internalTexturesCache: InternalTexture[];
  87529. /** @hidden */
  87530. protected _activeChannel: number;
  87531. private _currentTextureChannel;
  87532. /** @hidden */
  87533. protected _boundTexturesCache: {
  87534. [key: string]: Nullable<InternalTexture>;
  87535. };
  87536. /** @hidden */
  87537. protected _currentEffect: Nullable<Effect>;
  87538. /** @hidden */
  87539. protected _currentProgram: Nullable<WebGLProgram>;
  87540. private _compiledEffects;
  87541. private _vertexAttribArraysEnabled;
  87542. /** @hidden */
  87543. protected _cachedViewport: Nullable<Viewport>;
  87544. private _cachedVertexArrayObject;
  87545. /** @hidden */
  87546. protected _cachedVertexBuffers: any;
  87547. /** @hidden */
  87548. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87549. /** @hidden */
  87550. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87551. /** @hidden */
  87552. _currentRenderTarget: Nullable<InternalTexture>;
  87553. private _uintIndicesCurrentlySet;
  87554. private _currentBoundBuffer;
  87555. /** @hidden */
  87556. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87557. private _currentBufferPointers;
  87558. private _currentInstanceLocations;
  87559. private _currentInstanceBuffers;
  87560. private _textureUnits;
  87561. /** @hidden */
  87562. _workingCanvas: Nullable<HTMLCanvasElement>;
  87563. /** @hidden */
  87564. _workingContext: Nullable<CanvasRenderingContext2D>;
  87565. private _rescalePostProcess;
  87566. private _dummyFramebuffer;
  87567. private _externalData;
  87568. /** @hidden */
  87569. _bindedRenderFunction: any;
  87570. private _vaoRecordInProgress;
  87571. private _mustWipeVertexAttributes;
  87572. private _emptyTexture;
  87573. private _emptyCubeTexture;
  87574. private _emptyTexture3D;
  87575. /** @hidden */
  87576. _frameHandler: number;
  87577. private _nextFreeTextureSlots;
  87578. private _maxSimultaneousTextures;
  87579. private _activeRequests;
  87580. private _texturesSupported;
  87581. /** @hidden */
  87582. _textureFormatInUse: Nullable<string>;
  87583. /**
  87584. * Gets the list of texture formats supported
  87585. */
  87586. readonly texturesSupported: Array<string>;
  87587. /**
  87588. * Gets the list of texture formats in use
  87589. */
  87590. readonly textureFormatInUse: Nullable<string>;
  87591. /**
  87592. * Gets the current viewport
  87593. */
  87594. readonly currentViewport: Nullable<Viewport>;
  87595. /**
  87596. * Gets the default empty texture
  87597. */
  87598. readonly emptyTexture: InternalTexture;
  87599. /**
  87600. * Gets the default empty 3D texture
  87601. */
  87602. readonly emptyTexture3D: InternalTexture;
  87603. /**
  87604. * Gets the default empty cube texture
  87605. */
  87606. readonly emptyCubeTexture: InternalTexture;
  87607. /**
  87608. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87609. */
  87610. readonly premultipliedAlpha: boolean;
  87611. /**
  87612. * Creates a new engine
  87613. * @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
  87614. * @param antialias defines enable antialiasing (default: false)
  87615. * @param options defines further options to be sent to the getContext() function
  87616. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87617. */
  87618. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87619. /**
  87620. * Initializes a webVR display and starts listening to display change events
  87621. * The onVRDisplayChangedObservable will be notified upon these changes
  87622. * @returns The onVRDisplayChangedObservable
  87623. */
  87624. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87625. /** @hidden */
  87626. _prepareVRComponent(): void;
  87627. /** @hidden */
  87628. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87629. /** @hidden */
  87630. _submitVRFrame(): void;
  87631. /**
  87632. * Call this function to leave webVR mode
  87633. * Will do nothing if webVR is not supported or if there is no webVR device
  87634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87635. */
  87636. disableVR(): void;
  87637. /**
  87638. * Gets a boolean indicating that the system is in VR mode and is presenting
  87639. * @returns true if VR mode is engaged
  87640. */
  87641. isVRPresenting(): boolean;
  87642. /** @hidden */
  87643. _requestVRFrame(): void;
  87644. private _disableTouchAction;
  87645. private _rebuildInternalTextures;
  87646. private _rebuildEffects;
  87647. /**
  87648. * Gets a boolean indicating if all created effects are ready
  87649. * @returns true if all effects are ready
  87650. */
  87651. areAllEffectsReady(): boolean;
  87652. private _rebuildBuffers;
  87653. private _initGLContext;
  87654. /**
  87655. * Gets version of the current webGL context
  87656. */
  87657. readonly webGLVersion: number;
  87658. /**
  87659. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87660. */
  87661. readonly isStencilEnable: boolean;
  87662. /** @hidden */
  87663. _prepareWorkingCanvas(): void;
  87664. /**
  87665. * Reset the texture cache to empty state
  87666. */
  87667. resetTextureCache(): void;
  87668. /**
  87669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87671. * @returns true if engine is in deterministic lock step mode
  87672. */
  87673. isDeterministicLockStep(): boolean;
  87674. /**
  87675. * Gets the max steps when engine is running in deterministic lock step
  87676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87677. * @returns the max steps
  87678. */
  87679. getLockstepMaxSteps(): number;
  87680. /**
  87681. * Gets an object containing information about the current webGL context
  87682. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87683. */
  87684. getGlInfo(): {
  87685. vendor: string;
  87686. renderer: string;
  87687. version: string;
  87688. };
  87689. /**
  87690. * Gets current aspect ratio
  87691. * @param camera defines the camera to use to get the aspect ratio
  87692. * @param useScreen defines if screen size must be used (or the current render target if any)
  87693. * @returns a number defining the aspect ratio
  87694. */
  87695. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87696. /**
  87697. * Gets current screen aspect ratio
  87698. * @returns a number defining the aspect ratio
  87699. */
  87700. getScreenAspectRatio(): number;
  87701. /**
  87702. * Gets the current render width
  87703. * @param useScreen defines if screen size must be used (or the current render target if any)
  87704. * @returns a number defining the current render width
  87705. */
  87706. getRenderWidth(useScreen?: boolean): number;
  87707. /**
  87708. * Gets the current render height
  87709. * @param useScreen defines if screen size must be used (or the current render target if any)
  87710. * @returns a number defining the current render height
  87711. */
  87712. getRenderHeight(useScreen?: boolean): number;
  87713. /**
  87714. * Gets the HTML canvas attached with the current webGL context
  87715. * @returns a HTML canvas
  87716. */
  87717. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87718. /**
  87719. * Gets the client rect of the HTML canvas attached with the current webGL context
  87720. * @returns a client rectanglee
  87721. */
  87722. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87723. /**
  87724. * Defines the hardware scaling level.
  87725. * By default the hardware scaling level is computed from the window device ratio.
  87726. * 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.
  87727. * @param level defines the level to use
  87728. */
  87729. setHardwareScalingLevel(level: number): void;
  87730. /**
  87731. * Gets the current hardware scaling level.
  87732. * By default the hardware scaling level is computed from the window device ratio.
  87733. * 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.
  87734. * @returns a number indicating the current hardware scaling level
  87735. */
  87736. getHardwareScalingLevel(): number;
  87737. /**
  87738. * Gets the list of loaded textures
  87739. * @returns an array containing all loaded textures
  87740. */
  87741. getLoadedTexturesCache(): InternalTexture[];
  87742. /**
  87743. * Gets the object containing all engine capabilities
  87744. * @returns the EngineCapabilities object
  87745. */
  87746. getCaps(): EngineCapabilities;
  87747. /**
  87748. * Gets the current depth function
  87749. * @returns a number defining the depth function
  87750. */
  87751. getDepthFunction(): Nullable<number>;
  87752. /**
  87753. * Sets the current depth function
  87754. * @param depthFunc defines the function to use
  87755. */
  87756. setDepthFunction(depthFunc: number): void;
  87757. /**
  87758. * Sets the current depth function to GREATER
  87759. */
  87760. setDepthFunctionToGreater(): void;
  87761. /**
  87762. * Sets the current depth function to GEQUAL
  87763. */
  87764. setDepthFunctionToGreaterOrEqual(): void;
  87765. /**
  87766. * Sets the current depth function to LESS
  87767. */
  87768. setDepthFunctionToLess(): void;
  87769. private _cachedStencilBuffer;
  87770. private _cachedStencilFunction;
  87771. private _cachedStencilMask;
  87772. private _cachedStencilOperationPass;
  87773. private _cachedStencilOperationFail;
  87774. private _cachedStencilOperationDepthFail;
  87775. private _cachedStencilReference;
  87776. /**
  87777. * Caches the the state of the stencil buffer
  87778. */
  87779. cacheStencilState(): void;
  87780. /**
  87781. * Restores the state of the stencil buffer
  87782. */
  87783. restoreStencilState(): void;
  87784. /**
  87785. * Sets the current depth function to LEQUAL
  87786. */
  87787. setDepthFunctionToLessOrEqual(): void;
  87788. /**
  87789. * Gets a boolean indicating if stencil buffer is enabled
  87790. * @returns the current stencil buffer state
  87791. */
  87792. getStencilBuffer(): boolean;
  87793. /**
  87794. * Enable or disable the stencil buffer
  87795. * @param enable defines if the stencil buffer must be enabled or disabled
  87796. */
  87797. setStencilBuffer(enable: boolean): void;
  87798. /**
  87799. * Gets the current stencil mask
  87800. * @returns a number defining the new stencil mask to use
  87801. */
  87802. getStencilMask(): number;
  87803. /**
  87804. * Sets the current stencil mask
  87805. * @param mask defines the new stencil mask to use
  87806. */
  87807. setStencilMask(mask: number): void;
  87808. /**
  87809. * Gets the current stencil function
  87810. * @returns a number defining the stencil function to use
  87811. */
  87812. getStencilFunction(): number;
  87813. /**
  87814. * Gets the current stencil reference value
  87815. * @returns a number defining the stencil reference value to use
  87816. */
  87817. getStencilFunctionReference(): number;
  87818. /**
  87819. * Gets the current stencil mask
  87820. * @returns a number defining the stencil mask to use
  87821. */
  87822. getStencilFunctionMask(): number;
  87823. /**
  87824. * Sets the current stencil function
  87825. * @param stencilFunc defines the new stencil function to use
  87826. */
  87827. setStencilFunction(stencilFunc: number): void;
  87828. /**
  87829. * Sets the current stencil reference
  87830. * @param reference defines the new stencil reference to use
  87831. */
  87832. setStencilFunctionReference(reference: number): void;
  87833. /**
  87834. * Sets the current stencil mask
  87835. * @param mask defines the new stencil mask to use
  87836. */
  87837. setStencilFunctionMask(mask: number): void;
  87838. /**
  87839. * Gets the current stencil operation when stencil fails
  87840. * @returns a number defining stencil operation to use when stencil fails
  87841. */
  87842. getStencilOperationFail(): number;
  87843. /**
  87844. * Gets the current stencil operation when depth fails
  87845. * @returns a number defining stencil operation to use when depth fails
  87846. */
  87847. getStencilOperationDepthFail(): number;
  87848. /**
  87849. * Gets the current stencil operation when stencil passes
  87850. * @returns a number defining stencil operation to use when stencil passes
  87851. */
  87852. getStencilOperationPass(): number;
  87853. /**
  87854. * Sets the stencil operation to use when stencil fails
  87855. * @param operation defines the stencil operation to use when stencil fails
  87856. */
  87857. setStencilOperationFail(operation: number): void;
  87858. /**
  87859. * Sets the stencil operation to use when depth fails
  87860. * @param operation defines the stencil operation to use when depth fails
  87861. */
  87862. setStencilOperationDepthFail(operation: number): void;
  87863. /**
  87864. * Sets the stencil operation to use when stencil passes
  87865. * @param operation defines the stencil operation to use when stencil passes
  87866. */
  87867. setStencilOperationPass(operation: number): void;
  87868. /**
  87869. * Sets a boolean indicating if the dithering state is enabled or disabled
  87870. * @param value defines the dithering state
  87871. */
  87872. setDitheringState(value: boolean): void;
  87873. /**
  87874. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87875. * @param value defines the rasterizer state
  87876. */
  87877. setRasterizerState(value: boolean): void;
  87878. /**
  87879. * stop executing a render loop function and remove it from the execution array
  87880. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87881. */
  87882. stopRenderLoop(renderFunction?: () => void): void;
  87883. /** @hidden */
  87884. _renderLoop(): void;
  87885. /**
  87886. * Register and execute a render loop. The engine can have more than one render function
  87887. * @param renderFunction defines the function to continuously execute
  87888. */
  87889. runRenderLoop(renderFunction: () => void): void;
  87890. /**
  87891. * Toggle full screen mode
  87892. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87893. */
  87894. switchFullscreen(requestPointerLock: boolean): void;
  87895. /**
  87896. * Enters full screen mode
  87897. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87898. */
  87899. enterFullscreen(requestPointerLock: boolean): void;
  87900. /**
  87901. * Exits full screen mode
  87902. */
  87903. exitFullscreen(): void;
  87904. /**
  87905. * Clear the current render buffer or the current render target (if any is set up)
  87906. * @param color defines the color to use
  87907. * @param backBuffer defines if the back buffer must be cleared
  87908. * @param depth defines if the depth buffer must be cleared
  87909. * @param stencil defines if the stencil buffer must be cleared
  87910. */
  87911. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87912. /**
  87913. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87914. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87915. * @param y defines the y-coordinate of the corner of the clear rectangle
  87916. * @param width defines the width of the clear rectangle
  87917. * @param height defines the height of the clear rectangle
  87918. * @param clearColor defines the clear color
  87919. */
  87920. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87921. /**
  87922. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87923. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87924. * @param y defines the y-coordinate of the corner of the clear rectangle
  87925. * @param width defines the width of the clear rectangle
  87926. * @param height defines the height of the clear rectangle
  87927. */
  87928. enableScissor(x: number, y: number, width: number, height: number): void;
  87929. /**
  87930. * Disable previously set scissor test rectangle
  87931. */
  87932. disableScissor(): void;
  87933. private _viewportCached;
  87934. /** @hidden */
  87935. _viewport(x: number, y: number, width: number, height: number): void;
  87936. /**
  87937. * Set the WebGL's viewport
  87938. * @param viewport defines the viewport element to be used
  87939. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87940. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87941. */
  87942. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87943. /**
  87944. * Directly set the WebGL Viewport
  87945. * @param x defines the x coordinate of the viewport (in screen space)
  87946. * @param y defines the y coordinate of the viewport (in screen space)
  87947. * @param width defines the width of the viewport (in screen space)
  87948. * @param height defines the height of the viewport (in screen space)
  87949. * @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
  87950. */
  87951. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87952. /**
  87953. * Begin a new frame
  87954. */
  87955. beginFrame(): void;
  87956. /**
  87957. * Enf the current frame
  87958. */
  87959. endFrame(): void;
  87960. /**
  87961. * Resize the view according to the canvas' size
  87962. */
  87963. resize(): void;
  87964. /**
  87965. * Force a specific size of the canvas
  87966. * @param width defines the new canvas' width
  87967. * @param height defines the new canvas' height
  87968. */
  87969. setSize(width: number, height: number): void;
  87970. /**
  87971. * Binds the frame buffer to the specified texture.
  87972. * @param texture The texture to render to or null for the default canvas
  87973. * @param faceIndex The face of the texture to render to in case of cube texture
  87974. * @param requiredWidth The width of the target to render to
  87975. * @param requiredHeight The height of the target to render to
  87976. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87977. * @param depthStencilTexture The depth stencil texture to use to render
  87978. * @param lodLevel defines le lod level to bind to the frame buffer
  87979. */
  87980. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87981. /** @hidden */
  87982. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  87983. /**
  87984. * Unbind the current render target texture from the webGL context
  87985. * @param texture defines the render target texture to unbind
  87986. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87987. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87988. */
  87989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87990. /**
  87991. * Force the mipmap generation for the given render target texture
  87992. * @param texture defines the render target texture to use
  87993. */
  87994. generateMipMapsForCubemap(texture: InternalTexture): void;
  87995. /**
  87996. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87997. */
  87998. flushFramebuffer(): void;
  87999. /**
  88000. * Unbind the current render target and bind the default framebuffer
  88001. */
  88002. restoreDefaultFramebuffer(): void;
  88003. /**
  88004. * Create an uniform buffer
  88005. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88006. * @param elements defines the content of the uniform buffer
  88007. * @returns the webGL uniform buffer
  88008. */
  88009. createUniformBuffer(elements: FloatArray): DataBuffer;
  88010. /**
  88011. * Create a dynamic uniform buffer
  88012. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88013. * @param elements defines the content of the uniform buffer
  88014. * @returns the webGL uniform buffer
  88015. */
  88016. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88017. /**
  88018. * Update an existing uniform buffer
  88019. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88020. * @param uniformBuffer defines the target uniform buffer
  88021. * @param elements defines the content to update
  88022. * @param offset defines the offset in the uniform buffer where update should start
  88023. * @param count defines the size of the data to update
  88024. */
  88025. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88026. private _resetVertexBufferBinding;
  88027. /**
  88028. * Creates a vertex buffer
  88029. * @param data the data for the vertex buffer
  88030. * @returns the new WebGL static buffer
  88031. */
  88032. createVertexBuffer(data: DataArray): DataBuffer;
  88033. /**
  88034. * Creates a dynamic vertex buffer
  88035. * @param data the data for the dynamic vertex buffer
  88036. * @returns the new WebGL dynamic buffer
  88037. */
  88038. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88039. /**
  88040. * Update a dynamic index buffer
  88041. * @param indexBuffer defines the target index buffer
  88042. * @param indices defines the data to update
  88043. * @param offset defines the offset in the target index buffer where update should start
  88044. */
  88045. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88046. /**
  88047. * Updates a dynamic vertex buffer.
  88048. * @param vertexBuffer the vertex buffer to update
  88049. * @param data the data used to update the vertex buffer
  88050. * @param byteOffset the byte offset of the data
  88051. * @param byteLength the byte length of the data
  88052. */
  88053. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88054. private _resetIndexBufferBinding;
  88055. /**
  88056. * Creates a new index buffer
  88057. * @param indices defines the content of the index buffer
  88058. * @param updatable defines if the index buffer must be updatable
  88059. * @returns a new webGL buffer
  88060. */
  88061. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88062. /**
  88063. * Bind a webGL buffer to the webGL context
  88064. * @param buffer defines the buffer to bind
  88065. */
  88066. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88067. /**
  88068. * Bind an uniform buffer to the current webGL context
  88069. * @param buffer defines the buffer to bind
  88070. */
  88071. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88072. /**
  88073. * Bind a buffer to the current webGL context at a given location
  88074. * @param buffer defines the buffer to bind
  88075. * @param location defines the index where to bind the buffer
  88076. */
  88077. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88078. /**
  88079. * Bind a specific block at a given index in a specific shader program
  88080. * @param pipelineContext defines the pipeline context to use
  88081. * @param blockName defines the block name
  88082. * @param index defines the index where to bind the block
  88083. */
  88084. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88085. private bindIndexBuffer;
  88086. private bindBuffer;
  88087. /**
  88088. * update the bound buffer with the given data
  88089. * @param data defines the data to update
  88090. */
  88091. updateArrayBuffer(data: Float32Array): void;
  88092. private _vertexAttribPointer;
  88093. private _bindIndexBufferWithCache;
  88094. private _bindVertexBuffersAttributes;
  88095. /**
  88096. * Records a vertex array object
  88097. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88098. * @param vertexBuffers defines the list of vertex buffers to store
  88099. * @param indexBuffer defines the index buffer to store
  88100. * @param effect defines the effect to store
  88101. * @returns the new vertex array object
  88102. */
  88103. recordVertexArrayObject(vertexBuffers: {
  88104. [key: string]: VertexBuffer;
  88105. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88106. /**
  88107. * Bind a specific vertex array object
  88108. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88109. * @param vertexArrayObject defines the vertex array object to bind
  88110. * @param indexBuffer defines the index buffer to bind
  88111. */
  88112. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88113. /**
  88114. * Bind webGl buffers directly to the webGL context
  88115. * @param vertexBuffer defines the vertex buffer to bind
  88116. * @param indexBuffer defines the index buffer to bind
  88117. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88118. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88119. * @param effect defines the effect associated with the vertex buffer
  88120. */
  88121. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88122. private _unbindVertexArrayObject;
  88123. /**
  88124. * Bind a list of vertex buffers to the webGL context
  88125. * @param vertexBuffers defines the list of vertex buffers to bind
  88126. * @param indexBuffer defines the index buffer to bind
  88127. * @param effect defines the effect associated with the vertex buffers
  88128. */
  88129. bindBuffers(vertexBuffers: {
  88130. [key: string]: Nullable<VertexBuffer>;
  88131. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88132. /**
  88133. * Unbind all instance attributes
  88134. */
  88135. unbindInstanceAttributes(): void;
  88136. /**
  88137. * Release and free the memory of a vertex array object
  88138. * @param vao defines the vertex array object to delete
  88139. */
  88140. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88141. /** @hidden */
  88142. _releaseBuffer(buffer: DataBuffer): boolean;
  88143. /**
  88144. * Creates a webGL buffer to use with instanciation
  88145. * @param capacity defines the size of the buffer
  88146. * @returns the webGL buffer
  88147. */
  88148. createInstancesBuffer(capacity: number): DataBuffer;
  88149. /**
  88150. * Delete a webGL buffer used with instanciation
  88151. * @param buffer defines the webGL buffer to delete
  88152. */
  88153. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88154. /**
  88155. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88156. * @param instancesBuffer defines the webGL buffer to update and bind
  88157. * @param data defines the data to store in the buffer
  88158. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88159. */
  88160. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88161. /**
  88162. * Apply all cached states (depth, culling, stencil and alpha)
  88163. */
  88164. applyStates(): void;
  88165. /**
  88166. * Send a draw order
  88167. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88168. * @param indexStart defines the starting index
  88169. * @param indexCount defines the number of index to draw
  88170. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88171. */
  88172. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88173. /**
  88174. * Draw a list of points
  88175. * @param verticesStart defines the index of first vertex to draw
  88176. * @param verticesCount defines the count of vertices to draw
  88177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88178. */
  88179. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88180. /**
  88181. * Draw a list of unindexed primitives
  88182. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88183. * @param verticesStart defines the index of first vertex to draw
  88184. * @param verticesCount defines the count of vertices to draw
  88185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88186. */
  88187. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88188. /**
  88189. * Draw a list of indexed primitives
  88190. * @param fillMode defines the primitive to use
  88191. * @param indexStart defines the starting index
  88192. * @param indexCount defines the number of index to draw
  88193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88194. */
  88195. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88196. /**
  88197. * Draw a list of unindexed primitives
  88198. * @param fillMode defines the primitive to use
  88199. * @param verticesStart defines the index of first vertex to draw
  88200. * @param verticesCount defines the count of vertices to draw
  88201. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88202. */
  88203. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88204. private _drawMode;
  88205. /** @hidden */
  88206. _releaseEffect(effect: Effect): void;
  88207. /** @hidden */
  88208. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88209. /**
  88210. * Create a new effect (used to store vertex/fragment shaders)
  88211. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88212. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88213. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88214. * @param samplers defines an array of string used to represent textures
  88215. * @param defines defines the string containing the defines to use to compile the shaders
  88216. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88217. * @param onCompiled defines a function to call when the effect creation is successful
  88218. * @param onError defines a function to call when the effect creation has failed
  88219. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88220. * @returns the new Effect
  88221. */
  88222. 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;
  88223. private _compileShader;
  88224. private _compileRawShader;
  88225. /**
  88226. * Directly creates a webGL program
  88227. * @param pipelineContext defines the pipeline context to attach to
  88228. * @param vertexCode defines the vertex shader code to use
  88229. * @param fragmentCode defines the fragment shader code to use
  88230. * @param context defines the webGL context to use (if not set, the current one will be used)
  88231. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88232. * @returns the new webGL program
  88233. */
  88234. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88235. /**
  88236. * Creates a webGL program
  88237. * @param pipelineContext defines the pipeline context to attach to
  88238. * @param vertexCode defines the vertex shader code to use
  88239. * @param fragmentCode defines the fragment shader code to use
  88240. * @param defines defines the string containing the defines to use to compile the shaders
  88241. * @param context defines the webGL context to use (if not set, the current one will be used)
  88242. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88243. * @returns the new webGL program
  88244. */
  88245. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88246. /**
  88247. * Creates a new pipeline context
  88248. * @returns the new pipeline
  88249. */
  88250. createPipelineContext(): WebGLPipelineContext;
  88251. private _createShaderProgram;
  88252. private _finalizePipelineContext;
  88253. /** @hidden */
  88254. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88255. /** @hidden */
  88256. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88257. /** @hidden */
  88258. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88259. /**
  88260. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88261. * @param pipelineContext defines the pipeline context to use
  88262. * @param uniformsNames defines the list of uniform names
  88263. * @returns an array of webGL uniform locations
  88264. */
  88265. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88266. /**
  88267. * Gets the lsit of active attributes for a given webGL program
  88268. * @param pipelineContext defines the pipeline context to use
  88269. * @param attributesNames defines the list of attribute names to get
  88270. * @returns an array of indices indicating the offset of each attribute
  88271. */
  88272. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88273. /**
  88274. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88275. * @param effect defines the effect to activate
  88276. */
  88277. enableEffect(effect: Nullable<Effect>): void;
  88278. /**
  88279. * Set the value of an uniform to an array of int32
  88280. * @param uniform defines the webGL uniform location where to store the value
  88281. * @param array defines the array of int32 to store
  88282. */
  88283. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88284. /**
  88285. * Set the value of an uniform to an array of int32 (stored as vec2)
  88286. * @param uniform defines the webGL uniform location where to store the value
  88287. * @param array defines the array of int32 to store
  88288. */
  88289. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88290. /**
  88291. * Set the value of an uniform to an array of int32 (stored as vec3)
  88292. * @param uniform defines the webGL uniform location where to store the value
  88293. * @param array defines the array of int32 to store
  88294. */
  88295. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88296. /**
  88297. * Set the value of an uniform to an array of int32 (stored as vec4)
  88298. * @param uniform defines the webGL uniform location where to store the value
  88299. * @param array defines the array of int32 to store
  88300. */
  88301. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88302. /**
  88303. * Set the value of an uniform to an array of float32
  88304. * @param uniform defines the webGL uniform location where to store the value
  88305. * @param array defines the array of float32 to store
  88306. */
  88307. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88308. /**
  88309. * Set the value of an uniform to an array of float32 (stored as vec2)
  88310. * @param uniform defines the webGL uniform location where to store the value
  88311. * @param array defines the array of float32 to store
  88312. */
  88313. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88314. /**
  88315. * Set the value of an uniform to an array of float32 (stored as vec3)
  88316. * @param uniform defines the webGL uniform location where to store the value
  88317. * @param array defines the array of float32 to store
  88318. */
  88319. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88320. /**
  88321. * Set the value of an uniform to an array of float32 (stored as vec4)
  88322. * @param uniform defines the webGL uniform location where to store the value
  88323. * @param array defines the array of float32 to store
  88324. */
  88325. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88326. /**
  88327. * Set the value of an uniform to an array of number
  88328. * @param uniform defines the webGL uniform location where to store the value
  88329. * @param array defines the array of number to store
  88330. */
  88331. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88332. /**
  88333. * Set the value of an uniform to an array of number (stored as vec2)
  88334. * @param uniform defines the webGL uniform location where to store the value
  88335. * @param array defines the array of number to store
  88336. */
  88337. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88338. /**
  88339. * Set the value of an uniform to an array of number (stored as vec3)
  88340. * @param uniform defines the webGL uniform location where to store the value
  88341. * @param array defines the array of number to store
  88342. */
  88343. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88344. /**
  88345. * Set the value of an uniform to an array of number (stored as vec4)
  88346. * @param uniform defines the webGL uniform location where to store the value
  88347. * @param array defines the array of number to store
  88348. */
  88349. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88350. /**
  88351. * Set the value of an uniform to an array of float32 (stored as matrices)
  88352. * @param uniform defines the webGL uniform location where to store the value
  88353. * @param matrices defines the array of float32 to store
  88354. */
  88355. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88356. /**
  88357. * Set the value of an uniform to a matrix
  88358. * @param uniform defines the webGL uniform location where to store the value
  88359. * @param matrix defines the matrix to store
  88360. */
  88361. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88362. /**
  88363. * Set the value of an uniform to a matrix (3x3)
  88364. * @param uniform defines the webGL uniform location where to store the value
  88365. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88366. */
  88367. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88368. /**
  88369. * Set the value of an uniform to a matrix (2x2)
  88370. * @param uniform defines the webGL uniform location where to store the value
  88371. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88372. */
  88373. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88374. /**
  88375. * Set the value of an uniform to a number (int)
  88376. * @param uniform defines the webGL uniform location where to store the value
  88377. * @param value defines the int number to store
  88378. */
  88379. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88380. /**
  88381. * Set the value of an uniform to a number (float)
  88382. * @param uniform defines the webGL uniform location where to store the value
  88383. * @param value defines the float number to store
  88384. */
  88385. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88386. /**
  88387. * Set the value of an uniform to a vec2
  88388. * @param uniform defines the webGL uniform location where to store the value
  88389. * @param x defines the 1st component of the value
  88390. * @param y defines the 2nd component of the value
  88391. */
  88392. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88393. /**
  88394. * Set the value of an uniform to a vec3
  88395. * @param uniform defines the webGL uniform location where to store the value
  88396. * @param x defines the 1st component of the value
  88397. * @param y defines the 2nd component of the value
  88398. * @param z defines the 3rd component of the value
  88399. */
  88400. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88401. /**
  88402. * Set the value of an uniform to a boolean
  88403. * @param uniform defines the webGL uniform location where to store the value
  88404. * @param bool defines the boolean to store
  88405. */
  88406. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88407. /**
  88408. * Set the value of an uniform to a vec4
  88409. * @param uniform defines the webGL uniform location where to store the value
  88410. * @param x defines the 1st component of the value
  88411. * @param y defines the 2nd component of the value
  88412. * @param z defines the 3rd component of the value
  88413. * @param w defines the 4th component of the value
  88414. */
  88415. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88416. /**
  88417. * Set the value of an uniform to a Color3
  88418. * @param uniform defines the webGL uniform location where to store the value
  88419. * @param color3 defines the color to store
  88420. */
  88421. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88422. /**
  88423. * Set the value of an uniform to a Color3 and an alpha value
  88424. * @param uniform defines the webGL uniform location where to store the value
  88425. * @param color3 defines the color to store
  88426. * @param alpha defines the alpha component to store
  88427. */
  88428. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88429. /**
  88430. * Sets a Color4 on a uniform variable
  88431. * @param uniform defines the uniform location
  88432. * @param color4 defines the value to be set
  88433. */
  88434. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88435. /**
  88436. * Set various states to the webGL context
  88437. * @param culling defines backface culling state
  88438. * @param zOffset defines the value to apply to zOffset (0 by default)
  88439. * @param force defines if states must be applied even if cache is up to date
  88440. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88441. */
  88442. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88443. /**
  88444. * Set the z offset to apply to current rendering
  88445. * @param value defines the offset to apply
  88446. */
  88447. setZOffset(value: number): void;
  88448. /**
  88449. * Gets the current value of the zOffset
  88450. * @returns the current zOffset state
  88451. */
  88452. getZOffset(): number;
  88453. /**
  88454. * Enable or disable depth buffering
  88455. * @param enable defines the state to set
  88456. */
  88457. setDepthBuffer(enable: boolean): void;
  88458. /**
  88459. * Gets a boolean indicating if depth writing is enabled
  88460. * @returns the current depth writing state
  88461. */
  88462. getDepthWrite(): boolean;
  88463. /**
  88464. * Enable or disable depth writing
  88465. * @param enable defines the state to set
  88466. */
  88467. setDepthWrite(enable: boolean): void;
  88468. /**
  88469. * Enable or disable color writing
  88470. * @param enable defines the state to set
  88471. */
  88472. setColorWrite(enable: boolean): void;
  88473. /**
  88474. * Gets a boolean indicating if color writing is enabled
  88475. * @returns the current color writing state
  88476. */
  88477. getColorWrite(): boolean;
  88478. /**
  88479. * Sets alpha constants used by some alpha blending modes
  88480. * @param r defines the red component
  88481. * @param g defines the green component
  88482. * @param b defines the blue component
  88483. * @param a defines the alpha component
  88484. */
  88485. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88486. /**
  88487. * Sets the current alpha mode
  88488. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88489. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88490. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88491. */
  88492. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88493. /**
  88494. * Gets the current alpha mode
  88495. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88496. * @returns the current alpha mode
  88497. */
  88498. getAlphaMode(): number;
  88499. /**
  88500. * Clears the list of texture accessible through engine.
  88501. * This can help preventing texture load conflict due to name collision.
  88502. */
  88503. clearInternalTexturesCache(): void;
  88504. /**
  88505. * Force the entire cache to be cleared
  88506. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88507. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88508. */
  88509. wipeCaches(bruteForce?: boolean): void;
  88510. /**
  88511. * Set the compressed texture format to use, based on the formats you have, and the formats
  88512. * supported by the hardware / browser.
  88513. *
  88514. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88515. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88516. * to API arguments needed to compressed textures. This puts the burden on the container
  88517. * generator to house the arcane code for determining these for current & future formats.
  88518. *
  88519. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88520. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88521. *
  88522. * Note: The result of this call is not taken into account when a texture is base64.
  88523. *
  88524. * @param formatsAvailable defines the list of those format families you have created
  88525. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88526. *
  88527. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88528. * @returns The extension selected.
  88529. */
  88530. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88531. /** @hidden */
  88532. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88533. min: number;
  88534. mag: number;
  88535. };
  88536. /** @hidden */
  88537. _createTexture(): WebGLTexture;
  88538. /**
  88539. * Usually called from Texture.ts.
  88540. * Passed information to create a WebGLTexture
  88541. * @param urlArg defines a value which contains one of the following:
  88542. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88543. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88544. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88546. * @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)
  88547. * @param scene needed for loading to the correct scene
  88548. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88549. * @param onLoad optional callback to be called upon successful completion
  88550. * @param onError optional callback to be called upon failure
  88551. * @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
  88552. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88553. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88554. * @param forcedExtension defines the extension to use to pick the right loader
  88555. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88556. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88557. */
  88558. 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;
  88559. private _rescaleTexture;
  88560. private _unpackFlipYCached;
  88561. /**
  88562. * In case you are sharing the context with other applications, it might
  88563. * be interested to not cache the unpack flip y state to ensure a consistent
  88564. * value would be set.
  88565. */
  88566. enableUnpackFlipYCached: boolean;
  88567. /** @hidden */
  88568. _unpackFlipY(value: boolean): void;
  88569. /** @hidden */
  88570. _getUnpackAlignement(): number;
  88571. /**
  88572. * Creates a dynamic texture
  88573. * @param width defines the width of the texture
  88574. * @param height defines the height of the texture
  88575. * @param generateMipMaps defines if the engine should generate the mip levels
  88576. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88577. * @returns the dynamic texture inside an InternalTexture
  88578. */
  88579. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88580. /**
  88581. * Update the sampling mode of a given texture
  88582. * @param samplingMode defines the required sampling mode
  88583. * @param texture defines the texture to update
  88584. */
  88585. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88586. /**
  88587. * Update the content of a dynamic texture
  88588. * @param texture defines the texture to update
  88589. * @param canvas defines the canvas containing the source
  88590. * @param invertY defines if data must be stored with Y axis inverted
  88591. * @param premulAlpha defines if alpha is stored as premultiplied
  88592. * @param format defines the format of the data
  88593. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88594. */
  88595. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88596. /**
  88597. * Update a video texture
  88598. * @param texture defines the texture to update
  88599. * @param video defines the video element to use
  88600. * @param invertY defines if data must be stored with Y axis inverted
  88601. */
  88602. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88603. /**
  88604. * Updates a depth texture Comparison Mode and Function.
  88605. * If the comparison Function is equal to 0, the mode will be set to none.
  88606. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88607. * @param texture The texture to set the comparison function for
  88608. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88609. */
  88610. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88611. /** @hidden */
  88612. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88613. width: number;
  88614. height: number;
  88615. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88616. /**
  88617. * Creates a depth stencil texture.
  88618. * This is only available in WebGL 2 or with the depth texture extension available.
  88619. * @param size The size of face edge in the texture.
  88620. * @param options The options defining the texture.
  88621. * @returns The texture
  88622. */
  88623. createDepthStencilTexture(size: number | {
  88624. width: number;
  88625. height: number;
  88626. }, options: DepthTextureCreationOptions): InternalTexture;
  88627. /**
  88628. * Creates a depth stencil texture.
  88629. * This is only available in WebGL 2 or with the depth texture extension available.
  88630. * @param size The size of face edge in the texture.
  88631. * @param options The options defining the texture.
  88632. * @returns The texture
  88633. */
  88634. private _createDepthStencilTexture;
  88635. /**
  88636. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88637. * @param renderTarget The render target to set the frame buffer for
  88638. */
  88639. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88640. /**
  88641. * Creates a new render target texture
  88642. * @param size defines the size of the texture
  88643. * @param options defines the options used to create the texture
  88644. * @returns a new render target texture stored in an InternalTexture
  88645. */
  88646. createRenderTargetTexture(size: number | {
  88647. width: number;
  88648. height: number;
  88649. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88650. /** @hidden */
  88651. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88652. /**
  88653. * Updates the sample count of a render target texture
  88654. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88655. * @param texture defines the texture to update
  88656. * @param samples defines the sample count to set
  88657. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88658. */
  88659. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88660. /** @hidden */
  88661. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88662. /** @hidden */
  88663. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88664. /** @hidden */
  88665. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88666. /** @hidden */
  88667. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88668. /**
  88669. * @hidden
  88670. */
  88671. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88672. private _prepareWebGLTextureContinuation;
  88673. private _prepareWebGLTexture;
  88674. /** @hidden */
  88675. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88676. /** @hidden */
  88677. _releaseFramebufferObjects(texture: InternalTexture): void;
  88678. /** @hidden */
  88679. _releaseTexture(texture: InternalTexture): void;
  88680. private setProgram;
  88681. private _boundUniforms;
  88682. /**
  88683. * Binds an effect to the webGL context
  88684. * @param effect defines the effect to bind
  88685. */
  88686. bindSamplers(effect: Effect): void;
  88687. private _activateCurrentTexture;
  88688. /** @hidden */
  88689. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88690. /** @hidden */
  88691. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88692. /**
  88693. * Sets a texture to the webGL context from a postprocess
  88694. * @param channel defines the channel to use
  88695. * @param postProcess defines the source postprocess
  88696. */
  88697. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88698. /**
  88699. * Binds the output of the passed in post process to the texture channel specified
  88700. * @param channel The channel the texture should be bound to
  88701. * @param postProcess The post process which's output should be bound
  88702. */
  88703. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88704. /**
  88705. * Unbind all textures from the webGL context
  88706. */
  88707. unbindAllTextures(): void;
  88708. /**
  88709. * Sets a texture to the according uniform.
  88710. * @param channel The texture channel
  88711. * @param uniform The uniform to set
  88712. * @param texture The texture to apply
  88713. */
  88714. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88715. /**
  88716. * Sets a depth stencil texture from a render target to the according uniform.
  88717. * @param channel The texture channel
  88718. * @param uniform The uniform to set
  88719. * @param texture The render target texture containing the depth stencil texture to apply
  88720. */
  88721. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88722. private _bindSamplerUniformToChannel;
  88723. private _getTextureWrapMode;
  88724. private _setTexture;
  88725. /**
  88726. * Sets an array of texture to the webGL context
  88727. * @param channel defines the channel where the texture array must be set
  88728. * @param uniform defines the associated uniform location
  88729. * @param textures defines the array of textures to bind
  88730. */
  88731. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88732. /** @hidden */
  88733. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88734. private _setTextureParameterFloat;
  88735. private _setTextureParameterInteger;
  88736. /**
  88737. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88738. * @param x defines the x coordinate of the rectangle where pixels must be read
  88739. * @param y defines the y coordinate of the rectangle where pixels must be read
  88740. * @param width defines the width of the rectangle where pixels must be read
  88741. * @param height defines the height of the rectangle where pixels must be read
  88742. * @returns a Uint8Array containing RGBA colors
  88743. */
  88744. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88745. /**
  88746. * Add an externaly attached data from its key.
  88747. * This method call will fail and return false, if such key already exists.
  88748. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88749. * @param key the unique key that identifies the data
  88750. * @param data the data object to associate to the key for this Engine instance
  88751. * @return true if no such key were already present and the data was added successfully, false otherwise
  88752. */
  88753. addExternalData<T>(key: string, data: T): boolean;
  88754. /**
  88755. * Get an externaly attached data from its key
  88756. * @param key the unique key that identifies the data
  88757. * @return the associated data, if present (can be null), or undefined if not present
  88758. */
  88759. getExternalData<T>(key: string): T;
  88760. /**
  88761. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88762. * @param key the unique key that identifies the data
  88763. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88764. * @return the associated data, can be null if the factory returned null.
  88765. */
  88766. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88767. /**
  88768. * Remove an externaly attached data from the Engine instance
  88769. * @param key the unique key that identifies the data
  88770. * @return true if the data was successfully removed, false if it doesn't exist
  88771. */
  88772. removeExternalData(key: string): boolean;
  88773. /**
  88774. * Unbind all vertex attributes from the webGL context
  88775. */
  88776. unbindAllAttributes(): void;
  88777. /**
  88778. * 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
  88779. */
  88780. releaseEffects(): void;
  88781. /**
  88782. * Dispose and release all associated resources
  88783. */
  88784. dispose(): void;
  88785. /**
  88786. * Display the loading screen
  88787. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88788. */
  88789. displayLoadingUI(): void;
  88790. /**
  88791. * Hide the loading screen
  88792. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88793. */
  88794. hideLoadingUI(): void;
  88795. /**
  88796. * Gets the current loading screen object
  88797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88798. */
  88799. /**
  88800. * Sets the current loading screen object
  88801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88802. */
  88803. loadingScreen: ILoadingScreen;
  88804. /**
  88805. * Sets the current loading screen text
  88806. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88807. */
  88808. loadingUIText: string;
  88809. /**
  88810. * Sets the current loading screen background color
  88811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88812. */
  88813. loadingUIBackgroundColor: string;
  88814. /**
  88815. * Attach a new callback raised when context lost event is fired
  88816. * @param callback defines the callback to call
  88817. */
  88818. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88819. /**
  88820. * Attach a new callback raised when context restored event is fired
  88821. * @param callback defines the callback to call
  88822. */
  88823. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88824. /**
  88825. * Gets the source code of the vertex shader associated with a specific webGL program
  88826. * @param program defines the program to use
  88827. * @returns a string containing the source code of the vertex shader associated with the program
  88828. */
  88829. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88830. /**
  88831. * Gets the source code of the fragment shader associated with a specific webGL program
  88832. * @param program defines the program to use
  88833. * @returns a string containing the source code of the fragment shader associated with the program
  88834. */
  88835. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88836. /**
  88837. * Get the current error code of the webGL context
  88838. * @returns the error code
  88839. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88840. */
  88841. getError(): number;
  88842. /**
  88843. * Gets the current framerate
  88844. * @returns a number representing the framerate
  88845. */
  88846. getFps(): number;
  88847. /**
  88848. * Gets the time spent between current and previous frame
  88849. * @returns a number representing the delta time in ms
  88850. */
  88851. getDeltaTime(): number;
  88852. private _measureFps;
  88853. /** @hidden */
  88854. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88855. private _canRenderToFloatFramebuffer;
  88856. private _canRenderToHalfFloatFramebuffer;
  88857. private _canRenderToFramebuffer;
  88858. /** @hidden */
  88859. _getWebGLTextureType(type: number): number;
  88860. /** @hidden */
  88861. _getInternalFormat(format: number): number;
  88862. /** @hidden */
  88863. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88864. /** @hidden */
  88865. _getRGBAMultiSampleBufferFormat(type: number): number;
  88866. /** @hidden */
  88867. _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;
  88868. /** @hidden */
  88869. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88870. /**
  88871. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88872. * @returns true if the engine can be created
  88873. * @ignorenaming
  88874. */
  88875. static isSupported(): boolean;
  88876. }
  88877. }
  88878. declare module BABYLON {
  88879. /**
  88880. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88881. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88882. */
  88883. export class EffectFallbacks {
  88884. private _defines;
  88885. private _currentRank;
  88886. private _maxRank;
  88887. private _mesh;
  88888. /**
  88889. * Removes the fallback from the bound mesh.
  88890. */
  88891. unBindMesh(): void;
  88892. /**
  88893. * Adds a fallback on the specified property.
  88894. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88895. * @param define The name of the define in the shader
  88896. */
  88897. addFallback(rank: number, define: string): void;
  88898. /**
  88899. * Sets the mesh to use CPU skinning when needing to fallback.
  88900. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88901. * @param mesh The mesh to use the fallbacks.
  88902. */
  88903. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88904. /**
  88905. * Checks to see if more fallbacks are still availible.
  88906. */
  88907. readonly isMoreFallbacks: boolean;
  88908. /**
  88909. * Removes the defines that shoould be removed when falling back.
  88910. * @param currentDefines defines the current define statements for the shader.
  88911. * @param effect defines the current effect we try to compile
  88912. * @returns The resulting defines with defines of the current rank removed.
  88913. */
  88914. reduce(currentDefines: string, effect: Effect): string;
  88915. }
  88916. /**
  88917. * Options to be used when creating an effect.
  88918. */
  88919. export class EffectCreationOptions {
  88920. /**
  88921. * Atrributes that will be used in the shader.
  88922. */
  88923. attributes: string[];
  88924. /**
  88925. * Uniform varible names that will be set in the shader.
  88926. */
  88927. uniformsNames: string[];
  88928. /**
  88929. * Uniform buffer varible names that will be set in the shader.
  88930. */
  88931. uniformBuffersNames: string[];
  88932. /**
  88933. * Sampler texture variable names that will be set in the shader.
  88934. */
  88935. samplers: string[];
  88936. /**
  88937. * Define statements that will be set in the shader.
  88938. */
  88939. defines: any;
  88940. /**
  88941. * Possible fallbacks for this effect to improve performance when needed.
  88942. */
  88943. fallbacks: Nullable<EffectFallbacks>;
  88944. /**
  88945. * Callback that will be called when the shader is compiled.
  88946. */
  88947. onCompiled: Nullable<(effect: Effect) => void>;
  88948. /**
  88949. * Callback that will be called if an error occurs during shader compilation.
  88950. */
  88951. onError: Nullable<(effect: Effect, errors: string) => void>;
  88952. /**
  88953. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88954. */
  88955. indexParameters: any;
  88956. /**
  88957. * Max number of lights that can be used in the shader.
  88958. */
  88959. maxSimultaneousLights: number;
  88960. /**
  88961. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88962. */
  88963. transformFeedbackVaryings: Nullable<string[]>;
  88964. }
  88965. /**
  88966. * Effect containing vertex and fragment shader that can be executed on an object.
  88967. */
  88968. export class Effect implements IDisposable {
  88969. /**
  88970. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88971. */
  88972. static ShadersRepository: string;
  88973. /**
  88974. * Name of the effect.
  88975. */
  88976. name: any;
  88977. /**
  88978. * String container all the define statements that should be set on the shader.
  88979. */
  88980. defines: string;
  88981. /**
  88982. * Callback that will be called when the shader is compiled.
  88983. */
  88984. onCompiled: Nullable<(effect: Effect) => void>;
  88985. /**
  88986. * Callback that will be called if an error occurs during shader compilation.
  88987. */
  88988. onError: Nullable<(effect: Effect, errors: string) => void>;
  88989. /**
  88990. * Callback that will be called when effect is bound.
  88991. */
  88992. onBind: Nullable<(effect: Effect) => void>;
  88993. /**
  88994. * Unique ID of the effect.
  88995. */
  88996. uniqueId: number;
  88997. /**
  88998. * Observable that will be called when the shader is compiled.
  88999. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89000. */
  89001. onCompileObservable: Observable<Effect>;
  89002. /**
  89003. * Observable that will be called if an error occurs during shader compilation.
  89004. */
  89005. onErrorObservable: Observable<Effect>;
  89006. /** @hidden */
  89007. _onBindObservable: Nullable<Observable<Effect>>;
  89008. /**
  89009. * Observable that will be called when effect is bound.
  89010. */
  89011. readonly onBindObservable: Observable<Effect>;
  89012. /** @hidden */
  89013. _bonesComputationForcedToCPU: boolean;
  89014. private static _uniqueIdSeed;
  89015. private _engine;
  89016. private _uniformBuffersNames;
  89017. private _uniformsNames;
  89018. private _samplerList;
  89019. private _samplers;
  89020. private _isReady;
  89021. private _compilationError;
  89022. private _attributesNames;
  89023. private _attributes;
  89024. private _uniforms;
  89025. /**
  89026. * Key for the effect.
  89027. * @hidden
  89028. */
  89029. _key: string;
  89030. private _indexParameters;
  89031. private _fallbacks;
  89032. private _vertexSourceCode;
  89033. private _fragmentSourceCode;
  89034. private _vertexSourceCodeOverride;
  89035. private _fragmentSourceCodeOverride;
  89036. private _transformFeedbackVaryings;
  89037. /**
  89038. * Compiled shader to webGL program.
  89039. * @hidden
  89040. */
  89041. _pipelineContext: IPipelineContext;
  89042. private _valueCache;
  89043. private static _baseCache;
  89044. /**
  89045. * Instantiates an effect.
  89046. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89047. * @param baseName Name of the effect.
  89048. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89049. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89050. * @param samplers List of sampler variables that will be passed to the shader.
  89051. * @param engine Engine to be used to render the effect
  89052. * @param defines Define statements to be added to the shader.
  89053. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89054. * @param onCompiled Callback that will be called when the shader is compiled.
  89055. * @param onError Callback that will be called if an error occurs during shader compilation.
  89056. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89057. */
  89058. 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);
  89059. /**
  89060. * Unique key for this effect
  89061. */
  89062. readonly key: string;
  89063. /**
  89064. * If the effect has been compiled and prepared.
  89065. * @returns if the effect is compiled and prepared.
  89066. */
  89067. isReady(): boolean;
  89068. /**
  89069. * The engine the effect was initialized with.
  89070. * @returns the engine.
  89071. */
  89072. getEngine(): Engine;
  89073. /**
  89074. * The pipeline context for this effect
  89075. * @returns the associated pipeline context
  89076. */
  89077. getPipelineContext(): IPipelineContext;
  89078. /**
  89079. * The set of names of attribute variables for the shader.
  89080. * @returns An array of attribute names.
  89081. */
  89082. getAttributesNames(): string[];
  89083. /**
  89084. * Returns the attribute at the given index.
  89085. * @param index The index of the attribute.
  89086. * @returns The location of the attribute.
  89087. */
  89088. getAttributeLocation(index: number): number;
  89089. /**
  89090. * Returns the attribute based on the name of the variable.
  89091. * @param name of the attribute to look up.
  89092. * @returns the attribute location.
  89093. */
  89094. getAttributeLocationByName(name: string): number;
  89095. /**
  89096. * The number of attributes.
  89097. * @returns the numnber of attributes.
  89098. */
  89099. getAttributesCount(): number;
  89100. /**
  89101. * Gets the index of a uniform variable.
  89102. * @param uniformName of the uniform to look up.
  89103. * @returns the index.
  89104. */
  89105. getUniformIndex(uniformName: string): number;
  89106. /**
  89107. * Returns the attribute based on the name of the variable.
  89108. * @param uniformName of the uniform to look up.
  89109. * @returns the location of the uniform.
  89110. */
  89111. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89112. /**
  89113. * Returns an array of sampler variable names
  89114. * @returns The array of sampler variable neames.
  89115. */
  89116. getSamplers(): string[];
  89117. /**
  89118. * The error from the last compilation.
  89119. * @returns the error string.
  89120. */
  89121. getCompilationError(): string;
  89122. /**
  89123. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89124. * @param func The callback to be used.
  89125. */
  89126. executeWhenCompiled(func: (effect: Effect) => void): void;
  89127. private _checkIsReady;
  89128. /** @hidden */
  89129. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89130. /** @hidden */
  89131. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89132. /** @hidden */
  89133. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89134. private _processShaderConversion;
  89135. private _processIncludes;
  89136. private _processPrecision;
  89137. /**
  89138. * Recompiles the webGL program
  89139. * @param vertexSourceCode The source code for the vertex shader.
  89140. * @param fragmentSourceCode The source code for the fragment shader.
  89141. * @param onCompiled Callback called when completed.
  89142. * @param onError Callback called on error.
  89143. * @hidden
  89144. */
  89145. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89146. /**
  89147. * Prepares the effect
  89148. * @hidden
  89149. */
  89150. _prepareEffect(): void;
  89151. /**
  89152. * Checks if the effect is supported. (Must be called after compilation)
  89153. */
  89154. readonly isSupported: boolean;
  89155. /**
  89156. * Binds a texture to the engine to be used as output of the shader.
  89157. * @param channel Name of the output variable.
  89158. * @param texture Texture to bind.
  89159. * @hidden
  89160. */
  89161. _bindTexture(channel: string, texture: InternalTexture): void;
  89162. /**
  89163. * Sets a texture on the engine to be used in the shader.
  89164. * @param channel Name of the sampler variable.
  89165. * @param texture Texture to set.
  89166. */
  89167. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89168. /**
  89169. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89170. * @param channel Name of the sampler variable.
  89171. * @param texture Texture to set.
  89172. */
  89173. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89174. /**
  89175. * Sets an array of textures on the engine to be used in the shader.
  89176. * @param channel Name of the variable.
  89177. * @param textures Textures to set.
  89178. */
  89179. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89180. /**
  89181. * 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)
  89182. * @param channel Name of the sampler variable.
  89183. * @param postProcess Post process to get the input texture from.
  89184. */
  89185. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89186. /**
  89187. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89188. * 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)
  89189. * @param channel Name of the sampler variable.
  89190. * @param postProcess Post process to get the output texture from.
  89191. */
  89192. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89193. /** @hidden */
  89194. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89195. /** @hidden */
  89196. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89197. /** @hidden */
  89198. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89199. /** @hidden */
  89200. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89201. /**
  89202. * Binds a buffer to a uniform.
  89203. * @param buffer Buffer to bind.
  89204. * @param name Name of the uniform variable to bind to.
  89205. */
  89206. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89207. /**
  89208. * Binds block to a uniform.
  89209. * @param blockName Name of the block to bind.
  89210. * @param index Index to bind.
  89211. */
  89212. bindUniformBlock(blockName: string, index: number): void;
  89213. /**
  89214. * Sets an interger value on a uniform variable.
  89215. * @param uniformName Name of the variable.
  89216. * @param value Value to be set.
  89217. * @returns this effect.
  89218. */
  89219. setInt(uniformName: string, value: number): Effect;
  89220. /**
  89221. * Sets an int array on a uniform variable.
  89222. * @param uniformName Name of the variable.
  89223. * @param array array to be set.
  89224. * @returns this effect.
  89225. */
  89226. setIntArray(uniformName: string, array: Int32Array): Effect;
  89227. /**
  89228. * 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)
  89229. * @param uniformName Name of the variable.
  89230. * @param array array to be set.
  89231. * @returns this effect.
  89232. */
  89233. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89234. /**
  89235. * 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)
  89236. * @param uniformName Name of the variable.
  89237. * @param array array to be set.
  89238. * @returns this effect.
  89239. */
  89240. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89241. /**
  89242. * 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)
  89243. * @param uniformName Name of the variable.
  89244. * @param array array to be set.
  89245. * @returns this effect.
  89246. */
  89247. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89248. /**
  89249. * Sets an float array on a uniform variable.
  89250. * @param uniformName Name of the variable.
  89251. * @param array array to be set.
  89252. * @returns this effect.
  89253. */
  89254. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89255. /**
  89256. * 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)
  89257. * @param uniformName Name of the variable.
  89258. * @param array array to be set.
  89259. * @returns this effect.
  89260. */
  89261. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89262. /**
  89263. * 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)
  89264. * @param uniformName Name of the variable.
  89265. * @param array array to be set.
  89266. * @returns this effect.
  89267. */
  89268. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89269. /**
  89270. * 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)
  89271. * @param uniformName Name of the variable.
  89272. * @param array array to be set.
  89273. * @returns this effect.
  89274. */
  89275. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89276. /**
  89277. * Sets an array on a uniform variable.
  89278. * @param uniformName Name of the variable.
  89279. * @param array array to be set.
  89280. * @returns this effect.
  89281. */
  89282. setArray(uniformName: string, array: number[]): Effect;
  89283. /**
  89284. * 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)
  89285. * @param uniformName Name of the variable.
  89286. * @param array array to be set.
  89287. * @returns this effect.
  89288. */
  89289. setArray2(uniformName: string, array: number[]): Effect;
  89290. /**
  89291. * 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)
  89292. * @param uniformName Name of the variable.
  89293. * @param array array to be set.
  89294. * @returns this effect.
  89295. */
  89296. setArray3(uniformName: string, array: number[]): Effect;
  89297. /**
  89298. * 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)
  89299. * @param uniformName Name of the variable.
  89300. * @param array array to be set.
  89301. * @returns this effect.
  89302. */
  89303. setArray4(uniformName: string, array: number[]): Effect;
  89304. /**
  89305. * Sets matrices on a uniform variable.
  89306. * @param uniformName Name of the variable.
  89307. * @param matrices matrices to be set.
  89308. * @returns this effect.
  89309. */
  89310. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89311. /**
  89312. * Sets matrix on a uniform variable.
  89313. * @param uniformName Name of the variable.
  89314. * @param matrix matrix to be set.
  89315. * @returns this effect.
  89316. */
  89317. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89318. /**
  89319. * 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)
  89320. * @param uniformName Name of the variable.
  89321. * @param matrix matrix to be set.
  89322. * @returns this effect.
  89323. */
  89324. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89325. /**
  89326. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89327. * @param uniformName Name of the variable.
  89328. * @param matrix matrix to be set.
  89329. * @returns this effect.
  89330. */
  89331. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89332. /**
  89333. * Sets a float on a uniform variable.
  89334. * @param uniformName Name of the variable.
  89335. * @param value value to be set.
  89336. * @returns this effect.
  89337. */
  89338. setFloat(uniformName: string, value: number): Effect;
  89339. /**
  89340. * Sets a boolean on a uniform variable.
  89341. * @param uniformName Name of the variable.
  89342. * @param bool value to be set.
  89343. * @returns this effect.
  89344. */
  89345. setBool(uniformName: string, bool: boolean): Effect;
  89346. /**
  89347. * Sets a Vector2 on a uniform variable.
  89348. * @param uniformName Name of the variable.
  89349. * @param vector2 vector2 to be set.
  89350. * @returns this effect.
  89351. */
  89352. setVector2(uniformName: string, vector2: Vector2): Effect;
  89353. /**
  89354. * Sets a float2 on a uniform variable.
  89355. * @param uniformName Name of the variable.
  89356. * @param x First float in float2.
  89357. * @param y Second float in float2.
  89358. * @returns this effect.
  89359. */
  89360. setFloat2(uniformName: string, x: number, y: number): Effect;
  89361. /**
  89362. * Sets a Vector3 on a uniform variable.
  89363. * @param uniformName Name of the variable.
  89364. * @param vector3 Value to be set.
  89365. * @returns this effect.
  89366. */
  89367. setVector3(uniformName: string, vector3: Vector3): Effect;
  89368. /**
  89369. * Sets a float3 on a uniform variable.
  89370. * @param uniformName Name of the variable.
  89371. * @param x First float in float3.
  89372. * @param y Second float in float3.
  89373. * @param z Third float in float3.
  89374. * @returns this effect.
  89375. */
  89376. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89377. /**
  89378. * Sets a Vector4 on a uniform variable.
  89379. * @param uniformName Name of the variable.
  89380. * @param vector4 Value to be set.
  89381. * @returns this effect.
  89382. */
  89383. setVector4(uniformName: string, vector4: Vector4): Effect;
  89384. /**
  89385. * Sets a float4 on a uniform variable.
  89386. * @param uniformName Name of the variable.
  89387. * @param x First float in float4.
  89388. * @param y Second float in float4.
  89389. * @param z Third float in float4.
  89390. * @param w Fourth float in float4.
  89391. * @returns this effect.
  89392. */
  89393. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89394. /**
  89395. * Sets a Color3 on a uniform variable.
  89396. * @param uniformName Name of the variable.
  89397. * @param color3 Value to be set.
  89398. * @returns this effect.
  89399. */
  89400. setColor3(uniformName: string, color3: Color3): Effect;
  89401. /**
  89402. * Sets a Color4 on a uniform variable.
  89403. * @param uniformName Name of the variable.
  89404. * @param color3 Value to be set.
  89405. * @param alpha Alpha value to be set.
  89406. * @returns this effect.
  89407. */
  89408. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89409. /**
  89410. * Sets a Color4 on a uniform variable
  89411. * @param uniformName defines the name of the variable
  89412. * @param color4 defines the value to be set
  89413. * @returns this effect.
  89414. */
  89415. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89416. /** Release all associated resources */
  89417. dispose(): void;
  89418. /**
  89419. * This function will add a new shader to the shader store
  89420. * @param name the name of the shader
  89421. * @param pixelShader optional pixel shader content
  89422. * @param vertexShader optional vertex shader content
  89423. */
  89424. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89425. /**
  89426. * Store of each shader (The can be looked up using effect.key)
  89427. */
  89428. static ShadersStore: {
  89429. [key: string]: string;
  89430. };
  89431. /**
  89432. * Store of each included file for a shader (The can be looked up using effect.key)
  89433. */
  89434. static IncludesShadersStore: {
  89435. [key: string]: string;
  89436. };
  89437. /**
  89438. * Resets the cache of effects.
  89439. */
  89440. static ResetCache(): void;
  89441. }
  89442. }
  89443. declare module BABYLON {
  89444. /**
  89445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89447. * 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;
  89448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89449. */
  89450. export class ColorCurves {
  89451. private _dirty;
  89452. private _tempColor;
  89453. private _globalCurve;
  89454. private _highlightsCurve;
  89455. private _midtonesCurve;
  89456. private _shadowsCurve;
  89457. private _positiveCurve;
  89458. private _negativeCurve;
  89459. private _globalHue;
  89460. private _globalDensity;
  89461. private _globalSaturation;
  89462. private _globalExposure;
  89463. /**
  89464. * Gets the global Hue value.
  89465. * 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).
  89466. */
  89467. /**
  89468. * Sets the global Hue value.
  89469. * 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).
  89470. */
  89471. globalHue: number;
  89472. /**
  89473. * Gets the global Density value.
  89474. * 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.
  89475. * Values less than zero provide a filter of opposite hue.
  89476. */
  89477. /**
  89478. * Sets the global Density value.
  89479. * 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.
  89480. * Values less than zero provide a filter of opposite hue.
  89481. */
  89482. globalDensity: number;
  89483. /**
  89484. * Gets the global Saturation value.
  89485. * 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.
  89486. */
  89487. /**
  89488. * Sets the global Saturation value.
  89489. * 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.
  89490. */
  89491. globalSaturation: number;
  89492. /**
  89493. * Gets the global Exposure value.
  89494. * 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.
  89495. */
  89496. /**
  89497. * Sets the global Exposure value.
  89498. * 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.
  89499. */
  89500. globalExposure: number;
  89501. private _highlightsHue;
  89502. private _highlightsDensity;
  89503. private _highlightsSaturation;
  89504. private _highlightsExposure;
  89505. /**
  89506. * Gets the highlights Hue value.
  89507. * 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).
  89508. */
  89509. /**
  89510. * Sets the highlights Hue value.
  89511. * 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).
  89512. */
  89513. highlightsHue: number;
  89514. /**
  89515. * Gets the highlights Density value.
  89516. * 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.
  89517. * Values less than zero provide a filter of opposite hue.
  89518. */
  89519. /**
  89520. * Sets the highlights Density value.
  89521. * 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.
  89522. * Values less than zero provide a filter of opposite hue.
  89523. */
  89524. highlightsDensity: number;
  89525. /**
  89526. * Gets the highlights Saturation value.
  89527. * 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.
  89528. */
  89529. /**
  89530. * Sets the highlights Saturation value.
  89531. * 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.
  89532. */
  89533. highlightsSaturation: number;
  89534. /**
  89535. * Gets the highlights Exposure value.
  89536. * 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.
  89537. */
  89538. /**
  89539. * Sets the highlights Exposure value.
  89540. * 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.
  89541. */
  89542. highlightsExposure: number;
  89543. private _midtonesHue;
  89544. private _midtonesDensity;
  89545. private _midtonesSaturation;
  89546. private _midtonesExposure;
  89547. /**
  89548. * Gets the midtones Hue value.
  89549. * 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).
  89550. */
  89551. /**
  89552. * Sets the midtones Hue value.
  89553. * 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).
  89554. */
  89555. midtonesHue: number;
  89556. /**
  89557. * Gets the midtones Density value.
  89558. * 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.
  89559. * Values less than zero provide a filter of opposite hue.
  89560. */
  89561. /**
  89562. * Sets the midtones Density value.
  89563. * 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.
  89564. * Values less than zero provide a filter of opposite hue.
  89565. */
  89566. midtonesDensity: number;
  89567. /**
  89568. * Gets the midtones Saturation value.
  89569. * 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.
  89570. */
  89571. /**
  89572. * Sets the midtones Saturation value.
  89573. * 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.
  89574. */
  89575. midtonesSaturation: number;
  89576. /**
  89577. * Gets the midtones Exposure value.
  89578. * 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.
  89579. */
  89580. /**
  89581. * Sets the midtones Exposure value.
  89582. * 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.
  89583. */
  89584. midtonesExposure: number;
  89585. private _shadowsHue;
  89586. private _shadowsDensity;
  89587. private _shadowsSaturation;
  89588. private _shadowsExposure;
  89589. /**
  89590. * Gets the shadows Hue value.
  89591. * 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).
  89592. */
  89593. /**
  89594. * Sets the shadows Hue value.
  89595. * 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).
  89596. */
  89597. shadowsHue: number;
  89598. /**
  89599. * Gets the shadows Density value.
  89600. * 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.
  89601. * Values less than zero provide a filter of opposite hue.
  89602. */
  89603. /**
  89604. * Sets the shadows Density value.
  89605. * 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.
  89606. * Values less than zero provide a filter of opposite hue.
  89607. */
  89608. shadowsDensity: number;
  89609. /**
  89610. * Gets the shadows Saturation value.
  89611. * 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.
  89612. */
  89613. /**
  89614. * Sets the shadows Saturation value.
  89615. * 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.
  89616. */
  89617. shadowsSaturation: number;
  89618. /**
  89619. * Gets the shadows Exposure value.
  89620. * 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.
  89621. */
  89622. /**
  89623. * Sets the shadows Exposure value.
  89624. * 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.
  89625. */
  89626. shadowsExposure: number;
  89627. /**
  89628. * Returns the class name
  89629. * @returns The class name
  89630. */
  89631. getClassName(): string;
  89632. /**
  89633. * Binds the color curves to the shader.
  89634. * @param colorCurves The color curve to bind
  89635. * @param effect The effect to bind to
  89636. * @param positiveUniform The positive uniform shader parameter
  89637. * @param neutralUniform The neutral uniform shader parameter
  89638. * @param negativeUniform The negative uniform shader parameter
  89639. */
  89640. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89641. /**
  89642. * Prepare the list of uniforms associated with the ColorCurves effects.
  89643. * @param uniformsList The list of uniforms used in the effect
  89644. */
  89645. static PrepareUniforms(uniformsList: string[]): void;
  89646. /**
  89647. * Returns color grading data based on a hue, density, saturation and exposure value.
  89648. * @param filterHue The hue of the color filter.
  89649. * @param filterDensity The density of the color filter.
  89650. * @param saturation The saturation.
  89651. * @param exposure The exposure.
  89652. * @param result The result data container.
  89653. */
  89654. private getColorGradingDataToRef;
  89655. /**
  89656. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89657. * @param value The input slider value in range [-100,100].
  89658. * @returns Adjusted value.
  89659. */
  89660. private static applyColorGradingSliderNonlinear;
  89661. /**
  89662. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89663. * @param hue The hue (H) input.
  89664. * @param saturation The saturation (S) input.
  89665. * @param brightness The brightness (B) input.
  89666. * @result An RGBA color represented as Vector4.
  89667. */
  89668. private static fromHSBToRef;
  89669. /**
  89670. * Returns a value clamped between min and max
  89671. * @param value The value to clamp
  89672. * @param min The minimum of value
  89673. * @param max The maximum of value
  89674. * @returns The clamped value.
  89675. */
  89676. private static clamp;
  89677. /**
  89678. * Clones the current color curve instance.
  89679. * @return The cloned curves
  89680. */
  89681. clone(): ColorCurves;
  89682. /**
  89683. * Serializes the current color curve instance to a json representation.
  89684. * @return a JSON representation
  89685. */
  89686. serialize(): any;
  89687. /**
  89688. * Parses the color curve from a json representation.
  89689. * @param source the JSON source to parse
  89690. * @return The parsed curves
  89691. */
  89692. static Parse(source: any): ColorCurves;
  89693. }
  89694. }
  89695. declare module BABYLON {
  89696. /**
  89697. * Interface to follow in your material defines to integrate easily the
  89698. * Image proccessing functions.
  89699. * @hidden
  89700. */
  89701. export interface IImageProcessingConfigurationDefines {
  89702. IMAGEPROCESSING: boolean;
  89703. VIGNETTE: boolean;
  89704. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89705. VIGNETTEBLENDMODEOPAQUE: boolean;
  89706. TONEMAPPING: boolean;
  89707. TONEMAPPING_ACES: boolean;
  89708. CONTRAST: boolean;
  89709. EXPOSURE: boolean;
  89710. COLORCURVES: boolean;
  89711. COLORGRADING: boolean;
  89712. COLORGRADING3D: boolean;
  89713. SAMPLER3DGREENDEPTH: boolean;
  89714. SAMPLER3DBGRMAP: boolean;
  89715. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89716. }
  89717. /**
  89718. * @hidden
  89719. */
  89720. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89721. IMAGEPROCESSING: boolean;
  89722. VIGNETTE: boolean;
  89723. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89724. VIGNETTEBLENDMODEOPAQUE: boolean;
  89725. TONEMAPPING: boolean;
  89726. TONEMAPPING_ACES: boolean;
  89727. CONTRAST: boolean;
  89728. COLORCURVES: boolean;
  89729. COLORGRADING: boolean;
  89730. COLORGRADING3D: boolean;
  89731. SAMPLER3DGREENDEPTH: boolean;
  89732. SAMPLER3DBGRMAP: boolean;
  89733. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89734. EXPOSURE: boolean;
  89735. constructor();
  89736. }
  89737. /**
  89738. * This groups together the common properties used for image processing either in direct forward pass
  89739. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89740. * or not.
  89741. */
  89742. export class ImageProcessingConfiguration {
  89743. /**
  89744. * Default tone mapping applied in BabylonJS.
  89745. */
  89746. static readonly TONEMAPPING_STANDARD: number;
  89747. /**
  89748. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89749. * to other engines rendering to increase portability.
  89750. */
  89751. static readonly TONEMAPPING_ACES: number;
  89752. /**
  89753. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89754. */
  89755. colorCurves: Nullable<ColorCurves>;
  89756. private _colorCurvesEnabled;
  89757. /**
  89758. * Gets wether the color curves effect is enabled.
  89759. */
  89760. /**
  89761. * Sets wether the color curves effect is enabled.
  89762. */
  89763. colorCurvesEnabled: boolean;
  89764. private _colorGradingTexture;
  89765. /**
  89766. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89767. */
  89768. /**
  89769. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89770. */
  89771. colorGradingTexture: Nullable<BaseTexture>;
  89772. private _colorGradingEnabled;
  89773. /**
  89774. * Gets wether the color grading effect is enabled.
  89775. */
  89776. /**
  89777. * Sets wether the color grading effect is enabled.
  89778. */
  89779. colorGradingEnabled: boolean;
  89780. private _colorGradingWithGreenDepth;
  89781. /**
  89782. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89783. */
  89784. /**
  89785. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89786. */
  89787. colorGradingWithGreenDepth: boolean;
  89788. private _colorGradingBGR;
  89789. /**
  89790. * Gets wether the color grading texture contains BGR values.
  89791. */
  89792. /**
  89793. * Sets wether the color grading texture contains BGR values.
  89794. */
  89795. colorGradingBGR: boolean;
  89796. /** @hidden */
  89797. _exposure: number;
  89798. /**
  89799. * Gets the Exposure used in the effect.
  89800. */
  89801. /**
  89802. * Sets the Exposure used in the effect.
  89803. */
  89804. exposure: number;
  89805. private _toneMappingEnabled;
  89806. /**
  89807. * Gets wether the tone mapping effect is enabled.
  89808. */
  89809. /**
  89810. * Sets wether the tone mapping effect is enabled.
  89811. */
  89812. toneMappingEnabled: boolean;
  89813. private _toneMappingType;
  89814. /**
  89815. * Gets the type of tone mapping effect.
  89816. */
  89817. /**
  89818. * Sets the type of tone mapping effect used in BabylonJS.
  89819. */
  89820. toneMappingType: number;
  89821. protected _contrast: number;
  89822. /**
  89823. * Gets the contrast used in the effect.
  89824. */
  89825. /**
  89826. * Sets the contrast used in the effect.
  89827. */
  89828. contrast: number;
  89829. /**
  89830. * Vignette stretch size.
  89831. */
  89832. vignetteStretch: number;
  89833. /**
  89834. * Vignette centre X Offset.
  89835. */
  89836. vignetteCentreX: number;
  89837. /**
  89838. * Vignette centre Y Offset.
  89839. */
  89840. vignetteCentreY: number;
  89841. /**
  89842. * Vignette weight or intensity of the vignette effect.
  89843. */
  89844. vignetteWeight: number;
  89845. /**
  89846. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89847. * if vignetteEnabled is set to true.
  89848. */
  89849. vignetteColor: Color4;
  89850. /**
  89851. * Camera field of view used by the Vignette effect.
  89852. */
  89853. vignetteCameraFov: number;
  89854. private _vignetteBlendMode;
  89855. /**
  89856. * Gets the vignette blend mode allowing different kind of effect.
  89857. */
  89858. /**
  89859. * Sets the vignette blend mode allowing different kind of effect.
  89860. */
  89861. vignetteBlendMode: number;
  89862. private _vignetteEnabled;
  89863. /**
  89864. * Gets wether the vignette effect is enabled.
  89865. */
  89866. /**
  89867. * Sets wether the vignette effect is enabled.
  89868. */
  89869. vignetteEnabled: boolean;
  89870. private _applyByPostProcess;
  89871. /**
  89872. * Gets wether the image processing is applied through a post process or not.
  89873. */
  89874. /**
  89875. * Sets wether the image processing is applied through a post process or not.
  89876. */
  89877. applyByPostProcess: boolean;
  89878. private _isEnabled;
  89879. /**
  89880. * Gets wether the image processing is enabled or not.
  89881. */
  89882. /**
  89883. * Sets wether the image processing is enabled or not.
  89884. */
  89885. isEnabled: boolean;
  89886. /**
  89887. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89888. */
  89889. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89890. /**
  89891. * Method called each time the image processing information changes requires to recompile the effect.
  89892. */
  89893. protected _updateParameters(): void;
  89894. /**
  89895. * Gets the current class name.
  89896. * @return "ImageProcessingConfiguration"
  89897. */
  89898. getClassName(): string;
  89899. /**
  89900. * Prepare the list of uniforms associated with the Image Processing effects.
  89901. * @param uniforms The list of uniforms used in the effect
  89902. * @param defines the list of defines currently in use
  89903. */
  89904. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89905. /**
  89906. * Prepare the list of samplers associated with the Image Processing effects.
  89907. * @param samplersList The list of uniforms used in the effect
  89908. * @param defines the list of defines currently in use
  89909. */
  89910. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89911. /**
  89912. * Prepare the list of defines associated to the shader.
  89913. * @param defines the list of defines to complete
  89914. * @param forPostProcess Define if we are currently in post process mode or not
  89915. */
  89916. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89917. /**
  89918. * Returns true if all the image processing information are ready.
  89919. * @returns True if ready, otherwise, false
  89920. */
  89921. isReady(): boolean;
  89922. /**
  89923. * Binds the image processing to the shader.
  89924. * @param effect The effect to bind to
  89925. * @param aspectRatio Define the current aspect ratio of the effect
  89926. */
  89927. bind(effect: Effect, aspectRatio?: number): void;
  89928. /**
  89929. * Clones the current image processing instance.
  89930. * @return The cloned image processing
  89931. */
  89932. clone(): ImageProcessingConfiguration;
  89933. /**
  89934. * Serializes the current image processing instance to a json representation.
  89935. * @return a JSON representation
  89936. */
  89937. serialize(): any;
  89938. /**
  89939. * Parses the image processing from a json representation.
  89940. * @param source the JSON source to parse
  89941. * @return The parsed image processing
  89942. */
  89943. static Parse(source: any): ImageProcessingConfiguration;
  89944. private static _VIGNETTEMODE_MULTIPLY;
  89945. private static _VIGNETTEMODE_OPAQUE;
  89946. /**
  89947. * Used to apply the vignette as a mix with the pixel color.
  89948. */
  89949. static readonly VIGNETTEMODE_MULTIPLY: number;
  89950. /**
  89951. * Used to apply the vignette as a replacement of the pixel color.
  89952. */
  89953. static readonly VIGNETTEMODE_OPAQUE: number;
  89954. }
  89955. }
  89956. declare module BABYLON {
  89957. /**
  89958. * This represents all the required information to add a fresnel effect on a material:
  89959. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89960. */
  89961. export class FresnelParameters {
  89962. private _isEnabled;
  89963. /**
  89964. * Define if the fresnel effect is enable or not.
  89965. */
  89966. isEnabled: boolean;
  89967. /**
  89968. * Define the color used on edges (grazing angle)
  89969. */
  89970. leftColor: Color3;
  89971. /**
  89972. * Define the color used on center
  89973. */
  89974. rightColor: Color3;
  89975. /**
  89976. * Define bias applied to computed fresnel term
  89977. */
  89978. bias: number;
  89979. /**
  89980. * Defined the power exponent applied to fresnel term
  89981. */
  89982. power: number;
  89983. /**
  89984. * Clones the current fresnel and its valuues
  89985. * @returns a clone fresnel configuration
  89986. */
  89987. clone(): FresnelParameters;
  89988. /**
  89989. * Serializes the current fresnel parameters to a JSON representation.
  89990. * @return the JSON serialization
  89991. */
  89992. serialize(): any;
  89993. /**
  89994. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89995. * @param parsedFresnelParameters Define the JSON representation
  89996. * @returns the parsed parameters
  89997. */
  89998. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89999. }
  90000. }
  90001. declare module BABYLON {
  90002. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90003. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90004. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90005. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90006. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90007. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90008. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90009. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90010. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90011. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90012. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90013. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90014. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90015. /**
  90016. * Decorator used to define property that can be serialized as reference to a camera
  90017. * @param sourceName defines the name of the property to decorate
  90018. */
  90019. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90020. /**
  90021. * Class used to help serialization objects
  90022. */
  90023. export class SerializationHelper {
  90024. /** hidden */
  90025. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90026. /** hidden */
  90027. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90028. /** hidden */
  90029. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90030. /** hidden */
  90031. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90032. /**
  90033. * Appends the serialized animations from the source animations
  90034. * @param source Source containing the animations
  90035. * @param destination Target to store the animations
  90036. */
  90037. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90038. /**
  90039. * Static function used to serialized a specific entity
  90040. * @param entity defines the entity to serialize
  90041. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90042. * @returns a JSON compatible object representing the serialization of the entity
  90043. */
  90044. static Serialize<T>(entity: T, serializationObject?: any): any;
  90045. /**
  90046. * Creates a new entity from a serialization data object
  90047. * @param creationFunction defines a function used to instanciated the new entity
  90048. * @param source defines the source serialization data
  90049. * @param scene defines the hosting scene
  90050. * @param rootUrl defines the root url for resources
  90051. * @returns a new entity
  90052. */
  90053. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90054. /**
  90055. * Clones an object
  90056. * @param creationFunction defines the function used to instanciate the new object
  90057. * @param source defines the source object
  90058. * @returns the cloned object
  90059. */
  90060. static Clone<T>(creationFunction: () => T, source: T): T;
  90061. /**
  90062. * Instanciates a new object based on a source one (some data will be shared between both object)
  90063. * @param creationFunction defines the function used to instanciate the new object
  90064. * @param source defines the source object
  90065. * @returns the new object
  90066. */
  90067. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90068. }
  90069. }
  90070. declare module BABYLON {
  90071. /**
  90072. * This is the base class of all the camera used in the application.
  90073. * @see http://doc.babylonjs.com/features/cameras
  90074. */
  90075. export class Camera extends Node {
  90076. /** @hidden */
  90077. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90078. /**
  90079. * This is the default projection mode used by the cameras.
  90080. * It helps recreating a feeling of perspective and better appreciate depth.
  90081. * This is the best way to simulate real life cameras.
  90082. */
  90083. static readonly PERSPECTIVE_CAMERA: number;
  90084. /**
  90085. * This helps creating camera with an orthographic mode.
  90086. * 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.
  90087. */
  90088. static readonly ORTHOGRAPHIC_CAMERA: number;
  90089. /**
  90090. * This is the default FOV mode for perspective cameras.
  90091. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90092. */
  90093. static readonly FOVMODE_VERTICAL_FIXED: number;
  90094. /**
  90095. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90096. */
  90097. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90098. /**
  90099. * This specifies ther is no need for a camera rig.
  90100. * Basically only one eye is rendered corresponding to the camera.
  90101. */
  90102. static readonly RIG_MODE_NONE: number;
  90103. /**
  90104. * Simulates a camera Rig with one blue eye and one red eye.
  90105. * This can be use with 3d blue and red glasses.
  90106. */
  90107. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90108. /**
  90109. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90110. */
  90111. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90112. /**
  90113. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90114. */
  90115. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90116. /**
  90117. * Defines that both eyes of the camera will be rendered over under each other.
  90118. */
  90119. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90120. /**
  90121. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90122. */
  90123. static readonly RIG_MODE_VR: number;
  90124. /**
  90125. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90126. */
  90127. static readonly RIG_MODE_WEBVR: number;
  90128. /**
  90129. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90130. */
  90131. static readonly RIG_MODE_CUSTOM: number;
  90132. /**
  90133. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90134. */
  90135. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90136. /**
  90137. * Define the input manager associated with the camera.
  90138. */
  90139. inputs: CameraInputsManager<Camera>;
  90140. /** @hidden */
  90141. _position: Vector3;
  90142. /**
  90143. * Define the current local position of the camera in the scene
  90144. */
  90145. position: Vector3;
  90146. /**
  90147. * The vector the camera should consider as up.
  90148. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90149. */
  90150. upVector: Vector3;
  90151. /**
  90152. * Define the current limit on the left side for an orthographic camera
  90153. * In scene unit
  90154. */
  90155. orthoLeft: Nullable<number>;
  90156. /**
  90157. * Define the current limit on the right side for an orthographic camera
  90158. * In scene unit
  90159. */
  90160. orthoRight: Nullable<number>;
  90161. /**
  90162. * Define the current limit on the bottom side for an orthographic camera
  90163. * In scene unit
  90164. */
  90165. orthoBottom: Nullable<number>;
  90166. /**
  90167. * Define the current limit on the top side for an orthographic camera
  90168. * In scene unit
  90169. */
  90170. orthoTop: Nullable<number>;
  90171. /**
  90172. * Field Of View is set in Radians. (default is 0.8)
  90173. */
  90174. fov: number;
  90175. /**
  90176. * Define the minimum distance the camera can see from.
  90177. * This is important to note that the depth buffer are not infinite and the closer it starts
  90178. * the more your scene might encounter depth fighting issue.
  90179. */
  90180. minZ: number;
  90181. /**
  90182. * Define the maximum distance the camera can see to.
  90183. * This is important to note that the depth buffer are not infinite and the further it end
  90184. * the more your scene might encounter depth fighting issue.
  90185. */
  90186. maxZ: number;
  90187. /**
  90188. * Define the default inertia of the camera.
  90189. * This helps giving a smooth feeling to the camera movement.
  90190. */
  90191. inertia: number;
  90192. /**
  90193. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90194. */
  90195. mode: number;
  90196. /**
  90197. * Define wether the camera is intermediate.
  90198. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90199. */
  90200. isIntermediate: boolean;
  90201. /**
  90202. * Define the viewport of the camera.
  90203. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90204. */
  90205. viewport: Viewport;
  90206. /**
  90207. * Restricts the camera to viewing objects with the same layerMask.
  90208. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90209. */
  90210. layerMask: number;
  90211. /**
  90212. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90213. */
  90214. fovMode: number;
  90215. /**
  90216. * Rig mode of the camera.
  90217. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90218. * This is normally controlled byt the camera themselves as internal use.
  90219. */
  90220. cameraRigMode: number;
  90221. /**
  90222. * Defines the distance between both "eyes" in case of a RIG
  90223. */
  90224. interaxialDistance: number;
  90225. /**
  90226. * Defines if stereoscopic rendering is done side by side or over under.
  90227. */
  90228. isStereoscopicSideBySide: boolean;
  90229. /**
  90230. * 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
  90231. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90232. * else in the scene.
  90233. */
  90234. customRenderTargets: RenderTargetTexture[];
  90235. /**
  90236. * When set, the camera will render to this render target instead of the default canvas
  90237. */
  90238. outputRenderTarget: Nullable<RenderTargetTexture>;
  90239. /**
  90240. * Observable triggered when the camera view matrix has changed.
  90241. */
  90242. onViewMatrixChangedObservable: Observable<Camera>;
  90243. /**
  90244. * Observable triggered when the camera Projection matrix has changed.
  90245. */
  90246. onProjectionMatrixChangedObservable: Observable<Camera>;
  90247. /**
  90248. * Observable triggered when the inputs have been processed.
  90249. */
  90250. onAfterCheckInputsObservable: Observable<Camera>;
  90251. /**
  90252. * Observable triggered when reset has been called and applied to the camera.
  90253. */
  90254. onRestoreStateObservable: Observable<Camera>;
  90255. /** @hidden */
  90256. _cameraRigParams: any;
  90257. /** @hidden */
  90258. _rigCameras: Camera[];
  90259. /** @hidden */
  90260. _rigPostProcess: Nullable<PostProcess>;
  90261. protected _webvrViewMatrix: Matrix;
  90262. /** @hidden */
  90263. _skipRendering: boolean;
  90264. /** @hidden */
  90265. _projectionMatrix: Matrix;
  90266. /** @hidden */
  90267. _postProcesses: Nullable<PostProcess>[];
  90268. /** @hidden */
  90269. _activeMeshes: SmartArray<AbstractMesh>;
  90270. protected _globalPosition: Vector3;
  90271. /** hidden */
  90272. _computedViewMatrix: Matrix;
  90273. private _doNotComputeProjectionMatrix;
  90274. private _transformMatrix;
  90275. private _frustumPlanes;
  90276. private _refreshFrustumPlanes;
  90277. private _storedFov;
  90278. private _stateStored;
  90279. /**
  90280. * Instantiates a new camera object.
  90281. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90282. * @see http://doc.babylonjs.com/features/cameras
  90283. * @param name Defines the name of the camera in the scene
  90284. * @param position Defines the position of the camera
  90285. * @param scene Defines the scene the camera belongs too
  90286. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90287. */
  90288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90289. /**
  90290. * Store current camera state (fov, position, etc..)
  90291. * @returns the camera
  90292. */
  90293. storeState(): Camera;
  90294. /**
  90295. * Restores the camera state values if it has been stored. You must call storeState() first
  90296. */
  90297. protected _restoreStateValues(): boolean;
  90298. /**
  90299. * Restored camera state. You must call storeState() first.
  90300. * @returns true if restored and false otherwise
  90301. */
  90302. restoreState(): boolean;
  90303. /**
  90304. * Gets the class name of the camera.
  90305. * @returns the class name
  90306. */
  90307. getClassName(): string;
  90308. /** @hidden */
  90309. readonly _isCamera: boolean;
  90310. /**
  90311. * Gets a string representation of the camera useful for debug purpose.
  90312. * @param fullDetails Defines that a more verboe level of logging is required
  90313. * @returns the string representation
  90314. */
  90315. toString(fullDetails?: boolean): string;
  90316. /**
  90317. * Gets the current world space position of the camera.
  90318. */
  90319. readonly globalPosition: Vector3;
  90320. /**
  90321. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90322. * @returns the active meshe list
  90323. */
  90324. getActiveMeshes(): SmartArray<AbstractMesh>;
  90325. /**
  90326. * Check wether a mesh is part of the current active mesh list of the camera
  90327. * @param mesh Defines the mesh to check
  90328. * @returns true if active, false otherwise
  90329. */
  90330. isActiveMesh(mesh: Mesh): boolean;
  90331. /**
  90332. * Is this camera ready to be used/rendered
  90333. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90334. * @return true if the camera is ready
  90335. */
  90336. isReady(completeCheck?: boolean): boolean;
  90337. /** @hidden */
  90338. _initCache(): void;
  90339. /** @hidden */
  90340. _updateCache(ignoreParentClass?: boolean): void;
  90341. /** @hidden */
  90342. _isSynchronized(): boolean;
  90343. /** @hidden */
  90344. _isSynchronizedViewMatrix(): boolean;
  90345. /** @hidden */
  90346. _isSynchronizedProjectionMatrix(): boolean;
  90347. /**
  90348. * Attach the input controls to a specific dom element to get the input from.
  90349. * @param element Defines the element the controls should be listened from
  90350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90351. */
  90352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90353. /**
  90354. * Detach the current controls from the specified dom element.
  90355. * @param element Defines the element to stop listening the inputs from
  90356. */
  90357. detachControl(element: HTMLElement): void;
  90358. /**
  90359. * Update the camera state according to the different inputs gathered during the frame.
  90360. */
  90361. update(): void;
  90362. /** @hidden */
  90363. _checkInputs(): void;
  90364. /** @hidden */
  90365. readonly rigCameras: Camera[];
  90366. /**
  90367. * Gets the post process used by the rig cameras
  90368. */
  90369. readonly rigPostProcess: Nullable<PostProcess>;
  90370. /**
  90371. * Internal, gets the first post proces.
  90372. * @returns the first post process to be run on this camera.
  90373. */
  90374. _getFirstPostProcess(): Nullable<PostProcess>;
  90375. private _cascadePostProcessesToRigCams;
  90376. /**
  90377. * Attach a post process to the camera.
  90378. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90379. * @param postProcess The post process to attach to the camera
  90380. * @param insertAt The position of the post process in case several of them are in use in the scene
  90381. * @returns the position the post process has been inserted at
  90382. */
  90383. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90384. /**
  90385. * Detach a post process to the camera.
  90386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90387. * @param postProcess The post process to detach from the camera
  90388. */
  90389. detachPostProcess(postProcess: PostProcess): void;
  90390. /**
  90391. * Gets the current world matrix of the camera
  90392. */
  90393. getWorldMatrix(): Matrix;
  90394. /** @hidden */
  90395. _getViewMatrix(): Matrix;
  90396. /**
  90397. * Gets the current view matrix of the camera.
  90398. * @param force forces the camera to recompute the matrix without looking at the cached state
  90399. * @returns the view matrix
  90400. */
  90401. getViewMatrix(force?: boolean): Matrix;
  90402. /**
  90403. * Freeze the projection matrix.
  90404. * It will prevent the cache check of the camera projection compute and can speed up perf
  90405. * if no parameter of the camera are meant to change
  90406. * @param projection Defines manually a projection if necessary
  90407. */
  90408. freezeProjectionMatrix(projection?: Matrix): void;
  90409. /**
  90410. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90411. */
  90412. unfreezeProjectionMatrix(): void;
  90413. /**
  90414. * Gets the current projection matrix of the camera.
  90415. * @param force forces the camera to recompute the matrix without looking at the cached state
  90416. * @returns the projection matrix
  90417. */
  90418. getProjectionMatrix(force?: boolean): Matrix;
  90419. /**
  90420. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90421. * @returns a Matrix
  90422. */
  90423. getTransformationMatrix(): Matrix;
  90424. private _updateFrustumPlanes;
  90425. /**
  90426. * Checks if a cullable object (mesh...) is in the camera frustum
  90427. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90428. * @param target The object to check
  90429. * @returns true if the object is in frustum otherwise false
  90430. */
  90431. isInFrustum(target: ICullable): boolean;
  90432. /**
  90433. * Checks if a cullable object (mesh...) is in the camera frustum
  90434. * Unlike isInFrustum this cheks the full bounding box
  90435. * @param target The object to check
  90436. * @returns true if the object is in frustum otherwise false
  90437. */
  90438. isCompletelyInFrustum(target: ICullable): boolean;
  90439. /**
  90440. * Gets a ray in the forward direction from the camera.
  90441. * @param length Defines the length of the ray to create
  90442. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90443. * @param origin Defines the start point of the ray which defaults to the camera position
  90444. * @returns the forward ray
  90445. */
  90446. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90447. /**
  90448. * Releases resources associated with this node.
  90449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90451. */
  90452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90453. /** @hidden */
  90454. _isLeftCamera: boolean;
  90455. /**
  90456. * Gets the left camera of a rig setup in case of Rigged Camera
  90457. */
  90458. readonly isLeftCamera: boolean;
  90459. /** @hidden */
  90460. _isRightCamera: boolean;
  90461. /**
  90462. * Gets the right camera of a rig setup in case of Rigged Camera
  90463. */
  90464. readonly isRightCamera: boolean;
  90465. /**
  90466. * Gets the left camera of a rig setup in case of Rigged Camera
  90467. */
  90468. readonly leftCamera: Nullable<FreeCamera>;
  90469. /**
  90470. * Gets the right camera of a rig setup in case of Rigged Camera
  90471. */
  90472. readonly rightCamera: Nullable<FreeCamera>;
  90473. /**
  90474. * Gets the left camera target of a rig setup in case of Rigged Camera
  90475. * @returns the target position
  90476. */
  90477. getLeftTarget(): Nullable<Vector3>;
  90478. /**
  90479. * Gets the right camera target of a rig setup in case of Rigged Camera
  90480. * @returns the target position
  90481. */
  90482. getRightTarget(): Nullable<Vector3>;
  90483. /**
  90484. * @hidden
  90485. */
  90486. setCameraRigMode(mode: number, rigParams: any): void;
  90487. /** @hidden */
  90488. static _setStereoscopicRigMode(camera: Camera): void;
  90489. /** @hidden */
  90490. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90491. /** @hidden */
  90492. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90493. /** @hidden */
  90494. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90495. /** @hidden */
  90496. _getVRProjectionMatrix(): Matrix;
  90497. protected _updateCameraRotationMatrix(): void;
  90498. protected _updateWebVRCameraRotationMatrix(): void;
  90499. /**
  90500. * This function MUST be overwritten by the different WebVR cameras available.
  90501. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90502. * @hidden
  90503. */
  90504. _getWebVRProjectionMatrix(): Matrix;
  90505. /**
  90506. * This function MUST be overwritten by the different WebVR cameras available.
  90507. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90508. * @hidden
  90509. */
  90510. _getWebVRViewMatrix(): Matrix;
  90511. /** @hidden */
  90512. setCameraRigParameter(name: string, value: any): void;
  90513. /**
  90514. * needs to be overridden by children so sub has required properties to be copied
  90515. * @hidden
  90516. */
  90517. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90518. /**
  90519. * May need to be overridden by children
  90520. * @hidden
  90521. */
  90522. _updateRigCameras(): void;
  90523. /** @hidden */
  90524. _setupInputs(): void;
  90525. /**
  90526. * Serialiaze the camera setup to a json represention
  90527. * @returns the JSON representation
  90528. */
  90529. serialize(): any;
  90530. /**
  90531. * Clones the current camera.
  90532. * @param name The cloned camera name
  90533. * @returns the cloned camera
  90534. */
  90535. clone(name: string): Camera;
  90536. /**
  90537. * Gets the direction of the camera relative to a given local axis.
  90538. * @param localAxis Defines the reference axis to provide a relative direction.
  90539. * @return the direction
  90540. */
  90541. getDirection(localAxis: Vector3): Vector3;
  90542. /**
  90543. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90544. * @param localAxis Defines the reference axis to provide a relative direction.
  90545. * @param result Defines the vector to store the result in
  90546. */
  90547. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90548. /**
  90549. * Gets a camera constructor for a given camera type
  90550. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90551. * @param name The name of the camera the result will be able to instantiate
  90552. * @param scene The scene the result will construct the camera in
  90553. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90554. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90555. * @returns a factory method to construc the camera
  90556. */
  90557. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90558. /**
  90559. * Compute the world matrix of the camera.
  90560. * @returns the camera workd matrix
  90561. */
  90562. computeWorldMatrix(): Matrix;
  90563. /**
  90564. * Parse a JSON and creates the camera from the parsed information
  90565. * @param parsedCamera The JSON to parse
  90566. * @param scene The scene to instantiate the camera in
  90567. * @returns the newly constructed camera
  90568. */
  90569. static Parse(parsedCamera: any, scene: Scene): Camera;
  90570. }
  90571. }
  90572. declare module BABYLON {
  90573. /**
  90574. * Interface for any object that can request an animation frame
  90575. */
  90576. export interface ICustomAnimationFrameRequester {
  90577. /**
  90578. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90579. */
  90580. renderFunction?: Function;
  90581. /**
  90582. * Called to request the next frame to render to
  90583. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90584. */
  90585. requestAnimationFrame: Function;
  90586. /**
  90587. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90588. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90589. */
  90590. requestID?: number;
  90591. }
  90592. /**
  90593. * Interface containing an array of animations
  90594. */
  90595. export interface IAnimatable {
  90596. /**
  90597. * Array of animations
  90598. */
  90599. animations: Nullable<Array<Animation>>;
  90600. }
  90601. /** Interface used by value gradients (color, factor, ...) */
  90602. export interface IValueGradient {
  90603. /**
  90604. * Gets or sets the gradient value (between 0 and 1)
  90605. */
  90606. gradient: number;
  90607. }
  90608. /** Class used to store color4 gradient */
  90609. export class ColorGradient implements IValueGradient {
  90610. /**
  90611. * Gets or sets the gradient value (between 0 and 1)
  90612. */
  90613. gradient: number;
  90614. /**
  90615. * Gets or sets first associated color
  90616. */
  90617. color1: Color4;
  90618. /**
  90619. * Gets or sets second associated color
  90620. */
  90621. color2?: Color4;
  90622. /**
  90623. * Will get a color picked randomly between color1 and color2.
  90624. * If color2 is undefined then color1 will be used
  90625. * @param result defines the target Color4 to store the result in
  90626. */
  90627. getColorToRef(result: Color4): void;
  90628. }
  90629. /** Class used to store color 3 gradient */
  90630. export class Color3Gradient implements IValueGradient {
  90631. /**
  90632. * Gets or sets the gradient value (between 0 and 1)
  90633. */
  90634. gradient: number;
  90635. /**
  90636. * Gets or sets the associated color
  90637. */
  90638. color: Color3;
  90639. }
  90640. /** Class used to store factor gradient */
  90641. export class FactorGradient implements IValueGradient {
  90642. /**
  90643. * Gets or sets the gradient value (between 0 and 1)
  90644. */
  90645. gradient: number;
  90646. /**
  90647. * Gets or sets first associated factor
  90648. */
  90649. factor1: number;
  90650. /**
  90651. * Gets or sets second associated factor
  90652. */
  90653. factor2?: number;
  90654. /**
  90655. * Will get a number picked randomly between factor1 and factor2.
  90656. * If factor2 is undefined then factor1 will be used
  90657. * @returns the picked number
  90658. */
  90659. getFactor(): number;
  90660. }
  90661. /**
  90662. * @ignore
  90663. * Application error to support additional information when loading a file
  90664. */
  90665. export class LoadFileError extends Error {
  90666. /** defines the optional web request */
  90667. request?: WebRequest | undefined;
  90668. private static _setPrototypeOf;
  90669. /**
  90670. * Creates a new LoadFileError
  90671. * @param message defines the message of the error
  90672. * @param request defines the optional web request
  90673. */
  90674. constructor(message: string,
  90675. /** defines the optional web request */
  90676. request?: WebRequest | undefined);
  90677. }
  90678. /**
  90679. * Class used to define a retry strategy when error happens while loading assets
  90680. */
  90681. export class RetryStrategy {
  90682. /**
  90683. * Function used to defines an exponential back off strategy
  90684. * @param maxRetries defines the maximum number of retries (3 by default)
  90685. * @param baseInterval defines the interval between retries
  90686. * @returns the strategy function to use
  90687. */
  90688. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90689. }
  90690. /**
  90691. * File request interface
  90692. */
  90693. export interface IFileRequest {
  90694. /**
  90695. * Raised when the request is complete (success or error).
  90696. */
  90697. onCompleteObservable: Observable<IFileRequest>;
  90698. /**
  90699. * Aborts the request for a file.
  90700. */
  90701. abort: () => void;
  90702. }
  90703. /**
  90704. * Class containing a set of static utilities functions
  90705. */
  90706. export class Tools {
  90707. /**
  90708. * Gets or sets the base URL to use to load assets
  90709. */
  90710. static BaseUrl: string;
  90711. /**
  90712. * Enable/Disable Custom HTTP Request Headers globally.
  90713. * default = false
  90714. * @see CustomRequestHeaders
  90715. */
  90716. static UseCustomRequestHeaders: boolean;
  90717. /**
  90718. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90719. * i.e. when loading files, where the server/service expects an Authorization header
  90720. */
  90721. static CustomRequestHeaders: {
  90722. [key: string]: string;
  90723. };
  90724. /**
  90725. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90726. */
  90727. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90728. /**
  90729. * Default behaviour for cors in the application.
  90730. * It can be a string if the expected behavior is identical in the entire app.
  90731. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90732. */
  90733. static CorsBehavior: string | ((url: string | string[]) => string);
  90734. /**
  90735. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90736. * @ignorenaming
  90737. */
  90738. static UseFallbackTexture: boolean;
  90739. /**
  90740. * Use this object to register external classes like custom textures or material
  90741. * to allow the laoders to instantiate them
  90742. */
  90743. static RegisteredExternalClasses: {
  90744. [key: string]: Object;
  90745. };
  90746. /**
  90747. * Texture content used if a texture cannot loaded
  90748. * @ignorenaming
  90749. */
  90750. static fallbackTexture: string;
  90751. /**
  90752. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90753. * @param u defines the coordinate on X axis
  90754. * @param v defines the coordinate on Y axis
  90755. * @param width defines the width of the source data
  90756. * @param height defines the height of the source data
  90757. * @param pixels defines the source byte array
  90758. * @param color defines the output color
  90759. */
  90760. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90761. /**
  90762. * Interpolates between a and b via alpha
  90763. * @param a The lower value (returned when alpha = 0)
  90764. * @param b The upper value (returned when alpha = 1)
  90765. * @param alpha The interpolation-factor
  90766. * @return The mixed value
  90767. */
  90768. static Mix(a: number, b: number, alpha: number): number;
  90769. /**
  90770. * Tries to instantiate a new object from a given class name
  90771. * @param className defines the class name to instantiate
  90772. * @returns the new object or null if the system was not able to do the instantiation
  90773. */
  90774. static Instantiate(className: string): any;
  90775. /**
  90776. * Provides a slice function that will work even on IE
  90777. * @param data defines the array to slice
  90778. * @param start defines the start of the data (optional)
  90779. * @param end defines the end of the data (optional)
  90780. * @returns the new sliced array
  90781. */
  90782. static Slice<T>(data: T, start?: number, end?: number): T;
  90783. /**
  90784. * Polyfill for setImmediate
  90785. * @param action defines the action to execute after the current execution block
  90786. */
  90787. static SetImmediate(action: () => void): void;
  90788. /**
  90789. * Function indicating if a number is an exponent of 2
  90790. * @param value defines the value to test
  90791. * @returns true if the value is an exponent of 2
  90792. */
  90793. static IsExponentOfTwo(value: number): boolean;
  90794. private static _tmpFloatArray;
  90795. /**
  90796. * Returns the nearest 32-bit single precision float representation of a Number
  90797. * @param value A Number. If the parameter is of a different type, it will get converted
  90798. * to a number or to NaN if it cannot be converted
  90799. * @returns number
  90800. */
  90801. static FloatRound(value: number): number;
  90802. /**
  90803. * Find the next highest power of two.
  90804. * @param x Number to start search from.
  90805. * @return Next highest power of two.
  90806. */
  90807. static CeilingPOT(x: number): number;
  90808. /**
  90809. * Find the next lowest power of two.
  90810. * @param x Number to start search from.
  90811. * @return Next lowest power of two.
  90812. */
  90813. static FloorPOT(x: number): number;
  90814. /**
  90815. * Find the nearest power of two.
  90816. * @param x Number to start search from.
  90817. * @return Next nearest power of two.
  90818. */
  90819. static NearestPOT(x: number): number;
  90820. /**
  90821. * Get the closest exponent of two
  90822. * @param value defines the value to approximate
  90823. * @param max defines the maximum value to return
  90824. * @param mode defines how to define the closest value
  90825. * @returns closest exponent of two of the given value
  90826. */
  90827. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90828. /**
  90829. * Extracts the filename from a path
  90830. * @param path defines the path to use
  90831. * @returns the filename
  90832. */
  90833. static GetFilename(path: string): string;
  90834. /**
  90835. * Extracts the "folder" part of a path (everything before the filename).
  90836. * @param uri The URI to extract the info from
  90837. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90838. * @returns The "folder" part of the path
  90839. */
  90840. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90841. /**
  90842. * Extracts text content from a DOM element hierarchy
  90843. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90844. */
  90845. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90846. /**
  90847. * Convert an angle in radians to degrees
  90848. * @param angle defines the angle to convert
  90849. * @returns the angle in degrees
  90850. */
  90851. static ToDegrees(angle: number): number;
  90852. /**
  90853. * Convert an angle in degrees to radians
  90854. * @param angle defines the angle to convert
  90855. * @returns the angle in radians
  90856. */
  90857. static ToRadians(angle: number): number;
  90858. /**
  90859. * Encode a buffer to a base64 string
  90860. * @param buffer defines the buffer to encode
  90861. * @returns the encoded string
  90862. */
  90863. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90864. /**
  90865. * Extracts minimum and maximum values from a list of indexed positions
  90866. * @param positions defines the positions to use
  90867. * @param indices defines the indices to the positions
  90868. * @param indexStart defines the start index
  90869. * @param indexCount defines the end index
  90870. * @param bias defines bias value to add to the result
  90871. * @return minimum and maximum values
  90872. */
  90873. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90874. minimum: Vector3;
  90875. maximum: Vector3;
  90876. };
  90877. /**
  90878. * Extracts minimum and maximum values from a list of positions
  90879. * @param positions defines the positions to use
  90880. * @param start defines the start index in the positions array
  90881. * @param count defines the number of positions to handle
  90882. * @param bias defines bias value to add to the result
  90883. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90884. * @return minimum and maximum values
  90885. */
  90886. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90887. minimum: Vector3;
  90888. maximum: Vector3;
  90889. };
  90890. /**
  90891. * Returns an array if obj is not an array
  90892. * @param obj defines the object to evaluate as an array
  90893. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90894. * @returns either obj directly if obj is an array or a new array containing obj
  90895. */
  90896. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90897. /**
  90898. * Gets the pointer prefix to use
  90899. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90900. */
  90901. static GetPointerPrefix(): string;
  90902. /**
  90903. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90904. * @param func - the function to be called
  90905. * @param requester - the object that will request the next frame. Falls back to window.
  90906. * @returns frame number
  90907. */
  90908. static QueueNewFrame(func: () => void, requester?: any): number;
  90909. /**
  90910. * Ask the browser to promote the current element to fullscreen rendering mode
  90911. * @param element defines the DOM element to promote
  90912. */
  90913. static RequestFullscreen(element: HTMLElement): void;
  90914. /**
  90915. * Asks the browser to exit fullscreen mode
  90916. */
  90917. static ExitFullscreen(): void;
  90918. /**
  90919. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90920. * @param url define the url we are trying
  90921. * @param element define the dom element where to configure the cors policy
  90922. */
  90923. static SetCorsBehavior(url: string | string[], element: {
  90924. crossOrigin: string | null;
  90925. }): void;
  90926. /**
  90927. * Removes unwanted characters from an url
  90928. * @param url defines the url to clean
  90929. * @returns the cleaned url
  90930. */
  90931. static CleanUrl(url: string): string;
  90932. /**
  90933. * Gets or sets a function used to pre-process url before using them to load assets
  90934. */
  90935. static PreprocessUrl: (url: string) => string;
  90936. /**
  90937. * Loads an image as an HTMLImageElement.
  90938. * @param input url string, ArrayBuffer, or Blob to load
  90939. * @param onLoad callback called when the image successfully loads
  90940. * @param onError callback called when the image fails to load
  90941. * @param offlineProvider offline provider for caching
  90942. * @returns the HTMLImageElement of the loaded image
  90943. */
  90944. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90945. /**
  90946. * Loads a file
  90947. * @param url url string, ArrayBuffer, or Blob to load
  90948. * @param onSuccess callback called when the file successfully loads
  90949. * @param onProgress callback called while file is loading (if the server supports this mode)
  90950. * @param offlineProvider defines the offline provider for caching
  90951. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90952. * @param onError callback called when the file fails to load
  90953. * @returns a file request object
  90954. */
  90955. 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;
  90956. /**
  90957. * Load a script (identified by an url). When the url returns, the
  90958. * content of this file is added into a new script element, attached to the DOM (body element)
  90959. * @param scriptUrl defines the url of the script to laod
  90960. * @param onSuccess defines the callback called when the script is loaded
  90961. * @param onError defines the callback to call if an error occurs
  90962. * @param scriptId defines the id of the script element
  90963. */
  90964. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90965. /**
  90966. * Load an asynchronous script (identified by an url). When the url returns, the
  90967. * content of this file is added into a new script element, attached to the DOM (body element)
  90968. * @param scriptUrl defines the url of the script to laod
  90969. * @param scriptId defines the id of the script element
  90970. * @returns a promise request object
  90971. */
  90972. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90973. /**
  90974. * Loads a file from a blob
  90975. * @param fileToLoad defines the blob to use
  90976. * @param callback defines the callback to call when data is loaded
  90977. * @param progressCallback defines the callback to call during loading process
  90978. * @returns a file request object
  90979. */
  90980. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90981. /**
  90982. * Loads a file
  90983. * @param fileToLoad defines the file to load
  90984. * @param callback defines the callback to call when data is loaded
  90985. * @param progressCallBack defines the callback to call during loading process
  90986. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90987. * @returns a file request object
  90988. */
  90989. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90990. /**
  90991. * Creates a data url from a given string content
  90992. * @param content defines the content to convert
  90993. * @returns the new data url link
  90994. */
  90995. static FileAsURL(content: string): string;
  90996. /**
  90997. * Format the given number to a specific decimal format
  90998. * @param value defines the number to format
  90999. * @param decimals defines the number of decimals to use
  91000. * @returns the formatted string
  91001. */
  91002. static Format(value: number, decimals?: number): string;
  91003. /**
  91004. * Checks if a given vector is inside a specific range
  91005. * @param v defines the vector to test
  91006. * @param min defines the minimum range
  91007. * @param max defines the maximum range
  91008. */
  91009. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91010. /**
  91011. * Tries to copy an object by duplicating every property
  91012. * @param source defines the source object
  91013. * @param destination defines the target object
  91014. * @param doNotCopyList defines a list of properties to avoid
  91015. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91016. */
  91017. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91018. /**
  91019. * Gets a boolean indicating if the given object has no own property
  91020. * @param obj defines the object to test
  91021. * @returns true if object has no own property
  91022. */
  91023. static IsEmpty(obj: any): boolean;
  91024. /**
  91025. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91026. * @param str Source string
  91027. * @param suffix Suffix to search for in the source string
  91028. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91029. */
  91030. static EndsWith(str: string, suffix: string): boolean;
  91031. /**
  91032. * Function used to register events at window level
  91033. * @param events defines the events to register
  91034. */
  91035. static RegisterTopRootEvents(events: {
  91036. name: string;
  91037. handler: Nullable<(e: FocusEvent) => any>;
  91038. }[]): void;
  91039. /**
  91040. * Function used to unregister events from window level
  91041. * @param events defines the events to unregister
  91042. */
  91043. static UnregisterTopRootEvents(events: {
  91044. name: string;
  91045. handler: Nullable<(e: FocusEvent) => any>;
  91046. }[]): void;
  91047. /**
  91048. * @ignore
  91049. */
  91050. static _ScreenshotCanvas: HTMLCanvasElement;
  91051. /**
  91052. * Dumps the current bound framebuffer
  91053. * @param width defines the rendering width
  91054. * @param height defines the rendering height
  91055. * @param engine defines the hosting engine
  91056. * @param successCallback defines the callback triggered once the data are available
  91057. * @param mimeType defines the mime type of the result
  91058. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91059. */
  91060. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91061. /**
  91062. * Converts the canvas data to blob.
  91063. * This acts as a polyfill for browsers not supporting the to blob function.
  91064. * @param canvas Defines the canvas to extract the data from
  91065. * @param successCallback Defines the callback triggered once the data are available
  91066. * @param mimeType Defines the mime type of the result
  91067. */
  91068. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91069. /**
  91070. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91071. * @param successCallback defines the callback triggered once the data are available
  91072. * @param mimeType defines the mime type of the result
  91073. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91074. */
  91075. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91076. /**
  91077. * Downloads a blob in the browser
  91078. * @param blob defines the blob to download
  91079. * @param fileName defines the name of the downloaded file
  91080. */
  91081. static Download(blob: Blob, fileName: string): void;
  91082. /**
  91083. * Captures a screenshot of the current rendering
  91084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91085. * @param engine defines the rendering engine
  91086. * @param camera defines the source camera
  91087. * @param size This parameter can be set to a single number or to an object with the
  91088. * following (optional) properties: precision, width, height. If a single number is passed,
  91089. * it will be used for both width and height. If an object is passed, the screenshot size
  91090. * will be derived from the parameters. The precision property is a multiplier allowing
  91091. * rendering at a higher or lower resolution
  91092. * @param successCallback defines the callback receives a single parameter which contains the
  91093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91094. * src parameter of an <img> to display it
  91095. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91096. * Check your browser for supported MIME types
  91097. */
  91098. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91099. /**
  91100. * Generates an image screenshot from the specified camera.
  91101. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91102. * @param engine The engine to use for rendering
  91103. * @param camera The camera to use for rendering
  91104. * @param size This parameter can be set to a single number or to an object with the
  91105. * following (optional) properties: precision, width, height. If a single number is passed,
  91106. * it will be used for both width and height. If an object is passed, the screenshot size
  91107. * will be derived from the parameters. The precision property is a multiplier allowing
  91108. * rendering at a higher or lower resolution
  91109. * @param successCallback The callback receives a single parameter which contains the
  91110. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91111. * src parameter of an <img> to display it
  91112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91113. * Check your browser for supported MIME types
  91114. * @param samples Texture samples (default: 1)
  91115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91116. * @param fileName A name for for the downloaded file.
  91117. */
  91118. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91119. /**
  91120. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91121. * Be aware Math.random() could cause collisions, but:
  91122. * "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"
  91123. * @returns a pseudo random id
  91124. */
  91125. static RandomId(): string;
  91126. /**
  91127. * Test if the given uri is a base64 string
  91128. * @param uri The uri to test
  91129. * @return True if the uri is a base64 string or false otherwise
  91130. */
  91131. static IsBase64(uri: string): boolean;
  91132. /**
  91133. * Decode the given base64 uri.
  91134. * @param uri The uri to decode
  91135. * @return The decoded base64 data.
  91136. */
  91137. static DecodeBase64(uri: string): ArrayBuffer;
  91138. /**
  91139. * Gets the absolute url.
  91140. * @param url the input url
  91141. * @return the absolute url
  91142. */
  91143. static GetAbsoluteUrl(url: string): string;
  91144. /**
  91145. * No log
  91146. */
  91147. static readonly NoneLogLevel: number;
  91148. /**
  91149. * Only message logs
  91150. */
  91151. static readonly MessageLogLevel: number;
  91152. /**
  91153. * Only warning logs
  91154. */
  91155. static readonly WarningLogLevel: number;
  91156. /**
  91157. * Only error logs
  91158. */
  91159. static readonly ErrorLogLevel: number;
  91160. /**
  91161. * All logs
  91162. */
  91163. static readonly AllLogLevel: number;
  91164. /**
  91165. * Gets a value indicating the number of loading errors
  91166. * @ignorenaming
  91167. */
  91168. static readonly errorsCount: number;
  91169. /**
  91170. * Callback called when a new log is added
  91171. */
  91172. static OnNewCacheEntry: (entry: string) => void;
  91173. /**
  91174. * Log a message to the console
  91175. * @param message defines the message to log
  91176. */
  91177. static Log(message: string): void;
  91178. /**
  91179. * Write a warning message to the console
  91180. * @param message defines the message to log
  91181. */
  91182. static Warn(message: string): void;
  91183. /**
  91184. * Write an error message to the console
  91185. * @param message defines the message to log
  91186. */
  91187. static Error(message: string): void;
  91188. /**
  91189. * Gets current log cache (list of logs)
  91190. */
  91191. static readonly LogCache: string;
  91192. /**
  91193. * Clears the log cache
  91194. */
  91195. static ClearLogCache(): void;
  91196. /**
  91197. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91198. */
  91199. static LogLevels: number;
  91200. /**
  91201. * Checks if the loaded document was accessed via `file:`-Protocol.
  91202. * @returns boolean
  91203. */
  91204. static IsFileURL(): boolean;
  91205. /**
  91206. * Checks if the window object exists
  91207. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91208. */
  91209. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91210. /**
  91211. * No performance log
  91212. */
  91213. static readonly PerformanceNoneLogLevel: number;
  91214. /**
  91215. * Use user marks to log performance
  91216. */
  91217. static readonly PerformanceUserMarkLogLevel: number;
  91218. /**
  91219. * Log performance to the console
  91220. */
  91221. static readonly PerformanceConsoleLogLevel: number;
  91222. private static _performance;
  91223. /**
  91224. * Sets the current performance log level
  91225. */
  91226. static PerformanceLogLevel: number;
  91227. private static _StartPerformanceCounterDisabled;
  91228. private static _EndPerformanceCounterDisabled;
  91229. private static _StartUserMark;
  91230. private static _EndUserMark;
  91231. private static _StartPerformanceConsole;
  91232. private static _EndPerformanceConsole;
  91233. /**
  91234. * Starts a performance counter
  91235. */
  91236. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91237. /**
  91238. * Ends a specific performance coutner
  91239. */
  91240. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91241. /**
  91242. * Gets either window.performance.now() if supported or Date.now() else
  91243. */
  91244. static readonly Now: number;
  91245. /**
  91246. * This method will return the name of the class used to create the instance of the given object.
  91247. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91248. * @param object the object to get the class name from
  91249. * @param isType defines if the object is actually a type
  91250. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91251. */
  91252. static GetClassName(object: any, isType?: boolean): string;
  91253. /**
  91254. * Gets the first element of an array satisfying a given predicate
  91255. * @param array defines the array to browse
  91256. * @param predicate defines the predicate to use
  91257. * @returns null if not found or the element
  91258. */
  91259. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91260. /**
  91261. * This method will return the name of the full name of the class, including its owning module (if any).
  91262. * 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).
  91263. * @param object the object to get the class name from
  91264. * @param isType defines if the object is actually a type
  91265. * @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.
  91266. * @ignorenaming
  91267. */
  91268. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91269. /**
  91270. * Returns a promise that resolves after the given amount of time.
  91271. * @param delay Number of milliseconds to delay
  91272. * @returns Promise that resolves after the given amount of time
  91273. */
  91274. static DelayAsync(delay: number): Promise<void>;
  91275. /**
  91276. * Gets the current gradient from an array of IValueGradient
  91277. * @param ratio defines the current ratio to get
  91278. * @param gradients defines the array of IValueGradient
  91279. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91280. */
  91281. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91282. }
  91283. /**
  91284. * This class is used to track a performance counter which is number based.
  91285. * The user has access to many properties which give statistics of different nature.
  91286. *
  91287. * The implementer can track two kinds of Performance Counter: time and count.
  91288. * 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.
  91289. * 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.
  91290. */
  91291. export class PerfCounter {
  91292. /**
  91293. * Gets or sets a global boolean to turn on and off all the counters
  91294. */
  91295. static Enabled: boolean;
  91296. /**
  91297. * Returns the smallest value ever
  91298. */
  91299. readonly min: number;
  91300. /**
  91301. * Returns the biggest value ever
  91302. */
  91303. readonly max: number;
  91304. /**
  91305. * Returns the average value since the performance counter is running
  91306. */
  91307. readonly average: number;
  91308. /**
  91309. * Returns the average value of the last second the counter was monitored
  91310. */
  91311. readonly lastSecAverage: number;
  91312. /**
  91313. * Returns the current value
  91314. */
  91315. readonly current: number;
  91316. /**
  91317. * Gets the accumulated total
  91318. */
  91319. readonly total: number;
  91320. /**
  91321. * Gets the total value count
  91322. */
  91323. readonly count: number;
  91324. /**
  91325. * Creates a new counter
  91326. */
  91327. constructor();
  91328. /**
  91329. * Call this method to start monitoring a new frame.
  91330. * 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.
  91331. */
  91332. fetchNewFrame(): void;
  91333. /**
  91334. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91335. * @param newCount the count value to add to the monitored count
  91336. * @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.
  91337. */
  91338. addCount(newCount: number, fetchResult: boolean): void;
  91339. /**
  91340. * Start monitoring this performance counter
  91341. */
  91342. beginMonitoring(): void;
  91343. /**
  91344. * Compute the time lapsed since the previous beginMonitoring() call.
  91345. * @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
  91346. */
  91347. endMonitoring(newFrame?: boolean): void;
  91348. private _fetchResult;
  91349. private _startMonitoringTime;
  91350. private _min;
  91351. private _max;
  91352. private _average;
  91353. private _current;
  91354. private _totalValueCount;
  91355. private _totalAccumulated;
  91356. private _lastSecAverage;
  91357. private _lastSecAccumulated;
  91358. private _lastSecTime;
  91359. private _lastSecValueCount;
  91360. }
  91361. /**
  91362. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91363. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91364. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91365. * @param name The name of the class, case should be preserved
  91366. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91367. */
  91368. export function className(name: string, module?: string): (target: Object) => void;
  91369. /**
  91370. * An implementation of a loop for asynchronous functions.
  91371. */
  91372. export class AsyncLoop {
  91373. /**
  91374. * Defines the number of iterations for the loop
  91375. */
  91376. iterations: number;
  91377. /**
  91378. * Defines the current index of the loop.
  91379. */
  91380. index: number;
  91381. private _done;
  91382. private _fn;
  91383. private _successCallback;
  91384. /**
  91385. * Constructor.
  91386. * @param iterations the number of iterations.
  91387. * @param func the function to run each iteration
  91388. * @param successCallback the callback that will be called upon succesful execution
  91389. * @param offset starting offset.
  91390. */
  91391. constructor(
  91392. /**
  91393. * Defines the number of iterations for the loop
  91394. */
  91395. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91396. /**
  91397. * Execute the next iteration. Must be called after the last iteration was finished.
  91398. */
  91399. executeNext(): void;
  91400. /**
  91401. * Break the loop and run the success callback.
  91402. */
  91403. breakLoop(): void;
  91404. /**
  91405. * Create and run an async loop.
  91406. * @param iterations the number of iterations.
  91407. * @param fn the function to run each iteration
  91408. * @param successCallback the callback that will be called upon succesful execution
  91409. * @param offset starting offset.
  91410. * @returns the created async loop object
  91411. */
  91412. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91413. /**
  91414. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91415. * @param iterations total number of iterations
  91416. * @param syncedIterations number of synchronous iterations in each async iteration.
  91417. * @param fn the function to call each iteration.
  91418. * @param callback a success call back that will be called when iterating stops.
  91419. * @param breakFunction a break condition (optional)
  91420. * @param timeout timeout settings for the setTimeout function. default - 0.
  91421. * @returns the created async loop object
  91422. */
  91423. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91424. }
  91425. }
  91426. declare module BABYLON {
  91427. /** @hidden */
  91428. export interface ICollisionCoordinator {
  91429. createCollider(): Collider;
  91430. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91431. init(scene: Scene): void;
  91432. }
  91433. /** @hidden */
  91434. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91435. private _scene;
  91436. private _scaledPosition;
  91437. private _scaledVelocity;
  91438. private _finalPosition;
  91439. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91440. createCollider(): Collider;
  91441. init(scene: Scene): void;
  91442. private _collideWithWorld;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /**
  91447. * Class used to manage all inputs for the scene.
  91448. */
  91449. export class InputManager {
  91450. /** The distance in pixel that you have to move to prevent some events */
  91451. static DragMovementThreshold: number;
  91452. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91453. static LongPressDelay: number;
  91454. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91455. static DoubleClickDelay: number;
  91456. /** If you need to check double click without raising a single click at first click, enable this flag */
  91457. static ExclusiveDoubleClickMode: boolean;
  91458. private _wheelEventName;
  91459. private _onPointerMove;
  91460. private _onPointerDown;
  91461. private _onPointerUp;
  91462. private _initClickEvent;
  91463. private _initActionManager;
  91464. private _delayedSimpleClick;
  91465. private _delayedSimpleClickTimeout;
  91466. private _previousDelayedSimpleClickTimeout;
  91467. private _meshPickProceed;
  91468. private _previousButtonPressed;
  91469. private _currentPickResult;
  91470. private _previousPickResult;
  91471. private _totalPointersPressed;
  91472. private _doubleClickOccured;
  91473. private _pointerOverMesh;
  91474. private _pickedDownMesh;
  91475. private _pickedUpMesh;
  91476. private _pointerX;
  91477. private _pointerY;
  91478. private _unTranslatedPointerX;
  91479. private _unTranslatedPointerY;
  91480. private _startingPointerPosition;
  91481. private _previousStartingPointerPosition;
  91482. private _startingPointerTime;
  91483. private _previousStartingPointerTime;
  91484. private _pointerCaptures;
  91485. private _onKeyDown;
  91486. private _onKeyUp;
  91487. private _onCanvasFocusObserver;
  91488. private _onCanvasBlurObserver;
  91489. private _scene;
  91490. /**
  91491. * Creates a new InputManager
  91492. * @param scene defines the hosting scene
  91493. */
  91494. constructor(scene: Scene);
  91495. /**
  91496. * Gets the mesh that is currently under the pointer
  91497. */
  91498. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91499. /**
  91500. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91501. */
  91502. readonly unTranslatedPointer: Vector2;
  91503. /**
  91504. * Gets or sets the current on-screen X position of the pointer
  91505. */
  91506. pointerX: number;
  91507. /**
  91508. * Gets or sets the current on-screen Y position of the pointer
  91509. */
  91510. pointerY: number;
  91511. private _updatePointerPosition;
  91512. private _processPointerMove;
  91513. private _setRayOnPointerInfo;
  91514. private _checkPrePointerObservable;
  91515. /**
  91516. * Use this method to simulate a pointer move on a mesh
  91517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91520. */
  91521. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91522. /**
  91523. * Use this method to simulate a pointer down on a mesh
  91524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91527. */
  91528. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91529. private _processPointerDown;
  91530. /** @hidden */
  91531. _isPointerSwiping(): boolean;
  91532. /**
  91533. * Use this method to simulate a pointer up on a mesh
  91534. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91535. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91536. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91537. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91538. */
  91539. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91540. private _processPointerUp;
  91541. /**
  91542. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91543. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91544. * @returns true if the pointer was captured
  91545. */
  91546. isPointerCaptured(pointerId?: number): boolean;
  91547. /**
  91548. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91549. * @param attachUp defines if you want to attach events to pointerup
  91550. * @param attachDown defines if you want to attach events to pointerdown
  91551. * @param attachMove defines if you want to attach events to pointermove
  91552. */
  91553. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91554. /**
  91555. * Detaches all event handlers
  91556. */
  91557. detachControl(): void;
  91558. /**
  91559. * Force the value of meshUnderPointer
  91560. * @param mesh defines the mesh to use
  91561. */
  91562. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91563. /**
  91564. * Gets the mesh under the pointer
  91565. * @returns a Mesh or null if no mesh is under the pointer
  91566. */
  91567. getPointerOverMesh(): Nullable<AbstractMesh>;
  91568. }
  91569. }
  91570. declare module BABYLON {
  91571. /**
  91572. * This class defines the direct association between an animation and a target
  91573. */
  91574. export class TargetedAnimation {
  91575. /**
  91576. * Animation to perform
  91577. */
  91578. animation: Animation;
  91579. /**
  91580. * Target to animate
  91581. */
  91582. target: any;
  91583. }
  91584. /**
  91585. * Use this class to create coordinated animations on multiple targets
  91586. */
  91587. export class AnimationGroup implements IDisposable {
  91588. /** The name of the animation group */
  91589. name: string;
  91590. private _scene;
  91591. private _targetedAnimations;
  91592. private _animatables;
  91593. private _from;
  91594. private _to;
  91595. private _isStarted;
  91596. private _isPaused;
  91597. private _speedRatio;
  91598. /**
  91599. * Gets or sets the unique id of the node
  91600. */
  91601. uniqueId: number;
  91602. /**
  91603. * This observable will notify when one animation have ended
  91604. */
  91605. onAnimationEndObservable: Observable<TargetedAnimation>;
  91606. /**
  91607. * Observer raised when one animation loops
  91608. */
  91609. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91610. /**
  91611. * This observable will notify when all animations have ended.
  91612. */
  91613. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91614. /**
  91615. * This observable will notify when all animations have paused.
  91616. */
  91617. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91618. /**
  91619. * This observable will notify when all animations are playing.
  91620. */
  91621. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91622. /**
  91623. * Gets the first frame
  91624. */
  91625. readonly from: number;
  91626. /**
  91627. * Gets the last frame
  91628. */
  91629. readonly to: number;
  91630. /**
  91631. * Define if the animations are started
  91632. */
  91633. readonly isStarted: boolean;
  91634. /**
  91635. * Gets a value indicating that the current group is playing
  91636. */
  91637. readonly isPlaying: boolean;
  91638. /**
  91639. * Gets or sets the speed ratio to use for all animations
  91640. */
  91641. /**
  91642. * Gets or sets the speed ratio to use for all animations
  91643. */
  91644. speedRatio: number;
  91645. /**
  91646. * Gets the targeted animations for this animation group
  91647. */
  91648. readonly targetedAnimations: Array<TargetedAnimation>;
  91649. /**
  91650. * returning the list of animatables controlled by this animation group.
  91651. */
  91652. readonly animatables: Array<Animatable>;
  91653. /**
  91654. * Instantiates a new Animation Group.
  91655. * This helps managing several animations at once.
  91656. * @see http://doc.babylonjs.com/how_to/group
  91657. * @param name Defines the name of the group
  91658. * @param scene Defines the scene the group belongs to
  91659. */
  91660. constructor(
  91661. /** The name of the animation group */
  91662. name: string, scene?: Nullable<Scene>);
  91663. /**
  91664. * Add an animation (with its target) in the group
  91665. * @param animation defines the animation we want to add
  91666. * @param target defines the target of the animation
  91667. * @returns the TargetedAnimation object
  91668. */
  91669. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91670. /**
  91671. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91672. * It can add constant keys at begin or end
  91673. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91674. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91675. * @returns the animation group
  91676. */
  91677. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91678. /**
  91679. * Start all animations on given targets
  91680. * @param loop defines if animations must loop
  91681. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91682. * @param from defines the from key (optional)
  91683. * @param to defines the to key (optional)
  91684. * @returns the current animation group
  91685. */
  91686. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91687. /**
  91688. * Pause all animations
  91689. * @returns the animation group
  91690. */
  91691. pause(): AnimationGroup;
  91692. /**
  91693. * Play all animations to initial state
  91694. * This function will start() the animations if they were not started or will restart() them if they were paused
  91695. * @param loop defines if animations must loop
  91696. * @returns the animation group
  91697. */
  91698. play(loop?: boolean): AnimationGroup;
  91699. /**
  91700. * Reset all animations to initial state
  91701. * @returns the animation group
  91702. */
  91703. reset(): AnimationGroup;
  91704. /**
  91705. * Restart animations from key 0
  91706. * @returns the animation group
  91707. */
  91708. restart(): AnimationGroup;
  91709. /**
  91710. * Stop all animations
  91711. * @returns the animation group
  91712. */
  91713. stop(): AnimationGroup;
  91714. /**
  91715. * Set animation weight for all animatables
  91716. * @param weight defines the weight to use
  91717. * @return the animationGroup
  91718. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91719. */
  91720. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91721. /**
  91722. * Synchronize and normalize all animatables with a source animatable
  91723. * @param root defines the root animatable to synchronize with
  91724. * @return the animationGroup
  91725. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91726. */
  91727. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91728. /**
  91729. * Goes to a specific frame in this animation group
  91730. * @param frame the frame number to go to
  91731. * @return the animationGroup
  91732. */
  91733. goToFrame(frame: number): AnimationGroup;
  91734. /**
  91735. * Dispose all associated resources
  91736. */
  91737. dispose(): void;
  91738. private _checkAnimationGroupEnded;
  91739. /**
  91740. * Clone the current animation group and returns a copy
  91741. * @param newName defines the name of the new group
  91742. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91743. * @returns the new aniamtion group
  91744. */
  91745. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91746. /**
  91747. * Returns a new AnimationGroup object parsed from the source provided.
  91748. * @param parsedAnimationGroup defines the source
  91749. * @param scene defines the scene that will receive the animationGroup
  91750. * @returns a new AnimationGroup
  91751. */
  91752. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91753. /**
  91754. * Returns the string "AnimationGroup"
  91755. * @returns "AnimationGroup"
  91756. */
  91757. getClassName(): string;
  91758. /**
  91759. * Creates a detailled string about the object
  91760. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91761. * @returns a string representing the object
  91762. */
  91763. toString(fullDetails?: boolean): string;
  91764. }
  91765. }
  91766. declare module BABYLON {
  91767. /**
  91768. * Define an interface for all classes that will hold resources
  91769. */
  91770. export interface IDisposable {
  91771. /**
  91772. * Releases all held resources
  91773. */
  91774. dispose(): void;
  91775. }
  91776. /** Interface defining initialization parameters for Scene class */
  91777. export interface SceneOptions {
  91778. /**
  91779. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91780. * It will improve performance when the number of geometries becomes important.
  91781. */
  91782. useGeometryUniqueIdsMap?: boolean;
  91783. /**
  91784. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91785. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91786. */
  91787. useMaterialMeshMap?: boolean;
  91788. /**
  91789. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91791. */
  91792. useClonedMeshhMap?: boolean;
  91793. }
  91794. /**
  91795. * Represents a scene to be rendered by the engine.
  91796. * @see http://doc.babylonjs.com/features/scene
  91797. */
  91798. export class Scene extends AbstractScene implements IAnimatable {
  91799. private static _uniqueIdCounter;
  91800. /** The fog is deactivated */
  91801. static readonly FOGMODE_NONE: number;
  91802. /** The fog density is following an exponential function */
  91803. static readonly FOGMODE_EXP: number;
  91804. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91805. static readonly FOGMODE_EXP2: number;
  91806. /** The fog density is following a linear function. */
  91807. static readonly FOGMODE_LINEAR: number;
  91808. /**
  91809. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91811. */
  91812. static MinDeltaTime: number;
  91813. /**
  91814. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91816. */
  91817. static MaxDeltaTime: number;
  91818. /**
  91819. * Factory used to create the default material.
  91820. * @param name The name of the material to create
  91821. * @param scene The scene to create the material for
  91822. * @returns The default material
  91823. */
  91824. static DefaultMaterialFactory(scene: Scene): Material;
  91825. /**
  91826. * Factory used to create the a collision coordinator.
  91827. * @returns The collision coordinator
  91828. */
  91829. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91830. /** @hidden */
  91831. _inputManager: InputManager;
  91832. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91833. cameraToUseForPointers: Nullable<Camera>;
  91834. /** @hidden */
  91835. readonly _isScene: boolean;
  91836. /**
  91837. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91838. */
  91839. autoClear: boolean;
  91840. /**
  91841. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91842. */
  91843. autoClearDepthAndStencil: boolean;
  91844. /**
  91845. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91846. */
  91847. clearColor: Color4;
  91848. /**
  91849. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91850. */
  91851. ambientColor: Color3;
  91852. /**
  91853. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91854. * It should only be one of the following (if not the default embedded one):
  91855. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91856. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91857. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91858. * The material properties need to be setup according to the type of texture in use.
  91859. */
  91860. environmentBRDFTexture: BaseTexture;
  91861. /** @hidden */
  91862. protected _environmentTexture: Nullable<BaseTexture>;
  91863. /**
  91864. * Texture used in all pbr material as the reflection texture.
  91865. * As in the majority of the scene they are the same (exception for multi room and so on),
  91866. * this is easier to reference from here than from all the materials.
  91867. */
  91868. /**
  91869. * Texture used in all pbr material as the reflection texture.
  91870. * As in the majority of the scene they are the same (exception for multi room and so on),
  91871. * this is easier to set here than in all the materials.
  91872. */
  91873. environmentTexture: Nullable<BaseTexture>;
  91874. /** @hidden */
  91875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91876. /**
  91877. * Default image processing configuration used either in the rendering
  91878. * Forward main pass or through the imageProcessingPostProcess if present.
  91879. * As in the majority of the scene they are the same (exception for multi camera),
  91880. * this is easier to reference from here than from all the materials and post process.
  91881. *
  91882. * No setter as we it is a shared configuration, you can set the values instead.
  91883. */
  91884. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91885. private _forceWireframe;
  91886. /**
  91887. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91888. */
  91889. forceWireframe: boolean;
  91890. private _forcePointsCloud;
  91891. /**
  91892. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91893. */
  91894. forcePointsCloud: boolean;
  91895. /**
  91896. * Gets or sets the active clipplane 1
  91897. */
  91898. clipPlane: Nullable<Plane>;
  91899. /**
  91900. * Gets or sets the active clipplane 2
  91901. */
  91902. clipPlane2: Nullable<Plane>;
  91903. /**
  91904. * Gets or sets the active clipplane 3
  91905. */
  91906. clipPlane3: Nullable<Plane>;
  91907. /**
  91908. * Gets or sets the active clipplane 4
  91909. */
  91910. clipPlane4: Nullable<Plane>;
  91911. /**
  91912. * Gets or sets a boolean indicating if animations are enabled
  91913. */
  91914. animationsEnabled: boolean;
  91915. private _animationPropertiesOverride;
  91916. /**
  91917. * Gets or sets the animation properties override
  91918. */
  91919. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91920. /**
  91921. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91922. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91923. */
  91924. useConstantAnimationDeltaTime: boolean;
  91925. /**
  91926. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91927. * Please note that it requires to run a ray cast through the scene on every frame
  91928. */
  91929. constantlyUpdateMeshUnderPointer: boolean;
  91930. /**
  91931. * Defines the HTML cursor to use when hovering over interactive elements
  91932. */
  91933. hoverCursor: string;
  91934. /**
  91935. * Defines the HTML default cursor to use (empty by default)
  91936. */
  91937. defaultCursor: string;
  91938. /**
  91939. * This is used to call preventDefault() on pointer down
  91940. * in order to block unwanted artifacts like system double clicks
  91941. */
  91942. preventDefaultOnPointerDown: boolean;
  91943. /**
  91944. * This is used to call preventDefault() on pointer up
  91945. * in order to block unwanted artifacts like system double clicks
  91946. */
  91947. preventDefaultOnPointerUp: boolean;
  91948. /**
  91949. * Gets or sets user defined metadata
  91950. */
  91951. metadata: any;
  91952. /**
  91953. * For internal use only. Please do not use.
  91954. */
  91955. reservedDataStore: any;
  91956. /**
  91957. * Gets the name of the plugin used to load this scene (null by default)
  91958. */
  91959. loadingPluginName: string;
  91960. /**
  91961. * Use this array to add regular expressions used to disable offline support for specific urls
  91962. */
  91963. disableOfflineSupportExceptionRules: RegExp[];
  91964. /**
  91965. * An event triggered when the scene is disposed.
  91966. */
  91967. onDisposeObservable: Observable<Scene>;
  91968. private _onDisposeObserver;
  91969. /** Sets a function to be executed when this scene is disposed. */
  91970. onDispose: () => void;
  91971. /**
  91972. * An event triggered before rendering the scene (right after animations and physics)
  91973. */
  91974. onBeforeRenderObservable: Observable<Scene>;
  91975. private _onBeforeRenderObserver;
  91976. /** Sets a function to be executed before rendering this scene */
  91977. beforeRender: Nullable<() => void>;
  91978. /**
  91979. * An event triggered after rendering the scene
  91980. */
  91981. onAfterRenderObservable: Observable<Scene>;
  91982. private _onAfterRenderObserver;
  91983. /** Sets a function to be executed after rendering this scene */
  91984. afterRender: Nullable<() => void>;
  91985. /**
  91986. * An event triggered before animating the scene
  91987. */
  91988. onBeforeAnimationsObservable: Observable<Scene>;
  91989. /**
  91990. * An event triggered after animations processing
  91991. */
  91992. onAfterAnimationsObservable: Observable<Scene>;
  91993. /**
  91994. * An event triggered before draw calls are ready to be sent
  91995. */
  91996. onBeforeDrawPhaseObservable: Observable<Scene>;
  91997. /**
  91998. * An event triggered after draw calls have been sent
  91999. */
  92000. onAfterDrawPhaseObservable: Observable<Scene>;
  92001. /**
  92002. * An event triggered when the scene is ready
  92003. */
  92004. onReadyObservable: Observable<Scene>;
  92005. /**
  92006. * An event triggered before rendering a camera
  92007. */
  92008. onBeforeCameraRenderObservable: Observable<Camera>;
  92009. private _onBeforeCameraRenderObserver;
  92010. /** Sets a function to be executed before rendering a camera*/
  92011. beforeCameraRender: () => void;
  92012. /**
  92013. * An event triggered after rendering a camera
  92014. */
  92015. onAfterCameraRenderObservable: Observable<Camera>;
  92016. private _onAfterCameraRenderObserver;
  92017. /** Sets a function to be executed after rendering a camera*/
  92018. afterCameraRender: () => void;
  92019. /**
  92020. * An event triggered when active meshes evaluation is about to start
  92021. */
  92022. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92023. /**
  92024. * An event triggered when active meshes evaluation is done
  92025. */
  92026. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92027. /**
  92028. * An event triggered when particles rendering is about to start
  92029. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92030. */
  92031. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92032. /**
  92033. * An event triggered when particles rendering is done
  92034. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92035. */
  92036. onAfterParticlesRenderingObservable: Observable<Scene>;
  92037. /**
  92038. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92039. */
  92040. onDataLoadedObservable: Observable<Scene>;
  92041. /**
  92042. * An event triggered when a camera is created
  92043. */
  92044. onNewCameraAddedObservable: Observable<Camera>;
  92045. /**
  92046. * An event triggered when a camera is removed
  92047. */
  92048. onCameraRemovedObservable: Observable<Camera>;
  92049. /**
  92050. * An event triggered when a light is created
  92051. */
  92052. onNewLightAddedObservable: Observable<Light>;
  92053. /**
  92054. * An event triggered when a light is removed
  92055. */
  92056. onLightRemovedObservable: Observable<Light>;
  92057. /**
  92058. * An event triggered when a geometry is created
  92059. */
  92060. onNewGeometryAddedObservable: Observable<Geometry>;
  92061. /**
  92062. * An event triggered when a geometry is removed
  92063. */
  92064. onGeometryRemovedObservable: Observable<Geometry>;
  92065. /**
  92066. * An event triggered when a transform node is created
  92067. */
  92068. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92069. /**
  92070. * An event triggered when a transform node is removed
  92071. */
  92072. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92073. /**
  92074. * An event triggered when a mesh is created
  92075. */
  92076. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92077. /**
  92078. * An event triggered when a mesh is removed
  92079. */
  92080. onMeshRemovedObservable: Observable<AbstractMesh>;
  92081. /**
  92082. * An event triggered when a skeleton is created
  92083. */
  92084. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92085. /**
  92086. * An event triggered when a skeleton is removed
  92087. */
  92088. onSkeletonRemovedObservable: Observable<Skeleton>;
  92089. /**
  92090. * An event triggered when a material is created
  92091. */
  92092. onNewMaterialAddedObservable: Observable<Material>;
  92093. /**
  92094. * An event triggered when a material is removed
  92095. */
  92096. onMaterialRemovedObservable: Observable<Material>;
  92097. /**
  92098. * An event triggered when a texture is created
  92099. */
  92100. onNewTextureAddedObservable: Observable<BaseTexture>;
  92101. /**
  92102. * An event triggered when a texture is removed
  92103. */
  92104. onTextureRemovedObservable: Observable<BaseTexture>;
  92105. /**
  92106. * An event triggered when render targets are about to be rendered
  92107. * Can happen multiple times per frame.
  92108. */
  92109. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92110. /**
  92111. * An event triggered when render targets were rendered.
  92112. * Can happen multiple times per frame.
  92113. */
  92114. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92115. /**
  92116. * An event triggered before calculating deterministic simulation step
  92117. */
  92118. onBeforeStepObservable: Observable<Scene>;
  92119. /**
  92120. * An event triggered after calculating deterministic simulation step
  92121. */
  92122. onAfterStepObservable: Observable<Scene>;
  92123. /**
  92124. * An event triggered when the activeCamera property is updated
  92125. */
  92126. onActiveCameraChanged: Observable<Scene>;
  92127. /**
  92128. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92129. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92130. * 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)
  92131. */
  92132. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92133. /**
  92134. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92135. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92136. * 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)
  92137. */
  92138. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92139. /**
  92140. * This Observable will when a mesh has been imported into the scene.
  92141. */
  92142. onMeshImportedObservable: Observable<AbstractMesh>;
  92143. /**
  92144. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92145. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92146. */
  92147. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92148. /** @hidden */
  92149. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92150. /**
  92151. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92152. */
  92153. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92154. /**
  92155. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92156. */
  92157. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92158. /**
  92159. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92160. */
  92161. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92162. /** Callback called when a pointer move is detected */
  92163. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92164. /** Callback called when a pointer down is detected */
  92165. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92166. /** Callback called when a pointer up is detected */
  92167. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92168. /** Callback called when a pointer pick is detected */
  92169. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92170. /**
  92171. * 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).
  92172. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92173. */
  92174. onPrePointerObservable: Observable<PointerInfoPre>;
  92175. /**
  92176. * Observable event triggered each time an input event is received from the rendering canvas
  92177. */
  92178. onPointerObservable: Observable<PointerInfo>;
  92179. /**
  92180. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92181. */
  92182. readonly unTranslatedPointer: Vector2;
  92183. /**
  92184. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92185. */
  92186. static DragMovementThreshold: number;
  92187. /**
  92188. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92189. */
  92190. static LongPressDelay: number;
  92191. /**
  92192. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92193. */
  92194. static DoubleClickDelay: number;
  92195. /** If you need to check double click without raising a single click at first click, enable this flag */
  92196. static ExclusiveDoubleClickMode: boolean;
  92197. /** @hidden */
  92198. _mirroredCameraPosition: Nullable<Vector3>;
  92199. /**
  92200. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92201. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92202. */
  92203. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92204. /**
  92205. * Observable event triggered each time an keyboard event is received from the hosting window
  92206. */
  92207. onKeyboardObservable: Observable<KeyboardInfo>;
  92208. private _useRightHandedSystem;
  92209. /**
  92210. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92211. */
  92212. useRightHandedSystem: boolean;
  92213. private _timeAccumulator;
  92214. private _currentStepId;
  92215. private _currentInternalStep;
  92216. /**
  92217. * Sets the step Id used by deterministic lock step
  92218. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92219. * @param newStepId defines the step Id
  92220. */
  92221. setStepId(newStepId: number): void;
  92222. /**
  92223. * Gets the step Id used by deterministic lock step
  92224. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92225. * @returns the step Id
  92226. */
  92227. getStepId(): number;
  92228. /**
  92229. * Gets the internal step used by deterministic lock step
  92230. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92231. * @returns the internal step
  92232. */
  92233. getInternalStep(): number;
  92234. private _fogEnabled;
  92235. /**
  92236. * Gets or sets a boolean indicating if fog is enabled on this scene
  92237. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92238. * (Default is true)
  92239. */
  92240. fogEnabled: boolean;
  92241. private _fogMode;
  92242. /**
  92243. * Gets or sets the fog mode to use
  92244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92245. * | mode | value |
  92246. * | --- | --- |
  92247. * | FOGMODE_NONE | 0 |
  92248. * | FOGMODE_EXP | 1 |
  92249. * | FOGMODE_EXP2 | 2 |
  92250. * | FOGMODE_LINEAR | 3 |
  92251. */
  92252. fogMode: number;
  92253. /**
  92254. * Gets or sets the fog color to use
  92255. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92256. * (Default is Color3(0.2, 0.2, 0.3))
  92257. */
  92258. fogColor: Color3;
  92259. /**
  92260. * Gets or sets the fog density to use
  92261. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92262. * (Default is 0.1)
  92263. */
  92264. fogDensity: number;
  92265. /**
  92266. * Gets or sets the fog start distance to use
  92267. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92268. * (Default is 0)
  92269. */
  92270. fogStart: number;
  92271. /**
  92272. * Gets or sets the fog end distance to use
  92273. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92274. * (Default is 1000)
  92275. */
  92276. fogEnd: number;
  92277. private _shadowsEnabled;
  92278. /**
  92279. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92280. */
  92281. shadowsEnabled: boolean;
  92282. private _lightsEnabled;
  92283. /**
  92284. * Gets or sets a boolean indicating if lights are enabled on this scene
  92285. */
  92286. lightsEnabled: boolean;
  92287. /** All of the active cameras added to this scene. */
  92288. activeCameras: Camera[];
  92289. /** @hidden */
  92290. _activeCamera: Nullable<Camera>;
  92291. /** Gets or sets the current active camera */
  92292. activeCamera: Nullable<Camera>;
  92293. private _defaultMaterial;
  92294. /** The default material used on meshes when no material is affected */
  92295. /** The default material used on meshes when no material is affected */
  92296. defaultMaterial: Material;
  92297. private _texturesEnabled;
  92298. /**
  92299. * Gets or sets a boolean indicating if textures are enabled on this scene
  92300. */
  92301. texturesEnabled: boolean;
  92302. /**
  92303. * Gets or sets a boolean indicating if particles are enabled on this scene
  92304. */
  92305. particlesEnabled: boolean;
  92306. /**
  92307. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92308. */
  92309. spritesEnabled: boolean;
  92310. private _skeletonsEnabled;
  92311. /**
  92312. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92313. */
  92314. skeletonsEnabled: boolean;
  92315. /**
  92316. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92317. */
  92318. lensFlaresEnabled: boolean;
  92319. /**
  92320. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92322. */
  92323. collisionsEnabled: boolean;
  92324. private _collisionCoordinator;
  92325. /** @hidden */
  92326. readonly collisionCoordinator: ICollisionCoordinator;
  92327. /**
  92328. * Defines the gravity applied to this scene (used only for collisions)
  92329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92330. */
  92331. gravity: Vector3;
  92332. /**
  92333. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92334. */
  92335. postProcessesEnabled: boolean;
  92336. /**
  92337. * The list of postprocesses added to the scene
  92338. */
  92339. postProcesses: PostProcess[];
  92340. /**
  92341. * Gets the current postprocess manager
  92342. */
  92343. postProcessManager: PostProcessManager;
  92344. /**
  92345. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92346. */
  92347. renderTargetsEnabled: boolean;
  92348. /**
  92349. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92350. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92351. */
  92352. dumpNextRenderTargets: boolean;
  92353. /**
  92354. * The list of user defined render targets added to the scene
  92355. */
  92356. customRenderTargets: RenderTargetTexture[];
  92357. /**
  92358. * Defines if texture loading must be delayed
  92359. * If true, textures will only be loaded when they need to be rendered
  92360. */
  92361. useDelayedTextureLoading: boolean;
  92362. /**
  92363. * Gets the list of meshes imported to the scene through SceneLoader
  92364. */
  92365. importedMeshesFiles: String[];
  92366. /**
  92367. * Gets or sets a boolean indicating if probes are enabled on this scene
  92368. */
  92369. probesEnabled: boolean;
  92370. /**
  92371. * Gets or sets the current offline provider to use to store scene data
  92372. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92373. */
  92374. offlineProvider: IOfflineProvider;
  92375. /**
  92376. * Gets or sets the action manager associated with the scene
  92377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92378. */
  92379. actionManager: AbstractActionManager;
  92380. private _meshesForIntersections;
  92381. /**
  92382. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92383. */
  92384. proceduralTexturesEnabled: boolean;
  92385. private _engine;
  92386. private _totalVertices;
  92387. /** @hidden */
  92388. _activeIndices: PerfCounter;
  92389. /** @hidden */
  92390. _activeParticles: PerfCounter;
  92391. /** @hidden */
  92392. _activeBones: PerfCounter;
  92393. private _animationRatio;
  92394. /** @hidden */
  92395. _animationTimeLast: number;
  92396. /** @hidden */
  92397. _animationTime: number;
  92398. /**
  92399. * Gets or sets a general scale for animation speed
  92400. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92401. */
  92402. animationTimeScale: number;
  92403. /** @hidden */
  92404. _cachedMaterial: Nullable<Material>;
  92405. /** @hidden */
  92406. _cachedEffect: Nullable<Effect>;
  92407. /** @hidden */
  92408. _cachedVisibility: Nullable<number>;
  92409. private _renderId;
  92410. private _frameId;
  92411. private _executeWhenReadyTimeoutId;
  92412. private _intermediateRendering;
  92413. private _viewUpdateFlag;
  92414. private _projectionUpdateFlag;
  92415. /** @hidden */
  92416. _toBeDisposed: Nullable<IDisposable>[];
  92417. private _activeRequests;
  92418. /** @hidden */
  92419. _pendingData: any[];
  92420. private _isDisposed;
  92421. /**
  92422. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92423. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92424. */
  92425. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92426. private _activeMeshes;
  92427. private _processedMaterials;
  92428. private _renderTargets;
  92429. /** @hidden */
  92430. _activeParticleSystems: SmartArray<IParticleSystem>;
  92431. private _activeSkeletons;
  92432. private _softwareSkinnedMeshes;
  92433. private _renderingManager;
  92434. /** @hidden */
  92435. _activeAnimatables: Animatable[];
  92436. private _transformMatrix;
  92437. private _sceneUbo;
  92438. /** @hidden */
  92439. _viewMatrix: Matrix;
  92440. private _projectionMatrix;
  92441. /** @hidden */
  92442. _forcedViewPosition: Nullable<Vector3>;
  92443. /** @hidden */
  92444. _frustumPlanes: Plane[];
  92445. /**
  92446. * Gets the list of frustum planes (built from the active camera)
  92447. */
  92448. readonly frustumPlanes: Plane[];
  92449. /**
  92450. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92451. * This is useful if there are more lights that the maximum simulteanous authorized
  92452. */
  92453. requireLightSorting: boolean;
  92454. /** @hidden */
  92455. readonly useMaterialMeshMap: boolean;
  92456. /** @hidden */
  92457. readonly useClonedMeshhMap: boolean;
  92458. private _externalData;
  92459. private _uid;
  92460. /**
  92461. * @hidden
  92462. * Backing store of defined scene components.
  92463. */
  92464. _components: ISceneComponent[];
  92465. /**
  92466. * @hidden
  92467. * Backing store of defined scene components.
  92468. */
  92469. _serializableComponents: ISceneSerializableComponent[];
  92470. /**
  92471. * List of components to register on the next registration step.
  92472. */
  92473. private _transientComponents;
  92474. /**
  92475. * Registers the transient components if needed.
  92476. */
  92477. private _registerTransientComponents;
  92478. /**
  92479. * @hidden
  92480. * Add a component to the scene.
  92481. * Note that the ccomponent could be registered on th next frame if this is called after
  92482. * the register component stage.
  92483. * @param component Defines the component to add to the scene
  92484. */
  92485. _addComponent(component: ISceneComponent): void;
  92486. /**
  92487. * @hidden
  92488. * Gets a component from the scene.
  92489. * @param name defines the name of the component to retrieve
  92490. * @returns the component or null if not present
  92491. */
  92492. _getComponent(name: string): Nullable<ISceneComponent>;
  92493. /**
  92494. * @hidden
  92495. * Defines the actions happening before camera updates.
  92496. */
  92497. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92498. /**
  92499. * @hidden
  92500. * Defines the actions happening before clear the canvas.
  92501. */
  92502. _beforeClearStage: Stage<SimpleStageAction>;
  92503. /**
  92504. * @hidden
  92505. * Defines the actions when collecting render targets for the frame.
  92506. */
  92507. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92508. /**
  92509. * @hidden
  92510. * Defines the actions happening for one camera in the frame.
  92511. */
  92512. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92513. /**
  92514. * @hidden
  92515. * Defines the actions happening during the per mesh ready checks.
  92516. */
  92517. _isReadyForMeshStage: Stage<MeshStageAction>;
  92518. /**
  92519. * @hidden
  92520. * Defines the actions happening before evaluate active mesh checks.
  92521. */
  92522. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92523. /**
  92524. * @hidden
  92525. * Defines the actions happening during the evaluate sub mesh checks.
  92526. */
  92527. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92528. /**
  92529. * @hidden
  92530. * Defines the actions happening during the active mesh stage.
  92531. */
  92532. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92533. /**
  92534. * @hidden
  92535. * Defines the actions happening during the per camera render target step.
  92536. */
  92537. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92538. /**
  92539. * @hidden
  92540. * Defines the actions happening just before the active camera is drawing.
  92541. */
  92542. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92543. /**
  92544. * @hidden
  92545. * Defines the actions happening just before a render target is drawing.
  92546. */
  92547. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92548. /**
  92549. * @hidden
  92550. * Defines the actions happening just before a rendering group is drawing.
  92551. */
  92552. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92553. /**
  92554. * @hidden
  92555. * Defines the actions happening just before a mesh is drawing.
  92556. */
  92557. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92558. /**
  92559. * @hidden
  92560. * Defines the actions happening just after a mesh has been drawn.
  92561. */
  92562. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92563. /**
  92564. * @hidden
  92565. * Defines the actions happening just after a rendering group has been drawn.
  92566. */
  92567. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92568. /**
  92569. * @hidden
  92570. * Defines the actions happening just after the active camera has been drawn.
  92571. */
  92572. _afterCameraDrawStage: Stage<CameraStageAction>;
  92573. /**
  92574. * @hidden
  92575. * Defines the actions happening just after a render target has been drawn.
  92576. */
  92577. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92578. /**
  92579. * @hidden
  92580. * Defines the actions happening just after rendering all cameras and computing intersections.
  92581. */
  92582. _afterRenderStage: Stage<SimpleStageAction>;
  92583. /**
  92584. * @hidden
  92585. * Defines the actions happening when a pointer move event happens.
  92586. */
  92587. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92588. /**
  92589. * @hidden
  92590. * Defines the actions happening when a pointer down event happens.
  92591. */
  92592. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92593. /**
  92594. * @hidden
  92595. * Defines the actions happening when a pointer up event happens.
  92596. */
  92597. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92598. /**
  92599. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92600. */
  92601. private geometriesByUniqueId;
  92602. /**
  92603. * Creates a new Scene
  92604. * @param engine defines the engine to use to render this scene
  92605. * @param options defines the scene options
  92606. */
  92607. constructor(engine: Engine, options?: SceneOptions);
  92608. /**
  92609. * Gets a string idenfifying the name of the class
  92610. * @returns "Scene" string
  92611. */
  92612. getClassName(): string;
  92613. private _defaultMeshCandidates;
  92614. /**
  92615. * @hidden
  92616. */
  92617. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92618. private _defaultSubMeshCandidates;
  92619. /**
  92620. * @hidden
  92621. */
  92622. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92623. /**
  92624. * Sets the default candidate providers for the scene.
  92625. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92626. * and getCollidingSubMeshCandidates to their default function
  92627. */
  92628. setDefaultCandidateProviders(): void;
  92629. /**
  92630. * Gets the mesh that is currently under the pointer
  92631. */
  92632. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92633. /**
  92634. * Gets or sets the current on-screen X position of the pointer
  92635. */
  92636. pointerX: number;
  92637. /**
  92638. * Gets or sets the current on-screen Y position of the pointer
  92639. */
  92640. pointerY: number;
  92641. /**
  92642. * Gets the cached material (ie. the latest rendered one)
  92643. * @returns the cached material
  92644. */
  92645. getCachedMaterial(): Nullable<Material>;
  92646. /**
  92647. * Gets the cached effect (ie. the latest rendered one)
  92648. * @returns the cached effect
  92649. */
  92650. getCachedEffect(): Nullable<Effect>;
  92651. /**
  92652. * Gets the cached visibility state (ie. the latest rendered one)
  92653. * @returns the cached visibility state
  92654. */
  92655. getCachedVisibility(): Nullable<number>;
  92656. /**
  92657. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92658. * @param material defines the current material
  92659. * @param effect defines the current effect
  92660. * @param visibility defines the current visibility state
  92661. * @returns true if one parameter is not cached
  92662. */
  92663. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92664. /**
  92665. * Gets the engine associated with the scene
  92666. * @returns an Engine
  92667. */
  92668. getEngine(): Engine;
  92669. /**
  92670. * Gets the total number of vertices rendered per frame
  92671. * @returns the total number of vertices rendered per frame
  92672. */
  92673. getTotalVertices(): number;
  92674. /**
  92675. * Gets the performance counter for total vertices
  92676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92677. */
  92678. readonly totalVerticesPerfCounter: PerfCounter;
  92679. /**
  92680. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92681. * @returns the total number of active indices rendered per frame
  92682. */
  92683. getActiveIndices(): number;
  92684. /**
  92685. * Gets the performance counter for active indices
  92686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92687. */
  92688. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92689. /**
  92690. * Gets the total number of active particles rendered per frame
  92691. * @returns the total number of active particles rendered per frame
  92692. */
  92693. getActiveParticles(): number;
  92694. /**
  92695. * Gets the performance counter for active particles
  92696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92697. */
  92698. readonly activeParticlesPerfCounter: PerfCounter;
  92699. /**
  92700. * Gets the total number of active bones rendered per frame
  92701. * @returns the total number of active bones rendered per frame
  92702. */
  92703. getActiveBones(): number;
  92704. /**
  92705. * Gets the performance counter for active bones
  92706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92707. */
  92708. readonly activeBonesPerfCounter: PerfCounter;
  92709. /**
  92710. * Gets the array of active meshes
  92711. * @returns an array of AbstractMesh
  92712. */
  92713. getActiveMeshes(): SmartArray<AbstractMesh>;
  92714. /**
  92715. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92716. * @returns a number
  92717. */
  92718. getAnimationRatio(): number;
  92719. /**
  92720. * Gets an unique Id for the current render phase
  92721. * @returns a number
  92722. */
  92723. getRenderId(): number;
  92724. /**
  92725. * Gets an unique Id for the current frame
  92726. * @returns a number
  92727. */
  92728. getFrameId(): number;
  92729. /** Call this function if you want to manually increment the render Id*/
  92730. incrementRenderId(): void;
  92731. private _createUbo;
  92732. /**
  92733. * Use this method to simulate a pointer move on a mesh
  92734. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92735. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92736. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92737. * @returns the current scene
  92738. */
  92739. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92740. /**
  92741. * Use this method to simulate a pointer down on a mesh
  92742. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92743. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92744. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92745. * @returns the current scene
  92746. */
  92747. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92748. /**
  92749. * Use this method to simulate a pointer up on a mesh
  92750. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92751. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92752. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92753. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92754. * @returns the current scene
  92755. */
  92756. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92757. /**
  92758. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92759. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92760. * @returns true if the pointer was captured
  92761. */
  92762. isPointerCaptured(pointerId?: number): boolean;
  92763. /**
  92764. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92765. * @param attachUp defines if you want to attach events to pointerup
  92766. * @param attachDown defines if you want to attach events to pointerdown
  92767. * @param attachMove defines if you want to attach events to pointermove
  92768. */
  92769. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92770. /** Detaches all event handlers*/
  92771. detachControl(): void;
  92772. /**
  92773. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92774. * Delay loaded resources are not taking in account
  92775. * @return true if all required resources are ready
  92776. */
  92777. isReady(): boolean;
  92778. /** Resets all cached information relative to material (including effect and visibility) */
  92779. resetCachedMaterial(): void;
  92780. /**
  92781. * Registers a function to be called before every frame render
  92782. * @param func defines the function to register
  92783. */
  92784. registerBeforeRender(func: () => void): void;
  92785. /**
  92786. * Unregisters a function called before every frame render
  92787. * @param func defines the function to unregister
  92788. */
  92789. unregisterBeforeRender(func: () => void): void;
  92790. /**
  92791. * Registers a function to be called after every frame render
  92792. * @param func defines the function to register
  92793. */
  92794. registerAfterRender(func: () => void): void;
  92795. /**
  92796. * Unregisters a function called after every frame render
  92797. * @param func defines the function to unregister
  92798. */
  92799. unregisterAfterRender(func: () => void): void;
  92800. private _executeOnceBeforeRender;
  92801. /**
  92802. * The provided function will run before render once and will be disposed afterwards.
  92803. * A timeout delay can be provided so that the function will be executed in N ms.
  92804. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92805. * @param func The function to be executed.
  92806. * @param timeout optional delay in ms
  92807. */
  92808. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92809. /** @hidden */
  92810. _addPendingData(data: any): void;
  92811. /** @hidden */
  92812. _removePendingData(data: any): void;
  92813. /**
  92814. * Returns the number of items waiting to be loaded
  92815. * @returns the number of items waiting to be loaded
  92816. */
  92817. getWaitingItemsCount(): number;
  92818. /**
  92819. * Returns a boolean indicating if the scene is still loading data
  92820. */
  92821. readonly isLoading: boolean;
  92822. /**
  92823. * Registers a function to be executed when the scene is ready
  92824. * @param {Function} func - the function to be executed
  92825. */
  92826. executeWhenReady(func: () => void): void;
  92827. /**
  92828. * Returns a promise that resolves when the scene is ready
  92829. * @returns A promise that resolves when the scene is ready
  92830. */
  92831. whenReadyAsync(): Promise<void>;
  92832. /** @hidden */
  92833. _checkIsReady(): void;
  92834. /**
  92835. * Gets all animatable attached to the scene
  92836. */
  92837. readonly animatables: Animatable[];
  92838. /**
  92839. * Resets the last animation time frame.
  92840. * Useful to override when animations start running when loading a scene for the first time.
  92841. */
  92842. resetLastAnimationTimeFrame(): void;
  92843. /**
  92844. * Gets the current view matrix
  92845. * @returns a Matrix
  92846. */
  92847. getViewMatrix(): Matrix;
  92848. /**
  92849. * Gets the current projection matrix
  92850. * @returns a Matrix
  92851. */
  92852. getProjectionMatrix(): Matrix;
  92853. /**
  92854. * Gets the current transform matrix
  92855. * @returns a Matrix made of View * Projection
  92856. */
  92857. getTransformMatrix(): Matrix;
  92858. /**
  92859. * Sets the current transform matrix
  92860. * @param viewL defines the View matrix to use
  92861. * @param projectionL defines the Projection matrix to use
  92862. * @param viewR defines the right View matrix to use (if provided)
  92863. * @param projectionR defines the right Projection matrix to use (if provided)
  92864. */
  92865. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92866. /**
  92867. * Gets the uniform buffer used to store scene data
  92868. * @returns a UniformBuffer
  92869. */
  92870. getSceneUniformBuffer(): UniformBuffer;
  92871. /**
  92872. * Gets an unique (relatively to the current scene) Id
  92873. * @returns an unique number for the scene
  92874. */
  92875. getUniqueId(): number;
  92876. /**
  92877. * Add a mesh to the list of scene's meshes
  92878. * @param newMesh defines the mesh to add
  92879. * @param recursive if all child meshes should also be added to the scene
  92880. */
  92881. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92882. /**
  92883. * Remove a mesh for the list of scene's meshes
  92884. * @param toRemove defines the mesh to remove
  92885. * @param recursive if all child meshes should also be removed from the scene
  92886. * @returns the index where the mesh was in the mesh list
  92887. */
  92888. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92889. /**
  92890. * Add a transform node to the list of scene's transform nodes
  92891. * @param newTransformNode defines the transform node to add
  92892. */
  92893. addTransformNode(newTransformNode: TransformNode): void;
  92894. /**
  92895. * Remove a transform node for the list of scene's transform nodes
  92896. * @param toRemove defines the transform node to remove
  92897. * @returns the index where the transform node was in the transform node list
  92898. */
  92899. removeTransformNode(toRemove: TransformNode): number;
  92900. /**
  92901. * Remove a skeleton for the list of scene's skeletons
  92902. * @param toRemove defines the skeleton to remove
  92903. * @returns the index where the skeleton was in the skeleton list
  92904. */
  92905. removeSkeleton(toRemove: Skeleton): number;
  92906. /**
  92907. * Remove a morph target for the list of scene's morph targets
  92908. * @param toRemove defines the morph target to remove
  92909. * @returns the index where the morph target was in the morph target list
  92910. */
  92911. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92912. /**
  92913. * Remove a light for the list of scene's lights
  92914. * @param toRemove defines the light to remove
  92915. * @returns the index where the light was in the light list
  92916. */
  92917. removeLight(toRemove: Light): number;
  92918. /**
  92919. * Remove a camera for the list of scene's cameras
  92920. * @param toRemove defines the camera to remove
  92921. * @returns the index where the camera was in the camera list
  92922. */
  92923. removeCamera(toRemove: Camera): number;
  92924. /**
  92925. * Remove a particle system for the list of scene's particle systems
  92926. * @param toRemove defines the particle system to remove
  92927. * @returns the index where the particle system was in the particle system list
  92928. */
  92929. removeParticleSystem(toRemove: IParticleSystem): number;
  92930. /**
  92931. * Remove a animation for the list of scene's animations
  92932. * @param toRemove defines the animation to remove
  92933. * @returns the index where the animation was in the animation list
  92934. */
  92935. removeAnimation(toRemove: Animation): number;
  92936. /**
  92937. * Removes the given animation group from this scene.
  92938. * @param toRemove The animation group to remove
  92939. * @returns The index of the removed animation group
  92940. */
  92941. removeAnimationGroup(toRemove: AnimationGroup): number;
  92942. /**
  92943. * Removes the given multi-material from this scene.
  92944. * @param toRemove The multi-material to remove
  92945. * @returns The index of the removed multi-material
  92946. */
  92947. removeMultiMaterial(toRemove: MultiMaterial): number;
  92948. /**
  92949. * Removes the given material from this scene.
  92950. * @param toRemove The material to remove
  92951. * @returns The index of the removed material
  92952. */
  92953. removeMaterial(toRemove: Material): number;
  92954. /**
  92955. * Removes the given action manager from this scene.
  92956. * @param toRemove The action manager to remove
  92957. * @returns The index of the removed action manager
  92958. */
  92959. removeActionManager(toRemove: AbstractActionManager): number;
  92960. /**
  92961. * Removes the given texture from this scene.
  92962. * @param toRemove The texture to remove
  92963. * @returns The index of the removed texture
  92964. */
  92965. removeTexture(toRemove: BaseTexture): number;
  92966. /**
  92967. * Adds the given light to this scene
  92968. * @param newLight The light to add
  92969. */
  92970. addLight(newLight: Light): void;
  92971. /**
  92972. * Sorts the list list based on light priorities
  92973. */
  92974. sortLightsByPriority(): void;
  92975. /**
  92976. * Adds the given camera to this scene
  92977. * @param newCamera The camera to add
  92978. */
  92979. addCamera(newCamera: Camera): void;
  92980. /**
  92981. * Adds the given skeleton to this scene
  92982. * @param newSkeleton The skeleton to add
  92983. */
  92984. addSkeleton(newSkeleton: Skeleton): void;
  92985. /**
  92986. * Adds the given particle system to this scene
  92987. * @param newParticleSystem The particle system to add
  92988. */
  92989. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92990. /**
  92991. * Adds the given animation to this scene
  92992. * @param newAnimation The animation to add
  92993. */
  92994. addAnimation(newAnimation: Animation): void;
  92995. /**
  92996. * Adds the given animation group to this scene.
  92997. * @param newAnimationGroup The animation group to add
  92998. */
  92999. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93000. /**
  93001. * Adds the given multi-material to this scene
  93002. * @param newMultiMaterial The multi-material to add
  93003. */
  93004. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93005. /**
  93006. * Adds the given material to this scene
  93007. * @param newMaterial The material to add
  93008. */
  93009. addMaterial(newMaterial: Material): void;
  93010. /**
  93011. * Adds the given morph target to this scene
  93012. * @param newMorphTargetManager The morph target to add
  93013. */
  93014. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93015. /**
  93016. * Adds the given geometry to this scene
  93017. * @param newGeometry The geometry to add
  93018. */
  93019. addGeometry(newGeometry: Geometry): void;
  93020. /**
  93021. * Adds the given action manager to this scene
  93022. * @param newActionManager The action manager to add
  93023. */
  93024. addActionManager(newActionManager: AbstractActionManager): void;
  93025. /**
  93026. * Adds the given texture to this scene.
  93027. * @param newTexture The texture to add
  93028. */
  93029. addTexture(newTexture: BaseTexture): void;
  93030. /**
  93031. * Switch active camera
  93032. * @param newCamera defines the new active camera
  93033. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93034. */
  93035. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93036. /**
  93037. * sets the active camera of the scene using its ID
  93038. * @param id defines the camera's ID
  93039. * @return the new active camera or null if none found.
  93040. */
  93041. setActiveCameraByID(id: string): Nullable<Camera>;
  93042. /**
  93043. * sets the active camera of the scene using its name
  93044. * @param name defines the camera's name
  93045. * @returns the new active camera or null if none found.
  93046. */
  93047. setActiveCameraByName(name: string): Nullable<Camera>;
  93048. /**
  93049. * get an animation group using its name
  93050. * @param name defines the material's name
  93051. * @return the animation group or null if none found.
  93052. */
  93053. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93054. /**
  93055. * Get a material using its unique id
  93056. * @param uniqueId defines the material's unique id
  93057. * @return the material or null if none found.
  93058. */
  93059. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93060. /**
  93061. * get a material using its id
  93062. * @param id defines the material's ID
  93063. * @return the material or null if none found.
  93064. */
  93065. getMaterialByID(id: string): Nullable<Material>;
  93066. /**
  93067. * Gets a material using its name
  93068. * @param name defines the material's name
  93069. * @return the material or null if none found.
  93070. */
  93071. getMaterialByName(name: string): Nullable<Material>;
  93072. /**
  93073. * Gets a camera using its id
  93074. * @param id defines the id to look for
  93075. * @returns the camera or null if not found
  93076. */
  93077. getCameraByID(id: string): Nullable<Camera>;
  93078. /**
  93079. * Gets a camera using its unique id
  93080. * @param uniqueId defines the unique id to look for
  93081. * @returns the camera or null if not found
  93082. */
  93083. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93084. /**
  93085. * Gets a camera using its name
  93086. * @param name defines the camera's name
  93087. * @return the camera or null if none found.
  93088. */
  93089. getCameraByName(name: string): Nullable<Camera>;
  93090. /**
  93091. * Gets a bone using its id
  93092. * @param id defines the bone's id
  93093. * @return the bone or null if not found
  93094. */
  93095. getBoneByID(id: string): Nullable<Bone>;
  93096. /**
  93097. * Gets a bone using its id
  93098. * @param name defines the bone's name
  93099. * @return the bone or null if not found
  93100. */
  93101. getBoneByName(name: string): Nullable<Bone>;
  93102. /**
  93103. * Gets a light node using its name
  93104. * @param name defines the the light's name
  93105. * @return the light or null if none found.
  93106. */
  93107. getLightByName(name: string): Nullable<Light>;
  93108. /**
  93109. * Gets a light node using its id
  93110. * @param id defines the light's id
  93111. * @return the light or null if none found.
  93112. */
  93113. getLightByID(id: string): Nullable<Light>;
  93114. /**
  93115. * Gets a light node using its scene-generated unique ID
  93116. * @param uniqueId defines the light's unique id
  93117. * @return the light or null if none found.
  93118. */
  93119. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93120. /**
  93121. * Gets a particle system by id
  93122. * @param id defines the particle system id
  93123. * @return the corresponding system or null if none found
  93124. */
  93125. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93126. /**
  93127. * Gets a geometry using its ID
  93128. * @param id defines the geometry's id
  93129. * @return the geometry or null if none found.
  93130. */
  93131. getGeometryByID(id: string): Nullable<Geometry>;
  93132. private _getGeometryByUniqueID;
  93133. /**
  93134. * Add a new geometry to this scene
  93135. * @param geometry defines the geometry to be added to the scene.
  93136. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93137. * @return a boolean defining if the geometry was added or not
  93138. */
  93139. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93140. /**
  93141. * Removes an existing geometry
  93142. * @param geometry defines the geometry to be removed from the scene
  93143. * @return a boolean defining if the geometry was removed or not
  93144. */
  93145. removeGeometry(geometry: Geometry): boolean;
  93146. /**
  93147. * Gets the list of geometries attached to the scene
  93148. * @returns an array of Geometry
  93149. */
  93150. getGeometries(): Geometry[];
  93151. /**
  93152. * Gets the first added mesh found of a given ID
  93153. * @param id defines the id to search for
  93154. * @return the mesh found or null if not found at all
  93155. */
  93156. getMeshByID(id: string): Nullable<AbstractMesh>;
  93157. /**
  93158. * Gets a list of meshes using their id
  93159. * @param id defines the id to search for
  93160. * @returns a list of meshes
  93161. */
  93162. getMeshesByID(id: string): Array<AbstractMesh>;
  93163. /**
  93164. * Gets the first added transform node found of a given ID
  93165. * @param id defines the id to search for
  93166. * @return the found transform node or null if not found at all.
  93167. */
  93168. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93169. /**
  93170. * Gets a transform node with its auto-generated unique id
  93171. * @param uniqueId efines the unique id to search for
  93172. * @return the found transform node or null if not found at all.
  93173. */
  93174. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93175. /**
  93176. * Gets a list of transform nodes using their id
  93177. * @param id defines the id to search for
  93178. * @returns a list of transform nodes
  93179. */
  93180. getTransformNodesByID(id: string): Array<TransformNode>;
  93181. /**
  93182. * Gets a mesh with its auto-generated unique id
  93183. * @param uniqueId defines the unique id to search for
  93184. * @return the found mesh or null if not found at all.
  93185. */
  93186. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93187. /**
  93188. * Gets a the last added mesh using a given id
  93189. * @param id defines the id to search for
  93190. * @return the found mesh or null if not found at all.
  93191. */
  93192. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93193. /**
  93194. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93195. * @param id defines the id to search for
  93196. * @return the found node or null if not found at all
  93197. */
  93198. getLastEntryByID(id: string): Nullable<Node>;
  93199. /**
  93200. * Gets a node (Mesh, Camera, Light) using a given id
  93201. * @param id defines the id to search for
  93202. * @return the found node or null if not found at all
  93203. */
  93204. getNodeByID(id: string): Nullable<Node>;
  93205. /**
  93206. * Gets a node (Mesh, Camera, Light) using a given name
  93207. * @param name defines the name to search for
  93208. * @return the found node or null if not found at all.
  93209. */
  93210. getNodeByName(name: string): Nullable<Node>;
  93211. /**
  93212. * Gets a mesh using a given name
  93213. * @param name defines the name to search for
  93214. * @return the found mesh or null if not found at all.
  93215. */
  93216. getMeshByName(name: string): Nullable<AbstractMesh>;
  93217. /**
  93218. * Gets a transform node using a given name
  93219. * @param name defines the name to search for
  93220. * @return the found transform node or null if not found at all.
  93221. */
  93222. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93223. /**
  93224. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93225. * @param id defines the id to search for
  93226. * @return the found skeleton or null if not found at all.
  93227. */
  93228. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93229. /**
  93230. * Gets a skeleton using a given auto generated unique id
  93231. * @param uniqueId defines the unique id to search for
  93232. * @return the found skeleton or null if not found at all.
  93233. */
  93234. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93235. /**
  93236. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93237. * @param id defines the id to search for
  93238. * @return the found skeleton or null if not found at all.
  93239. */
  93240. getSkeletonById(id: string): Nullable<Skeleton>;
  93241. /**
  93242. * Gets a skeleton using a given name
  93243. * @param name defines the name to search for
  93244. * @return the found skeleton or null if not found at all.
  93245. */
  93246. getSkeletonByName(name: string): Nullable<Skeleton>;
  93247. /**
  93248. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93249. * @param id defines the id to search for
  93250. * @return the found morph target manager or null if not found at all.
  93251. */
  93252. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93253. /**
  93254. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93255. * @param id defines the id to search for
  93256. * @return the found morph target or null if not found at all.
  93257. */
  93258. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93259. /**
  93260. * Gets a boolean indicating if the given mesh is active
  93261. * @param mesh defines the mesh to look for
  93262. * @returns true if the mesh is in the active list
  93263. */
  93264. isActiveMesh(mesh: AbstractMesh): boolean;
  93265. /**
  93266. * Return a unique id as a string which can serve as an identifier for the scene
  93267. */
  93268. readonly uid: string;
  93269. /**
  93270. * Add an externaly attached data from its key.
  93271. * This method call will fail and return false, if such key already exists.
  93272. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93273. * @param key the unique key that identifies the data
  93274. * @param data the data object to associate to the key for this Engine instance
  93275. * @return true if no such key were already present and the data was added successfully, false otherwise
  93276. */
  93277. addExternalData<T>(key: string, data: T): boolean;
  93278. /**
  93279. * Get an externaly attached data from its key
  93280. * @param key the unique key that identifies the data
  93281. * @return the associated data, if present (can be null), or undefined if not present
  93282. */
  93283. getExternalData<T>(key: string): Nullable<T>;
  93284. /**
  93285. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93286. * @param key the unique key that identifies the data
  93287. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93288. * @return the associated data, can be null if the factory returned null.
  93289. */
  93290. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93291. /**
  93292. * Remove an externaly attached data from the Engine instance
  93293. * @param key the unique key that identifies the data
  93294. * @return true if the data was successfully removed, false if it doesn't exist
  93295. */
  93296. removeExternalData(key: string): boolean;
  93297. private _evaluateSubMesh;
  93298. /**
  93299. * Clear the processed materials smart array preventing retention point in material dispose.
  93300. */
  93301. freeProcessedMaterials(): void;
  93302. private _preventFreeActiveMeshesAndRenderingGroups;
  93303. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93304. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93305. * when disposing several meshes in a row or a hierarchy of meshes.
  93306. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93307. */
  93308. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93309. /**
  93310. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93311. */
  93312. freeActiveMeshes(): void;
  93313. /**
  93314. * Clear the info related to rendering groups preventing retention points during dispose.
  93315. */
  93316. freeRenderingGroups(): void;
  93317. /** @hidden */
  93318. _isInIntermediateRendering(): boolean;
  93319. /**
  93320. * Lambda returning the list of potentially active meshes.
  93321. */
  93322. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93323. /**
  93324. * Lambda returning the list of potentially active sub meshes.
  93325. */
  93326. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93327. /**
  93328. * Lambda returning the list of potentially intersecting sub meshes.
  93329. */
  93330. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93331. /**
  93332. * Lambda returning the list of potentially colliding sub meshes.
  93333. */
  93334. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93335. private _activeMeshesFrozen;
  93336. /**
  93337. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93338. * @returns the current scene
  93339. */
  93340. freezeActiveMeshes(): Scene;
  93341. /**
  93342. * Use this function to restart evaluating active meshes on every frame
  93343. * @returns the current scene
  93344. */
  93345. unfreezeActiveMeshes(): Scene;
  93346. private _evaluateActiveMeshes;
  93347. private _activeMesh;
  93348. /**
  93349. * Update the transform matrix to update from the current active camera
  93350. * @param force defines a boolean used to force the update even if cache is up to date
  93351. */
  93352. updateTransformMatrix(force?: boolean): void;
  93353. private _bindFrameBuffer;
  93354. /** @hidden */
  93355. _allowPostProcessClearColor: boolean;
  93356. /** @hidden */
  93357. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93358. private _processSubCameras;
  93359. private _checkIntersections;
  93360. /** @hidden */
  93361. _advancePhysicsEngineStep(step: number): void;
  93362. /**
  93363. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93364. */
  93365. getDeterministicFrameTime: () => number;
  93366. /** @hidden */
  93367. _animate(): void;
  93368. /** Execute all animations (for a frame) */
  93369. animate(): void;
  93370. /**
  93371. * Render the scene
  93372. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93373. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93374. */
  93375. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93376. /**
  93377. * Freeze all materials
  93378. * A frozen material will not be updatable but should be faster to render
  93379. */
  93380. freezeMaterials(): void;
  93381. /**
  93382. * Unfreeze all materials
  93383. * A frozen material will not be updatable but should be faster to render
  93384. */
  93385. unfreezeMaterials(): void;
  93386. /**
  93387. * Releases all held ressources
  93388. */
  93389. dispose(): void;
  93390. /**
  93391. * Gets if the scene is already disposed
  93392. */
  93393. readonly isDisposed: boolean;
  93394. /**
  93395. * Call this function to reduce memory footprint of the scene.
  93396. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93397. */
  93398. clearCachedVertexData(): void;
  93399. /**
  93400. * This function will remove the local cached buffer data from texture.
  93401. * It will save memory but will prevent the texture from being rebuilt
  93402. */
  93403. cleanCachedTextureBuffer(): void;
  93404. /**
  93405. * Get the world extend vectors with an optional filter
  93406. *
  93407. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93408. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93409. */
  93410. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93411. min: Vector3;
  93412. max: Vector3;
  93413. };
  93414. /**
  93415. * Creates a ray that can be used to pick in the scene
  93416. * @param x defines the x coordinate of the origin (on-screen)
  93417. * @param y defines the y coordinate of the origin (on-screen)
  93418. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93419. * @param camera defines the camera to use for the picking
  93420. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93421. * @returns a Ray
  93422. */
  93423. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93424. /**
  93425. * Creates a ray that can be used to pick in the scene
  93426. * @param x defines the x coordinate of the origin (on-screen)
  93427. * @param y defines the y coordinate of the origin (on-screen)
  93428. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93429. * @param result defines the ray where to store the picking ray
  93430. * @param camera defines the camera to use for the picking
  93431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93432. * @returns the current scene
  93433. */
  93434. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93435. /**
  93436. * Creates a ray that can be used to pick in the scene
  93437. * @param x defines the x coordinate of the origin (on-screen)
  93438. * @param y defines the y coordinate of the origin (on-screen)
  93439. * @param camera defines the camera to use for the picking
  93440. * @returns a Ray
  93441. */
  93442. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93443. /**
  93444. * Creates a ray that can be used to pick in the scene
  93445. * @param x defines the x coordinate of the origin (on-screen)
  93446. * @param y defines the y coordinate of the origin (on-screen)
  93447. * @param result defines the ray where to store the picking ray
  93448. * @param camera defines the camera to use for the picking
  93449. * @returns the current scene
  93450. */
  93451. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93452. /** Launch a ray to try to pick a mesh in the scene
  93453. * @param x position on screen
  93454. * @param y position on screen
  93455. * @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
  93456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93457. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93459. * @returns a PickingInfo
  93460. */
  93461. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93462. /** Use the given ray to pick a mesh in the scene
  93463. * @param ray The ray to use to pick meshes
  93464. * @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
  93465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93467. * @returns a PickingInfo
  93468. */
  93469. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93470. /**
  93471. * Launch a ray to try to pick a mesh in the scene
  93472. * @param x X position on screen
  93473. * @param y Y position on screen
  93474. * @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
  93475. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93477. * @returns an array of PickingInfo
  93478. */
  93479. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93480. /**
  93481. * Launch a ray to try to pick a mesh in the scene
  93482. * @param ray Ray to use
  93483. * @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
  93484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93485. * @returns an array of PickingInfo
  93486. */
  93487. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93488. /**
  93489. * Force the value of meshUnderPointer
  93490. * @param mesh defines the mesh to use
  93491. */
  93492. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93493. /**
  93494. * Gets the mesh under the pointer
  93495. * @returns a Mesh or null if no mesh is under the pointer
  93496. */
  93497. getPointerOverMesh(): Nullable<AbstractMesh>;
  93498. /** @hidden */
  93499. _rebuildGeometries(): void;
  93500. /** @hidden */
  93501. _rebuildTextures(): void;
  93502. private _getByTags;
  93503. /**
  93504. * Get a list of meshes by tags
  93505. * @param tagsQuery defines the tags query to use
  93506. * @param forEach defines a predicate used to filter results
  93507. * @returns an array of Mesh
  93508. */
  93509. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93510. /**
  93511. * Get a list of cameras by tags
  93512. * @param tagsQuery defines the tags query to use
  93513. * @param forEach defines a predicate used to filter results
  93514. * @returns an array of Camera
  93515. */
  93516. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93517. /**
  93518. * Get a list of lights by tags
  93519. * @param tagsQuery defines the tags query to use
  93520. * @param forEach defines a predicate used to filter results
  93521. * @returns an array of Light
  93522. */
  93523. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93524. /**
  93525. * Get a list of materials by tags
  93526. * @param tagsQuery defines the tags query to use
  93527. * @param forEach defines a predicate used to filter results
  93528. * @returns an array of Material
  93529. */
  93530. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93531. /**
  93532. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93533. * This allowed control for front to back rendering or reversly depending of the special needs.
  93534. *
  93535. * @param renderingGroupId The rendering group id corresponding to its index
  93536. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93537. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93538. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93539. */
  93540. 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;
  93541. /**
  93542. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93543. *
  93544. * @param renderingGroupId The rendering group id corresponding to its index
  93545. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93546. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93547. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93548. */
  93549. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93550. /**
  93551. * Gets the current auto clear configuration for one rendering group of the rendering
  93552. * manager.
  93553. * @param index the rendering group index to get the information for
  93554. * @returns The auto clear setup for the requested rendering group
  93555. */
  93556. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93557. private _blockMaterialDirtyMechanism;
  93558. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93559. blockMaterialDirtyMechanism: boolean;
  93560. /**
  93561. * Will flag all materials as dirty to trigger new shader compilation
  93562. * @param flag defines the flag used to specify which material part must be marked as dirty
  93563. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93564. */
  93565. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93566. /** @hidden */
  93567. _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;
  93568. /** @hidden */
  93569. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93570. }
  93571. }
  93572. declare module BABYLON {
  93573. /**
  93574. * Set of assets to keep when moving a scene into an asset container.
  93575. */
  93576. export class KeepAssets extends AbstractScene {
  93577. }
  93578. /**
  93579. * Container with a set of assets that can be added or removed from a scene.
  93580. */
  93581. export class AssetContainer extends AbstractScene {
  93582. /**
  93583. * The scene the AssetContainer belongs to.
  93584. */
  93585. scene: Scene;
  93586. /**
  93587. * Instantiates an AssetContainer.
  93588. * @param scene The scene the AssetContainer belongs to.
  93589. */
  93590. constructor(scene: Scene);
  93591. /**
  93592. * Adds all the assets from the container to the scene.
  93593. */
  93594. addAllToScene(): void;
  93595. /**
  93596. * Removes all the assets in the container from the scene
  93597. */
  93598. removeAllFromScene(): void;
  93599. /**
  93600. * Disposes all the assets in the container
  93601. */
  93602. dispose(): void;
  93603. private _moveAssets;
  93604. /**
  93605. * Removes all the assets contained in the scene and adds them to the container.
  93606. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93607. */
  93608. moveAllFromScene(keepAssets?: KeepAssets): void;
  93609. /**
  93610. * 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.
  93611. * @returns the root mesh
  93612. */
  93613. createRootMesh(): Mesh;
  93614. }
  93615. }
  93616. declare module BABYLON {
  93617. /**
  93618. * Defines how the parser contract is defined.
  93619. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93620. */
  93621. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93622. /**
  93623. * Defines how the individual parser contract is defined.
  93624. * These parser can parse an individual asset
  93625. */
  93626. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93627. /**
  93628. * Base class of the scene acting as a container for the different elements composing a scene.
  93629. * This class is dynamically extended by the different components of the scene increasing
  93630. * flexibility and reducing coupling
  93631. */
  93632. export abstract class AbstractScene {
  93633. /**
  93634. * Stores the list of available parsers in the application.
  93635. */
  93636. private static _BabylonFileParsers;
  93637. /**
  93638. * Stores the list of available individual parsers in the application.
  93639. */
  93640. private static _IndividualBabylonFileParsers;
  93641. /**
  93642. * Adds a parser in the list of available ones
  93643. * @param name Defines the name of the parser
  93644. * @param parser Defines the parser to add
  93645. */
  93646. static AddParser(name: string, parser: BabylonFileParser): void;
  93647. /**
  93648. * Gets a general parser from the list of avaialble ones
  93649. * @param name Defines the name of the parser
  93650. * @returns the requested parser or null
  93651. */
  93652. static GetParser(name: string): Nullable<BabylonFileParser>;
  93653. /**
  93654. * Adds n individual parser in the list of available ones
  93655. * @param name Defines the name of the parser
  93656. * @param parser Defines the parser to add
  93657. */
  93658. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93659. /**
  93660. * Gets an individual parser from the list of avaialble ones
  93661. * @param name Defines the name of the parser
  93662. * @returns the requested parser or null
  93663. */
  93664. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93665. /**
  93666. * Parser json data and populate both a scene and its associated container object
  93667. * @param jsonData Defines the data to parse
  93668. * @param scene Defines the scene to parse the data for
  93669. * @param container Defines the container attached to the parsing sequence
  93670. * @param rootUrl Defines the root url of the data
  93671. */
  93672. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93673. /**
  93674. * Gets the list of root nodes (ie. nodes with no parent)
  93675. */
  93676. rootNodes: Node[];
  93677. /** All of the cameras added to this scene
  93678. * @see http://doc.babylonjs.com/babylon101/cameras
  93679. */
  93680. cameras: Camera[];
  93681. /**
  93682. * All of the lights added to this scene
  93683. * @see http://doc.babylonjs.com/babylon101/lights
  93684. */
  93685. lights: Light[];
  93686. /**
  93687. * All of the (abstract) meshes added to this scene
  93688. */
  93689. meshes: AbstractMesh[];
  93690. /**
  93691. * The list of skeletons added to the scene
  93692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93693. */
  93694. skeletons: Skeleton[];
  93695. /**
  93696. * All of the particle systems added to this scene
  93697. * @see http://doc.babylonjs.com/babylon101/particles
  93698. */
  93699. particleSystems: IParticleSystem[];
  93700. /**
  93701. * Gets a list of Animations associated with the scene
  93702. */
  93703. animations: Animation[];
  93704. /**
  93705. * All of the animation groups added to this scene
  93706. * @see http://doc.babylonjs.com/how_to/group
  93707. */
  93708. animationGroups: AnimationGroup[];
  93709. /**
  93710. * All of the multi-materials added to this scene
  93711. * @see http://doc.babylonjs.com/how_to/multi_materials
  93712. */
  93713. multiMaterials: MultiMaterial[];
  93714. /**
  93715. * All of the materials added to this scene
  93716. * In the context of a Scene, it is not supposed to be modified manually.
  93717. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93718. * Note also that the order of the Material wihin the array is not significant and might change.
  93719. * @see http://doc.babylonjs.com/babylon101/materials
  93720. */
  93721. materials: Material[];
  93722. /**
  93723. * The list of morph target managers added to the scene
  93724. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93725. */
  93726. morphTargetManagers: MorphTargetManager[];
  93727. /**
  93728. * The list of geometries used in the scene.
  93729. */
  93730. geometries: Geometry[];
  93731. /**
  93732. * All of the tranform nodes added to this scene
  93733. * In the context of a Scene, it is not supposed to be modified manually.
  93734. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93735. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93736. * @see http://doc.babylonjs.com/how_to/transformnode
  93737. */
  93738. transformNodes: TransformNode[];
  93739. /**
  93740. * ActionManagers available on the scene.
  93741. */
  93742. actionManagers: AbstractActionManager[];
  93743. /**
  93744. * Textures to keep.
  93745. */
  93746. textures: BaseTexture[];
  93747. /**
  93748. * Environment texture for the scene
  93749. */
  93750. environmentTexture: Nullable<BaseTexture>;
  93751. }
  93752. }
  93753. declare module BABYLON {
  93754. /**
  93755. * Defines a sound that can be played in the application.
  93756. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93758. */
  93759. export class Sound {
  93760. /**
  93761. * The name of the sound in the scene.
  93762. */
  93763. name: string;
  93764. /**
  93765. * Does the sound autoplay once loaded.
  93766. */
  93767. autoplay: boolean;
  93768. /**
  93769. * Does the sound loop after it finishes playing once.
  93770. */
  93771. loop: boolean;
  93772. /**
  93773. * Does the sound use a custom attenuation curve to simulate the falloff
  93774. * happening when the source gets further away from the camera.
  93775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93776. */
  93777. useCustomAttenuation: boolean;
  93778. /**
  93779. * The sound track id this sound belongs to.
  93780. */
  93781. soundTrackId: number;
  93782. /**
  93783. * Is this sound currently played.
  93784. */
  93785. isPlaying: boolean;
  93786. /**
  93787. * Is this sound currently paused.
  93788. */
  93789. isPaused: boolean;
  93790. /**
  93791. * Does this sound enables spatial sound.
  93792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93793. */
  93794. spatialSound: boolean;
  93795. /**
  93796. * Define the reference distance the sound should be heard perfectly.
  93797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93798. */
  93799. refDistance: number;
  93800. /**
  93801. * Define the roll off factor of spatial sounds.
  93802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93803. */
  93804. rolloffFactor: number;
  93805. /**
  93806. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93808. */
  93809. maxDistance: number;
  93810. /**
  93811. * Define the distance attenuation model the sound will follow.
  93812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93813. */
  93814. distanceModel: string;
  93815. /**
  93816. * @hidden
  93817. * Back Compat
  93818. **/
  93819. onended: () => any;
  93820. /**
  93821. * Observable event when the current playing sound finishes.
  93822. */
  93823. onEndedObservable: Observable<Sound>;
  93824. private _panningModel;
  93825. private _playbackRate;
  93826. private _streaming;
  93827. private _startTime;
  93828. private _startOffset;
  93829. private _position;
  93830. /** @hidden */
  93831. _positionInEmitterSpace: boolean;
  93832. private _localDirection;
  93833. private _volume;
  93834. private _isReadyToPlay;
  93835. private _isDirectional;
  93836. private _readyToPlayCallback;
  93837. private _audioBuffer;
  93838. private _soundSource;
  93839. private _streamingSource;
  93840. private _soundPanner;
  93841. private _soundGain;
  93842. private _inputAudioNode;
  93843. private _outputAudioNode;
  93844. private _coneInnerAngle;
  93845. private _coneOuterAngle;
  93846. private _coneOuterGain;
  93847. private _scene;
  93848. private _connectedTransformNode;
  93849. private _customAttenuationFunction;
  93850. private _registerFunc;
  93851. private _isOutputConnected;
  93852. private _htmlAudioElement;
  93853. private _urlType;
  93854. /** @hidden */
  93855. static _SceneComponentInitialization: (scene: Scene) => void;
  93856. /**
  93857. * Create a sound and attach it to a scene
  93858. * @param name Name of your sound
  93859. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93860. * @param scene defines the scene the sound belongs to
  93861. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93862. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93863. */
  93864. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93865. /**
  93866. * Release the sound and its associated resources
  93867. */
  93868. dispose(): void;
  93869. /**
  93870. * Gets if the sounds is ready to be played or not.
  93871. * @returns true if ready, otherwise false
  93872. */
  93873. isReady(): boolean;
  93874. private _soundLoaded;
  93875. /**
  93876. * Sets the data of the sound from an audiobuffer
  93877. * @param audioBuffer The audioBuffer containing the data
  93878. */
  93879. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93880. /**
  93881. * Updates the current sounds options such as maxdistance, loop...
  93882. * @param options A JSON object containing values named as the object properties
  93883. */
  93884. updateOptions(options: any): void;
  93885. private _createSpatialParameters;
  93886. private _updateSpatialParameters;
  93887. /**
  93888. * Switch the panning model to HRTF:
  93889. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93891. */
  93892. switchPanningModelToHRTF(): void;
  93893. /**
  93894. * Switch the panning model to Equal Power:
  93895. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93897. */
  93898. switchPanningModelToEqualPower(): void;
  93899. private _switchPanningModel;
  93900. /**
  93901. * Connect this sound to a sound track audio node like gain...
  93902. * @param soundTrackAudioNode the sound track audio node to connect to
  93903. */
  93904. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93905. /**
  93906. * Transform this sound into a directional source
  93907. * @param coneInnerAngle Size of the inner cone in degree
  93908. * @param coneOuterAngle Size of the outer cone in degree
  93909. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93910. */
  93911. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93912. /**
  93913. * Gets or sets the inner angle for the directional cone.
  93914. */
  93915. /**
  93916. * Gets or sets the inner angle for the directional cone.
  93917. */
  93918. directionalConeInnerAngle: number;
  93919. /**
  93920. * Gets or sets the outer angle for the directional cone.
  93921. */
  93922. /**
  93923. * Gets or sets the outer angle for the directional cone.
  93924. */
  93925. directionalConeOuterAngle: number;
  93926. /**
  93927. * Sets the position of the emitter if spatial sound is enabled
  93928. * @param newPosition Defines the new posisiton
  93929. */
  93930. setPosition(newPosition: Vector3): void;
  93931. /**
  93932. * Sets the local direction of the emitter if spatial sound is enabled
  93933. * @param newLocalDirection Defines the new local direction
  93934. */
  93935. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93936. private _updateDirection;
  93937. /** @hidden */
  93938. updateDistanceFromListener(): void;
  93939. /**
  93940. * Sets a new custom attenuation function for the sound.
  93941. * @param callback Defines the function used for the attenuation
  93942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93943. */
  93944. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93945. /**
  93946. * Play the sound
  93947. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93948. * @param offset (optional) Start the sound setting it at a specific time
  93949. */
  93950. play(time?: number, offset?: number): void;
  93951. private _onended;
  93952. /**
  93953. * Stop the sound
  93954. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93955. */
  93956. stop(time?: number): void;
  93957. /**
  93958. * Put the sound in pause
  93959. */
  93960. pause(): void;
  93961. /**
  93962. * Sets a dedicated volume for this sounds
  93963. * @param newVolume Define the new volume of the sound
  93964. * @param time Define in how long the sound should be at this value
  93965. */
  93966. setVolume(newVolume: number, time?: number): void;
  93967. /**
  93968. * Set the sound play back rate
  93969. * @param newPlaybackRate Define the playback rate the sound should be played at
  93970. */
  93971. setPlaybackRate(newPlaybackRate: number): void;
  93972. /**
  93973. * Gets the volume of the sound.
  93974. * @returns the volume of the sound
  93975. */
  93976. getVolume(): number;
  93977. /**
  93978. * Attach the sound to a dedicated mesh
  93979. * @param transformNode The transform node to connect the sound with
  93980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93981. */
  93982. attachToMesh(transformNode: TransformNode): void;
  93983. /**
  93984. * Detach the sound from the previously attached mesh
  93985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93986. */
  93987. detachFromMesh(): void;
  93988. private _onRegisterAfterWorldMatrixUpdate;
  93989. /**
  93990. * Clone the current sound in the scene.
  93991. * @returns the new sound clone
  93992. */
  93993. clone(): Nullable<Sound>;
  93994. /**
  93995. * Gets the current underlying audio buffer containing the data
  93996. * @returns the audio buffer
  93997. */
  93998. getAudioBuffer(): Nullable<AudioBuffer>;
  93999. /**
  94000. * Serializes the Sound in a JSON representation
  94001. * @returns the JSON representation of the sound
  94002. */
  94003. serialize(): any;
  94004. /**
  94005. * Parse a JSON representation of a sound to innstantiate in a given scene
  94006. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94007. * @param scene Define the scene the new parsed sound should be created in
  94008. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94009. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94010. * @returns the newly parsed sound
  94011. */
  94012. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94013. }
  94014. }
  94015. declare module BABYLON {
  94016. /**
  94017. * This defines an action helpful to play a defined sound on a triggered action.
  94018. */
  94019. export class PlaySoundAction extends Action {
  94020. private _sound;
  94021. /**
  94022. * Instantiate the action
  94023. * @param triggerOptions defines the trigger options
  94024. * @param sound defines the sound to play
  94025. * @param condition defines the trigger related conditions
  94026. */
  94027. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94028. /** @hidden */
  94029. _prepare(): void;
  94030. /**
  94031. * Execute the action and play the sound.
  94032. */
  94033. execute(): void;
  94034. /**
  94035. * Serializes the actions and its related information.
  94036. * @param parent defines the object to serialize in
  94037. * @returns the serialized object
  94038. */
  94039. serialize(parent: any): any;
  94040. }
  94041. /**
  94042. * This defines an action helpful to stop a defined sound on a triggered action.
  94043. */
  94044. export class StopSoundAction extends Action {
  94045. private _sound;
  94046. /**
  94047. * Instantiate the action
  94048. * @param triggerOptions defines the trigger options
  94049. * @param sound defines the sound to stop
  94050. * @param condition defines the trigger related conditions
  94051. */
  94052. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94053. /** @hidden */
  94054. _prepare(): void;
  94055. /**
  94056. * Execute the action and stop the sound.
  94057. */
  94058. execute(): void;
  94059. /**
  94060. * Serializes the actions and its related information.
  94061. * @param parent defines the object to serialize in
  94062. * @returns the serialized object
  94063. */
  94064. serialize(parent: any): any;
  94065. }
  94066. }
  94067. declare module BABYLON {
  94068. /**
  94069. * This defines an action responsible to change the value of a property
  94070. * by interpolating between its current value and the newly set one once triggered.
  94071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94072. */
  94073. export class InterpolateValueAction extends Action {
  94074. /**
  94075. * Defines the path of the property where the value should be interpolated
  94076. */
  94077. propertyPath: string;
  94078. /**
  94079. * Defines the target value at the end of the interpolation.
  94080. */
  94081. value: any;
  94082. /**
  94083. * Defines the time it will take for the property to interpolate to the value.
  94084. */
  94085. duration: number;
  94086. /**
  94087. * Defines if the other scene animations should be stopped when the action has been triggered
  94088. */
  94089. stopOtherAnimations?: boolean;
  94090. /**
  94091. * Defines a callback raised once the interpolation animation has been done.
  94092. */
  94093. onInterpolationDone?: () => void;
  94094. /**
  94095. * Observable triggered once the interpolation animation has been done.
  94096. */
  94097. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94098. private _target;
  94099. private _effectiveTarget;
  94100. private _property;
  94101. /**
  94102. * Instantiate the action
  94103. * @param triggerOptions defines the trigger options
  94104. * @param target defines the object containing the value to interpolate
  94105. * @param propertyPath defines the path to the property in the target object
  94106. * @param value defines the target value at the end of the interpolation
  94107. * @param duration deines the time it will take for the property to interpolate to the value.
  94108. * @param condition defines the trigger related conditions
  94109. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94110. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94111. */
  94112. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94113. /** @hidden */
  94114. _prepare(): void;
  94115. /**
  94116. * Execute the action starts the value interpolation.
  94117. */
  94118. execute(): void;
  94119. /**
  94120. * Serializes the actions and its related information.
  94121. * @param parent defines the object to serialize in
  94122. * @returns the serialized object
  94123. */
  94124. serialize(parent: any): any;
  94125. }
  94126. }
  94127. declare module BABYLON {
  94128. /**
  94129. * Options allowed during the creation of a sound track.
  94130. */
  94131. export interface ISoundTrackOptions {
  94132. /**
  94133. * The volume the sound track should take during creation
  94134. */
  94135. volume?: number;
  94136. /**
  94137. * Define if the sound track is the main sound track of the scene
  94138. */
  94139. mainTrack?: boolean;
  94140. }
  94141. /**
  94142. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94143. * It will be also used in a future release to apply effects on a specific track.
  94144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94145. */
  94146. export class SoundTrack {
  94147. /**
  94148. * The unique identifier of the sound track in the scene.
  94149. */
  94150. id: number;
  94151. /**
  94152. * The list of sounds included in the sound track.
  94153. */
  94154. soundCollection: Array<Sound>;
  94155. private _outputAudioNode;
  94156. private _scene;
  94157. private _isMainTrack;
  94158. private _connectedAnalyser;
  94159. private _options;
  94160. private _isInitialized;
  94161. /**
  94162. * Creates a new sound track.
  94163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94164. * @param scene Define the scene the sound track belongs to
  94165. * @param options
  94166. */
  94167. constructor(scene: Scene, options?: ISoundTrackOptions);
  94168. private _initializeSoundTrackAudioGraph;
  94169. /**
  94170. * Release the sound track and its associated resources
  94171. */
  94172. dispose(): void;
  94173. /**
  94174. * Adds a sound to this sound track
  94175. * @param sound define the cound to add
  94176. * @ignoreNaming
  94177. */
  94178. AddSound(sound: Sound): void;
  94179. /**
  94180. * Removes a sound to this sound track
  94181. * @param sound define the cound to remove
  94182. * @ignoreNaming
  94183. */
  94184. RemoveSound(sound: Sound): void;
  94185. /**
  94186. * Set a global volume for the full sound track.
  94187. * @param newVolume Define the new volume of the sound track
  94188. */
  94189. setVolume(newVolume: number): void;
  94190. /**
  94191. * Switch the panning model to HRTF:
  94192. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94194. */
  94195. switchPanningModelToHRTF(): void;
  94196. /**
  94197. * Switch the panning model to Equal Power:
  94198. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94200. */
  94201. switchPanningModelToEqualPower(): void;
  94202. /**
  94203. * Connect the sound track to an audio analyser allowing some amazing
  94204. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94206. * @param analyser The analyser to connect to the engine
  94207. */
  94208. connectToAnalyser(analyser: Analyser): void;
  94209. }
  94210. }
  94211. declare module BABYLON {
  94212. interface AbstractScene {
  94213. /**
  94214. * The list of sounds used in the scene.
  94215. */
  94216. sounds: Nullable<Array<Sound>>;
  94217. }
  94218. interface Scene {
  94219. /**
  94220. * @hidden
  94221. * Backing field
  94222. */
  94223. _mainSoundTrack: SoundTrack;
  94224. /**
  94225. * The main sound track played by the scene.
  94226. * It cotains your primary collection of sounds.
  94227. */
  94228. mainSoundTrack: SoundTrack;
  94229. /**
  94230. * The list of sound tracks added to the scene
  94231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94232. */
  94233. soundTracks: Nullable<Array<SoundTrack>>;
  94234. /**
  94235. * Gets a sound using a given name
  94236. * @param name defines the name to search for
  94237. * @return the found sound or null if not found at all.
  94238. */
  94239. getSoundByName(name: string): Nullable<Sound>;
  94240. /**
  94241. * Gets or sets if audio support is enabled
  94242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94243. */
  94244. audioEnabled: boolean;
  94245. /**
  94246. * Gets or sets if audio will be output to headphones
  94247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94248. */
  94249. headphone: boolean;
  94250. }
  94251. /**
  94252. * Defines the sound scene component responsible to manage any sounds
  94253. * in a given scene.
  94254. */
  94255. export class AudioSceneComponent implements ISceneSerializableComponent {
  94256. /**
  94257. * The component name helpfull to identify the component in the list of scene components.
  94258. */
  94259. readonly name: string;
  94260. /**
  94261. * The scene the component belongs to.
  94262. */
  94263. scene: Scene;
  94264. private _audioEnabled;
  94265. /**
  94266. * Gets whether audio is enabled or not.
  94267. * Please use related enable/disable method to switch state.
  94268. */
  94269. readonly audioEnabled: boolean;
  94270. private _headphone;
  94271. /**
  94272. * Gets whether audio is outputing to headphone or not.
  94273. * Please use the according Switch methods to change output.
  94274. */
  94275. readonly headphone: boolean;
  94276. /**
  94277. * Creates a new instance of the component for the given scene
  94278. * @param scene Defines the scene to register the component in
  94279. */
  94280. constructor(scene: Scene);
  94281. /**
  94282. * Registers the component in a given scene
  94283. */
  94284. register(): void;
  94285. /**
  94286. * Rebuilds the elements related to this component in case of
  94287. * context lost for instance.
  94288. */
  94289. rebuild(): void;
  94290. /**
  94291. * Serializes the component data to the specified json object
  94292. * @param serializationObject The object to serialize to
  94293. */
  94294. serialize(serializationObject: any): void;
  94295. /**
  94296. * Adds all the element from the container to the scene
  94297. * @param container the container holding the elements
  94298. */
  94299. addFromContainer(container: AbstractScene): void;
  94300. /**
  94301. * Removes all the elements in the container from the scene
  94302. * @param container contains the elements to remove
  94303. * @param dispose if the removed element should be disposed (default: false)
  94304. */
  94305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94306. /**
  94307. * Disposes the component and the associated ressources.
  94308. */
  94309. dispose(): void;
  94310. /**
  94311. * Disables audio in the associated scene.
  94312. */
  94313. disableAudio(): void;
  94314. /**
  94315. * Enables audio in the associated scene.
  94316. */
  94317. enableAudio(): void;
  94318. /**
  94319. * Switch audio to headphone output.
  94320. */
  94321. switchAudioModeForHeadphones(): void;
  94322. /**
  94323. * Switch audio to normal speakers.
  94324. */
  94325. switchAudioModeForNormalSpeakers(): void;
  94326. private _afterRender;
  94327. }
  94328. }
  94329. declare module BABYLON {
  94330. /**
  94331. * Wraps one or more Sound objects and selects one with random weight for playback.
  94332. */
  94333. export class WeightedSound {
  94334. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94335. loop: boolean;
  94336. private _coneInnerAngle;
  94337. private _coneOuterAngle;
  94338. private _volume;
  94339. /** A Sound is currently playing. */
  94340. isPlaying: boolean;
  94341. /** A Sound is currently paused. */
  94342. isPaused: boolean;
  94343. private _sounds;
  94344. private _weights;
  94345. private _currentIndex?;
  94346. /**
  94347. * Creates a new WeightedSound from the list of sounds given.
  94348. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94349. * @param sounds Array of Sounds that will be selected from.
  94350. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94351. */
  94352. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94353. /**
  94354. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94355. */
  94356. /**
  94357. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94358. */
  94359. directionalConeInnerAngle: number;
  94360. /**
  94361. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94362. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94363. */
  94364. /**
  94365. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94366. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94367. */
  94368. directionalConeOuterAngle: number;
  94369. /**
  94370. * Playback volume.
  94371. */
  94372. /**
  94373. * Playback volume.
  94374. */
  94375. volume: number;
  94376. private _onended;
  94377. /**
  94378. * Suspend playback
  94379. */
  94380. pause(): void;
  94381. /**
  94382. * Stop playback
  94383. */
  94384. stop(): void;
  94385. /**
  94386. * Start playback.
  94387. * @param startOffset Position the clip head at a specific time in seconds.
  94388. */
  94389. play(startOffset?: number): void;
  94390. }
  94391. }
  94392. declare module BABYLON {
  94393. /**
  94394. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94395. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94396. */
  94397. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94398. /**
  94399. * Gets the name of the behavior.
  94400. */
  94401. readonly name: string;
  94402. /**
  94403. * The easing function used by animations
  94404. */
  94405. static EasingFunction: BackEase;
  94406. /**
  94407. * The easing mode used by animations
  94408. */
  94409. static EasingMode: number;
  94410. /**
  94411. * The duration of the animation, in milliseconds
  94412. */
  94413. transitionDuration: number;
  94414. /**
  94415. * Length of the distance animated by the transition when lower radius is reached
  94416. */
  94417. lowerRadiusTransitionRange: number;
  94418. /**
  94419. * Length of the distance animated by the transition when upper radius is reached
  94420. */
  94421. upperRadiusTransitionRange: number;
  94422. private _autoTransitionRange;
  94423. /**
  94424. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94425. */
  94426. /**
  94427. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94428. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94429. */
  94430. autoTransitionRange: boolean;
  94431. private _attachedCamera;
  94432. private _onAfterCheckInputsObserver;
  94433. private _onMeshTargetChangedObserver;
  94434. /**
  94435. * Initializes the behavior.
  94436. */
  94437. init(): void;
  94438. /**
  94439. * Attaches the behavior to its arc rotate camera.
  94440. * @param camera Defines the camera to attach the behavior to
  94441. */
  94442. attach(camera: ArcRotateCamera): void;
  94443. /**
  94444. * Detaches the behavior from its current arc rotate camera.
  94445. */
  94446. detach(): void;
  94447. private _radiusIsAnimating;
  94448. private _radiusBounceTransition;
  94449. private _animatables;
  94450. private _cachedWheelPrecision;
  94451. /**
  94452. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94453. * @param radiusLimit The limit to check against.
  94454. * @return Bool to indicate if at limit.
  94455. */
  94456. private _isRadiusAtLimit;
  94457. /**
  94458. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94459. * @param radiusDelta The delta by which to animate to. Can be negative.
  94460. */
  94461. private _applyBoundRadiusAnimation;
  94462. /**
  94463. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94464. */
  94465. protected _clearAnimationLocks(): void;
  94466. /**
  94467. * Stops and removes all animations that have been applied to the camera
  94468. */
  94469. stopAllAnimations(): void;
  94470. }
  94471. }
  94472. declare module BABYLON {
  94473. /**
  94474. * 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.
  94475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94476. */
  94477. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94478. /**
  94479. * Gets the name of the behavior.
  94480. */
  94481. readonly name: string;
  94482. private _mode;
  94483. private _radiusScale;
  94484. private _positionScale;
  94485. private _defaultElevation;
  94486. private _elevationReturnTime;
  94487. private _elevationReturnWaitTime;
  94488. private _zoomStopsAnimation;
  94489. private _framingTime;
  94490. /**
  94491. * The easing function used by animations
  94492. */
  94493. static EasingFunction: ExponentialEase;
  94494. /**
  94495. * The easing mode used by animations
  94496. */
  94497. static EasingMode: number;
  94498. /**
  94499. * Sets the current mode used by the behavior
  94500. */
  94501. /**
  94502. * Gets current mode used by the behavior.
  94503. */
  94504. mode: number;
  94505. /**
  94506. * Sets the scale applied to the radius (1 by default)
  94507. */
  94508. /**
  94509. * Gets the scale applied to the radius
  94510. */
  94511. radiusScale: number;
  94512. /**
  94513. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94514. */
  94515. /**
  94516. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94517. */
  94518. positionScale: number;
  94519. /**
  94520. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94521. * behaviour is triggered, in radians.
  94522. */
  94523. /**
  94524. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94525. * behaviour is triggered, in radians.
  94526. */
  94527. defaultElevation: number;
  94528. /**
  94529. * Sets the time (in milliseconds) taken to return to the default beta position.
  94530. * Negative value indicates camera should not return to default.
  94531. */
  94532. /**
  94533. * Gets the time (in milliseconds) taken to return to the default beta position.
  94534. * Negative value indicates camera should not return to default.
  94535. */
  94536. elevationReturnTime: number;
  94537. /**
  94538. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94539. */
  94540. /**
  94541. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94542. */
  94543. elevationReturnWaitTime: number;
  94544. /**
  94545. * Sets the flag that indicates if user zooming should stop animation.
  94546. */
  94547. /**
  94548. * Gets the flag that indicates if user zooming should stop animation.
  94549. */
  94550. zoomStopsAnimation: boolean;
  94551. /**
  94552. * Sets the transition time when framing the mesh, in milliseconds
  94553. */
  94554. /**
  94555. * Gets the transition time when framing the mesh, in milliseconds
  94556. */
  94557. framingTime: number;
  94558. /**
  94559. * Define if the behavior should automatically change the configured
  94560. * camera limits and sensibilities.
  94561. */
  94562. autoCorrectCameraLimitsAndSensibility: boolean;
  94563. private _onPrePointerObservableObserver;
  94564. private _onAfterCheckInputsObserver;
  94565. private _onMeshTargetChangedObserver;
  94566. private _attachedCamera;
  94567. private _isPointerDown;
  94568. private _lastInteractionTime;
  94569. /**
  94570. * Initializes the behavior.
  94571. */
  94572. init(): void;
  94573. /**
  94574. * Attaches the behavior to its arc rotate camera.
  94575. * @param camera Defines the camera to attach the behavior to
  94576. */
  94577. attach(camera: ArcRotateCamera): void;
  94578. /**
  94579. * Detaches the behavior from its current arc rotate camera.
  94580. */
  94581. detach(): void;
  94582. private _animatables;
  94583. private _betaIsAnimating;
  94584. private _betaTransition;
  94585. private _radiusTransition;
  94586. private _vectorTransition;
  94587. /**
  94588. * Targets the given mesh and updates zoom level accordingly.
  94589. * @param mesh The mesh to target.
  94590. * @param radius Optional. If a cached radius position already exists, overrides default.
  94591. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94592. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94593. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94594. */
  94595. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94596. /**
  94597. * Targets the given mesh with its children and updates zoom level accordingly.
  94598. * @param mesh The mesh to target.
  94599. * @param radius Optional. If a cached radius position already exists, overrides default.
  94600. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94601. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94602. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94603. */
  94604. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94605. /**
  94606. * Targets the given meshes with their children and updates zoom level accordingly.
  94607. * @param meshes The mesh to target.
  94608. * @param radius Optional. If a cached radius position already exists, overrides default.
  94609. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94610. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94611. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94612. */
  94613. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94614. /**
  94615. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94616. * @param minimumWorld Determines the smaller position of the bounding box extend
  94617. * @param maximumWorld Determines the bigger position of the bounding box extend
  94618. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94619. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94620. */
  94621. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94622. /**
  94623. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94624. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94625. * frustum width.
  94626. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94627. * to fully enclose the mesh in the viewing frustum.
  94628. */
  94629. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94630. /**
  94631. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94632. * is automatically returned to its default position (expected to be above ground plane).
  94633. */
  94634. private _maintainCameraAboveGround;
  94635. /**
  94636. * Returns the frustum slope based on the canvas ratio and camera FOV
  94637. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94638. */
  94639. private _getFrustumSlope;
  94640. /**
  94641. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94642. */
  94643. private _clearAnimationLocks;
  94644. /**
  94645. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94646. */
  94647. private _applyUserInteraction;
  94648. /**
  94649. * Stops and removes all animations that have been applied to the camera
  94650. */
  94651. stopAllAnimations(): void;
  94652. /**
  94653. * Gets a value indicating if the user is moving the camera
  94654. */
  94655. readonly isUserIsMoving: boolean;
  94656. /**
  94657. * The camera can move all the way towards the mesh.
  94658. */
  94659. static IgnoreBoundsSizeMode: number;
  94660. /**
  94661. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94662. */
  94663. static FitFrustumSidesMode: number;
  94664. }
  94665. }
  94666. declare module BABYLON {
  94667. /**
  94668. * Base class for Camera Pointer Inputs.
  94669. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94670. * for example usage.
  94671. */
  94672. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94673. /**
  94674. * Defines the camera the input is attached to.
  94675. */
  94676. abstract camera: Camera;
  94677. /**
  94678. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94679. */
  94680. protected _altKey: boolean;
  94681. protected _ctrlKey: boolean;
  94682. protected _metaKey: boolean;
  94683. protected _shiftKey: boolean;
  94684. /**
  94685. * Which mouse buttons were pressed at time of last mouse event.
  94686. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94687. */
  94688. protected _buttonsPressed: number;
  94689. /**
  94690. * Defines the buttons associated with the input to handle camera move.
  94691. */
  94692. buttons: number[];
  94693. /**
  94694. * Attach the input controls to a specific dom element to get the input from.
  94695. * @param element Defines the element the controls should be listened from
  94696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94697. */
  94698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94699. /**
  94700. * Detach the current controls from the specified dom element.
  94701. * @param element Defines the element to stop listening the inputs from
  94702. */
  94703. detachControl(element: Nullable<HTMLElement>): void;
  94704. /**
  94705. * Gets the class name of the current input.
  94706. * @returns the class name
  94707. */
  94708. getClassName(): string;
  94709. /**
  94710. * Get the friendly name associated with the input class.
  94711. * @returns the input friendly name
  94712. */
  94713. getSimpleName(): string;
  94714. /**
  94715. * Called on pointer POINTERDOUBLETAP event.
  94716. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94717. */
  94718. protected onDoubleTap(type: string): void;
  94719. /**
  94720. * Called on pointer POINTERMOVE event if only a single touch is active.
  94721. * Override this method to provide functionality.
  94722. */
  94723. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94724. /**
  94725. * Called on pointer POINTERMOVE event if multiple touches are active.
  94726. * Override this method to provide functionality.
  94727. */
  94728. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94729. /**
  94730. * Called on JS contextmenu event.
  94731. * Override this method to provide functionality.
  94732. */
  94733. protected onContextMenu(evt: PointerEvent): void;
  94734. /**
  94735. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94736. * press.
  94737. * Override this method to provide functionality.
  94738. */
  94739. protected onButtonDown(evt: PointerEvent): void;
  94740. /**
  94741. * Called each time a new POINTERUP event occurs. Ie, for each button
  94742. * release.
  94743. * Override this method to provide functionality.
  94744. */
  94745. protected onButtonUp(evt: PointerEvent): void;
  94746. /**
  94747. * Called when window becomes inactive.
  94748. * Override this method to provide functionality.
  94749. */
  94750. protected onLostFocus(): void;
  94751. private _pointerInput;
  94752. private _observer;
  94753. private _onLostFocus;
  94754. private pointA;
  94755. private pointB;
  94756. }
  94757. }
  94758. declare module BABYLON {
  94759. /**
  94760. * Manage the pointers inputs to control an arc rotate camera.
  94761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94762. */
  94763. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94764. /**
  94765. * Defines the camera the input is attached to.
  94766. */
  94767. camera: ArcRotateCamera;
  94768. /**
  94769. * Gets the class name of the current input.
  94770. * @returns the class name
  94771. */
  94772. getClassName(): string;
  94773. /**
  94774. * Defines the buttons associated with the input to handle camera move.
  94775. */
  94776. buttons: number[];
  94777. /**
  94778. * Defines the pointer angular sensibility along the X axis or how fast is
  94779. * the camera rotating.
  94780. */
  94781. angularSensibilityX: number;
  94782. /**
  94783. * Defines the pointer angular sensibility along the Y axis or how fast is
  94784. * the camera rotating.
  94785. */
  94786. angularSensibilityY: number;
  94787. /**
  94788. * Defines the pointer pinch precision or how fast is the camera zooming.
  94789. */
  94790. pinchPrecision: number;
  94791. /**
  94792. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94793. * from 0.
  94794. * It defines the percentage of current camera.radius to use as delta when
  94795. * pinch zoom is used.
  94796. */
  94797. pinchDeltaPercentage: number;
  94798. /**
  94799. * Defines the pointer panning sensibility or how fast is the camera moving.
  94800. */
  94801. panningSensibility: number;
  94802. /**
  94803. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94804. */
  94805. multiTouchPanning: boolean;
  94806. /**
  94807. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94808. * zoom (pinch) through multitouch.
  94809. */
  94810. multiTouchPanAndZoom: boolean;
  94811. /**
  94812. * Revers pinch action direction.
  94813. */
  94814. pinchInwards: boolean;
  94815. private _isPanClick;
  94816. private _twoFingerActivityCount;
  94817. private _isPinching;
  94818. /**
  94819. * Called on pointer POINTERMOVE event if only a single touch is active.
  94820. */
  94821. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94822. /**
  94823. * Called on pointer POINTERDOUBLETAP event.
  94824. */
  94825. protected onDoubleTap(type: string): void;
  94826. /**
  94827. * Called on pointer POINTERMOVE event if multiple touches are active.
  94828. */
  94829. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94830. /**
  94831. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94832. * press.
  94833. */
  94834. protected onButtonDown(evt: PointerEvent): void;
  94835. /**
  94836. * Called each time a new POINTERUP event occurs. Ie, for each button
  94837. * release.
  94838. */
  94839. protected onButtonUp(evt: PointerEvent): void;
  94840. /**
  94841. * Called when window becomes inactive.
  94842. */
  94843. protected onLostFocus(): void;
  94844. }
  94845. }
  94846. declare module BABYLON {
  94847. /**
  94848. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94850. */
  94851. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94852. /**
  94853. * Defines the camera the input is attached to.
  94854. */
  94855. camera: ArcRotateCamera;
  94856. /**
  94857. * Defines the list of key codes associated with the up action (increase alpha)
  94858. */
  94859. keysUp: number[];
  94860. /**
  94861. * Defines the list of key codes associated with the down action (decrease alpha)
  94862. */
  94863. keysDown: number[];
  94864. /**
  94865. * Defines the list of key codes associated with the left action (increase beta)
  94866. */
  94867. keysLeft: number[];
  94868. /**
  94869. * Defines the list of key codes associated with the right action (decrease beta)
  94870. */
  94871. keysRight: number[];
  94872. /**
  94873. * Defines the list of key codes associated with the reset action.
  94874. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94875. */
  94876. keysReset: number[];
  94877. /**
  94878. * Defines the panning sensibility of the inputs.
  94879. * (How fast is the camera paning)
  94880. */
  94881. panningSensibility: number;
  94882. /**
  94883. * Defines the zooming sensibility of the inputs.
  94884. * (How fast is the camera zooming)
  94885. */
  94886. zoomingSensibility: number;
  94887. /**
  94888. * Defines wether maintaining the alt key down switch the movement mode from
  94889. * orientation to zoom.
  94890. */
  94891. useAltToZoom: boolean;
  94892. /**
  94893. * Rotation speed of the camera
  94894. */
  94895. angularSpeed: number;
  94896. private _keys;
  94897. private _ctrlPressed;
  94898. private _altPressed;
  94899. private _onCanvasBlurObserver;
  94900. private _onKeyboardObserver;
  94901. private _engine;
  94902. private _scene;
  94903. /**
  94904. * Attach the input controls to a specific dom element to get the input from.
  94905. * @param element Defines the element the controls should be listened from
  94906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94907. */
  94908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94909. /**
  94910. * Detach the current controls from the specified dom element.
  94911. * @param element Defines the element to stop listening the inputs from
  94912. */
  94913. detachControl(element: Nullable<HTMLElement>): void;
  94914. /**
  94915. * Update the current camera state depending on the inputs that have been used this frame.
  94916. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94917. */
  94918. checkInputs(): void;
  94919. /**
  94920. * Gets the class name of the current intput.
  94921. * @returns the class name
  94922. */
  94923. getClassName(): string;
  94924. /**
  94925. * Get the friendly name associated with the input class.
  94926. * @returns the input friendly name
  94927. */
  94928. getSimpleName(): string;
  94929. }
  94930. }
  94931. declare module BABYLON {
  94932. /**
  94933. * Manage the mouse wheel inputs to control an arc rotate camera.
  94934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94935. */
  94936. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94937. /**
  94938. * Defines the camera the input is attached to.
  94939. */
  94940. camera: ArcRotateCamera;
  94941. /**
  94942. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94943. */
  94944. wheelPrecision: number;
  94945. /**
  94946. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94947. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94948. */
  94949. wheelDeltaPercentage: number;
  94950. private _wheel;
  94951. private _observer;
  94952. /**
  94953. * Attach the input controls to a specific dom element to get the input from.
  94954. * @param element Defines the element the controls should be listened from
  94955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94956. */
  94957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94958. /**
  94959. * Detach the current controls from the specified dom element.
  94960. * @param element Defines the element to stop listening the inputs from
  94961. */
  94962. detachControl(element: Nullable<HTMLElement>): void;
  94963. /**
  94964. * Gets the class name of the current intput.
  94965. * @returns the class name
  94966. */
  94967. getClassName(): string;
  94968. /**
  94969. * Get the friendly name associated with the input class.
  94970. * @returns the input friendly name
  94971. */
  94972. getSimpleName(): string;
  94973. }
  94974. }
  94975. declare module BABYLON {
  94976. /**
  94977. * Default Inputs manager for the ArcRotateCamera.
  94978. * It groups all the default supported inputs for ease of use.
  94979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94980. */
  94981. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94982. /**
  94983. * Instantiates a new ArcRotateCameraInputsManager.
  94984. * @param camera Defines the camera the inputs belong to
  94985. */
  94986. constructor(camera: ArcRotateCamera);
  94987. /**
  94988. * Add mouse wheel input support to the input manager.
  94989. * @returns the current input manager
  94990. */
  94991. addMouseWheel(): ArcRotateCameraInputsManager;
  94992. /**
  94993. * Add pointers input support to the input manager.
  94994. * @returns the current input manager
  94995. */
  94996. addPointers(): ArcRotateCameraInputsManager;
  94997. /**
  94998. * Add keyboard input support to the input manager.
  94999. * @returns the current input manager
  95000. */
  95001. addKeyboard(): ArcRotateCameraInputsManager;
  95002. }
  95003. }
  95004. declare module BABYLON {
  95005. /**
  95006. * This represents an orbital type of camera.
  95007. *
  95008. * 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.
  95009. * 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.
  95010. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95011. */
  95012. export class ArcRotateCamera extends TargetCamera {
  95013. /**
  95014. * Defines the rotation angle of the camera along the longitudinal axis.
  95015. */
  95016. alpha: number;
  95017. /**
  95018. * Defines the rotation angle of the camera along the latitudinal axis.
  95019. */
  95020. beta: number;
  95021. /**
  95022. * Defines the radius of the camera from it s target point.
  95023. */
  95024. radius: number;
  95025. protected _target: Vector3;
  95026. protected _targetHost: Nullable<AbstractMesh>;
  95027. /**
  95028. * Defines the target point of the camera.
  95029. * The camera looks towards it form the radius distance.
  95030. */
  95031. target: Vector3;
  95032. /**
  95033. * Define the current local position of the camera in the scene
  95034. */
  95035. position: Vector3;
  95036. protected _upVector: Vector3;
  95037. protected _upToYMatrix: Matrix;
  95038. protected _YToUpMatrix: Matrix;
  95039. /**
  95040. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95041. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95042. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95043. */
  95044. upVector: Vector3;
  95045. /**
  95046. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95047. */
  95048. setMatUp(): void;
  95049. /**
  95050. * Current inertia value on the longitudinal axis.
  95051. * The bigger this number the longer it will take for the camera to stop.
  95052. */
  95053. inertialAlphaOffset: number;
  95054. /**
  95055. * Current inertia value on the latitudinal axis.
  95056. * The bigger this number the longer it will take for the camera to stop.
  95057. */
  95058. inertialBetaOffset: number;
  95059. /**
  95060. * Current inertia value on the radius axis.
  95061. * The bigger this number the longer it will take for the camera to stop.
  95062. */
  95063. inertialRadiusOffset: number;
  95064. /**
  95065. * Minimum allowed angle on the longitudinal axis.
  95066. * This can help limiting how the Camera is able to move in the scene.
  95067. */
  95068. lowerAlphaLimit: Nullable<number>;
  95069. /**
  95070. * Maximum allowed angle on the longitudinal axis.
  95071. * This can help limiting how the Camera is able to move in the scene.
  95072. */
  95073. upperAlphaLimit: Nullable<number>;
  95074. /**
  95075. * Minimum allowed angle on the latitudinal axis.
  95076. * This can help limiting how the Camera is able to move in the scene.
  95077. */
  95078. lowerBetaLimit: number;
  95079. /**
  95080. * Maximum allowed angle on the latitudinal axis.
  95081. * This can help limiting how the Camera is able to move in the scene.
  95082. */
  95083. upperBetaLimit: number;
  95084. /**
  95085. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95086. * This can help limiting how the Camera is able to move in the scene.
  95087. */
  95088. lowerRadiusLimit: Nullable<number>;
  95089. /**
  95090. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95091. * This can help limiting how the Camera is able to move in the scene.
  95092. */
  95093. upperRadiusLimit: Nullable<number>;
  95094. /**
  95095. * Defines the current inertia value used during panning of the camera along the X axis.
  95096. */
  95097. inertialPanningX: number;
  95098. /**
  95099. * Defines the current inertia value used during panning of the camera along the Y axis.
  95100. */
  95101. inertialPanningY: number;
  95102. /**
  95103. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95104. * Basically if your fingers moves away from more than this distance you will be considered
  95105. * in pinch mode.
  95106. */
  95107. pinchToPanMaxDistance: number;
  95108. /**
  95109. * Defines the maximum distance the camera can pan.
  95110. * This could help keeping the cammera always in your scene.
  95111. */
  95112. panningDistanceLimit: Nullable<number>;
  95113. /**
  95114. * Defines the target of the camera before paning.
  95115. */
  95116. panningOriginTarget: Vector3;
  95117. /**
  95118. * Defines the value of the inertia used during panning.
  95119. * 0 would mean stop inertia and one would mean no decelleration at all.
  95120. */
  95121. panningInertia: number;
  95122. /**
  95123. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95124. */
  95125. angularSensibilityX: number;
  95126. /**
  95127. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95128. */
  95129. angularSensibilityY: number;
  95130. /**
  95131. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95132. */
  95133. pinchPrecision: number;
  95134. /**
  95135. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95136. * It will be used instead of pinchDeltaPrecision if different from 0.
  95137. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95138. */
  95139. pinchDeltaPercentage: number;
  95140. /**
  95141. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95142. */
  95143. panningSensibility: number;
  95144. /**
  95145. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95146. */
  95147. keysUp: number[];
  95148. /**
  95149. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95150. */
  95151. keysDown: number[];
  95152. /**
  95153. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95154. */
  95155. keysLeft: number[];
  95156. /**
  95157. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95158. */
  95159. keysRight: number[];
  95160. /**
  95161. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95162. */
  95163. wheelPrecision: number;
  95164. /**
  95165. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95166. * It will be used instead of pinchDeltaPrecision if different from 0.
  95167. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95168. */
  95169. wheelDeltaPercentage: number;
  95170. /**
  95171. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95172. */
  95173. zoomOnFactor: number;
  95174. /**
  95175. * Defines a screen offset for the camera position.
  95176. */
  95177. targetScreenOffset: Vector2;
  95178. /**
  95179. * Allows the camera to be completely reversed.
  95180. * If false the camera can not arrive upside down.
  95181. */
  95182. allowUpsideDown: boolean;
  95183. /**
  95184. * Define if double tap/click is used to restore the previously saved state of the camera.
  95185. */
  95186. useInputToRestoreState: boolean;
  95187. /** @hidden */
  95188. _viewMatrix: Matrix;
  95189. /** @hidden */
  95190. _useCtrlForPanning: boolean;
  95191. /** @hidden */
  95192. _panningMouseButton: number;
  95193. /**
  95194. * Defines the input associated to the camera.
  95195. */
  95196. inputs: ArcRotateCameraInputsManager;
  95197. /** @hidden */
  95198. _reset: () => void;
  95199. /**
  95200. * Defines the allowed panning axis.
  95201. */
  95202. panningAxis: Vector3;
  95203. protected _localDirection: Vector3;
  95204. protected _transformedDirection: Vector3;
  95205. private _bouncingBehavior;
  95206. /**
  95207. * Gets the bouncing behavior of the camera if it has been enabled.
  95208. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95209. */
  95210. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95211. /**
  95212. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95213. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95214. */
  95215. useBouncingBehavior: boolean;
  95216. private _framingBehavior;
  95217. /**
  95218. * Gets the framing behavior of the camera if it has been enabled.
  95219. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95220. */
  95221. readonly framingBehavior: Nullable<FramingBehavior>;
  95222. /**
  95223. * Defines if the framing behavior of the camera is enabled on the camera.
  95224. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95225. */
  95226. useFramingBehavior: boolean;
  95227. private _autoRotationBehavior;
  95228. /**
  95229. * Gets the auto rotation behavior of the camera if it has been enabled.
  95230. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95231. */
  95232. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95233. /**
  95234. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95236. */
  95237. useAutoRotationBehavior: boolean;
  95238. /**
  95239. * Observable triggered when the mesh target has been changed on the camera.
  95240. */
  95241. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95242. /**
  95243. * Event raised when the camera is colliding with a mesh.
  95244. */
  95245. onCollide: (collidedMesh: AbstractMesh) => void;
  95246. /**
  95247. * Defines whether the camera should check collision with the objects oh the scene.
  95248. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95249. */
  95250. checkCollisions: boolean;
  95251. /**
  95252. * Defines the collision radius of the camera.
  95253. * This simulates a sphere around the camera.
  95254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95255. */
  95256. collisionRadius: Vector3;
  95257. protected _collider: Collider;
  95258. protected _previousPosition: Vector3;
  95259. protected _collisionVelocity: Vector3;
  95260. protected _newPosition: Vector3;
  95261. protected _previousAlpha: number;
  95262. protected _previousBeta: number;
  95263. protected _previousRadius: number;
  95264. protected _collisionTriggered: boolean;
  95265. protected _targetBoundingCenter: Nullable<Vector3>;
  95266. private _computationVector;
  95267. /**
  95268. * Instantiates a new ArcRotateCamera in a given scene
  95269. * @param name Defines the name of the camera
  95270. * @param alpha Defines the camera rotation along the logitudinal axis
  95271. * @param beta Defines the camera rotation along the latitudinal axis
  95272. * @param radius Defines the camera distance from its target
  95273. * @param target Defines the camera target
  95274. * @param scene Defines the scene the camera belongs to
  95275. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95276. */
  95277. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95278. /** @hidden */
  95279. _initCache(): void;
  95280. /** @hidden */
  95281. _updateCache(ignoreParentClass?: boolean): void;
  95282. protected _getTargetPosition(): Vector3;
  95283. private _storedAlpha;
  95284. private _storedBeta;
  95285. private _storedRadius;
  95286. private _storedTarget;
  95287. /**
  95288. * Stores the current state of the camera (alpha, beta, radius and target)
  95289. * @returns the camera itself
  95290. */
  95291. storeState(): Camera;
  95292. /**
  95293. * @hidden
  95294. * Restored camera state. You must call storeState() first
  95295. */
  95296. _restoreStateValues(): boolean;
  95297. /** @hidden */
  95298. _isSynchronizedViewMatrix(): boolean;
  95299. /**
  95300. * Attached controls to the current camera.
  95301. * @param element Defines the element the controls should be listened from
  95302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95303. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95304. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95305. */
  95306. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95307. /**
  95308. * Detach the current controls from the camera.
  95309. * The camera will stop reacting to inputs.
  95310. * @param element Defines the element to stop listening the inputs from
  95311. */
  95312. detachControl(element: HTMLElement): void;
  95313. /** @hidden */
  95314. _checkInputs(): void;
  95315. protected _checkLimits(): void;
  95316. /**
  95317. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95318. */
  95319. rebuildAnglesAndRadius(): void;
  95320. /**
  95321. * Use a position to define the current camera related information like aplha, beta and radius
  95322. * @param position Defines the position to set the camera at
  95323. */
  95324. setPosition(position: Vector3): void;
  95325. /**
  95326. * Defines the target the camera should look at.
  95327. * This will automatically adapt alpha beta and radius to fit within the new target.
  95328. * @param target Defines the new target as a Vector or a mesh
  95329. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95330. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95331. */
  95332. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95333. /** @hidden */
  95334. _getViewMatrix(): Matrix;
  95335. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95336. /**
  95337. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95338. * @param meshes Defines the mesh to zoom on
  95339. * @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)
  95340. */
  95341. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95342. /**
  95343. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95344. * The target will be changed but the radius
  95345. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95346. * @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)
  95347. */
  95348. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95349. min: Vector3;
  95350. max: Vector3;
  95351. distance: number;
  95352. }, doNotUpdateMaxZ?: boolean): void;
  95353. /**
  95354. * @override
  95355. * Override Camera.createRigCamera
  95356. */
  95357. createRigCamera(name: string, cameraIndex: number): Camera;
  95358. /**
  95359. * @hidden
  95360. * @override
  95361. * Override Camera._updateRigCameras
  95362. */
  95363. _updateRigCameras(): void;
  95364. /**
  95365. * Destroy the camera and release the current resources hold by it.
  95366. */
  95367. dispose(): void;
  95368. /**
  95369. * Gets the current object class name.
  95370. * @return the class name
  95371. */
  95372. getClassName(): string;
  95373. }
  95374. }
  95375. declare module BABYLON {
  95376. /**
  95377. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95379. */
  95380. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95381. /**
  95382. * Gets the name of the behavior.
  95383. */
  95384. readonly name: string;
  95385. private _zoomStopsAnimation;
  95386. private _idleRotationSpeed;
  95387. private _idleRotationWaitTime;
  95388. private _idleRotationSpinupTime;
  95389. /**
  95390. * Sets the flag that indicates if user zooming should stop animation.
  95391. */
  95392. /**
  95393. * Gets the flag that indicates if user zooming should stop animation.
  95394. */
  95395. zoomStopsAnimation: boolean;
  95396. /**
  95397. * Sets the default speed at which the camera rotates around the model.
  95398. */
  95399. /**
  95400. * Gets the default speed at which the camera rotates around the model.
  95401. */
  95402. idleRotationSpeed: number;
  95403. /**
  95404. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95405. */
  95406. /**
  95407. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95408. */
  95409. idleRotationWaitTime: number;
  95410. /**
  95411. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95412. */
  95413. /**
  95414. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95415. */
  95416. idleRotationSpinupTime: number;
  95417. /**
  95418. * Gets a value indicating if the camera is currently rotating because of this behavior
  95419. */
  95420. readonly rotationInProgress: boolean;
  95421. private _onPrePointerObservableObserver;
  95422. private _onAfterCheckInputsObserver;
  95423. private _attachedCamera;
  95424. private _isPointerDown;
  95425. private _lastFrameTime;
  95426. private _lastInteractionTime;
  95427. private _cameraRotationSpeed;
  95428. /**
  95429. * Initializes the behavior.
  95430. */
  95431. init(): void;
  95432. /**
  95433. * Attaches the behavior to its arc rotate camera.
  95434. * @param camera Defines the camera to attach the behavior to
  95435. */
  95436. attach(camera: ArcRotateCamera): void;
  95437. /**
  95438. * Detaches the behavior from its current arc rotate camera.
  95439. */
  95440. detach(): void;
  95441. /**
  95442. * Returns true if user is scrolling.
  95443. * @return true if user is scrolling.
  95444. */
  95445. private _userIsZooming;
  95446. private _lastFrameRadius;
  95447. private _shouldAnimationStopForInteraction;
  95448. /**
  95449. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95450. */
  95451. private _applyUserInteraction;
  95452. private _userIsMoving;
  95453. }
  95454. }
  95455. declare module BABYLON {
  95456. /**
  95457. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95458. */
  95459. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95460. private ui;
  95461. /**
  95462. * The name of the behavior
  95463. */
  95464. name: string;
  95465. /**
  95466. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95467. */
  95468. distanceAwayFromFace: number;
  95469. /**
  95470. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95471. */
  95472. distanceAwayFromBottomOfFace: number;
  95473. private _faceVectors;
  95474. private _target;
  95475. private _scene;
  95476. private _onRenderObserver;
  95477. private _tmpMatrix;
  95478. private _tmpVector;
  95479. /**
  95480. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95481. * @param ui The transform node that should be attched to the mesh
  95482. */
  95483. constructor(ui: TransformNode);
  95484. /**
  95485. * Initializes the behavior
  95486. */
  95487. init(): void;
  95488. private _closestFace;
  95489. private _zeroVector;
  95490. private _lookAtTmpMatrix;
  95491. private _lookAtToRef;
  95492. /**
  95493. * Attaches the AttachToBoxBehavior to the passed in mesh
  95494. * @param target The mesh that the specified node will be attached to
  95495. */
  95496. attach(target: Mesh): void;
  95497. /**
  95498. * Detaches the behavior from the mesh
  95499. */
  95500. detach(): void;
  95501. }
  95502. }
  95503. declare module BABYLON {
  95504. /**
  95505. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95506. */
  95507. export class FadeInOutBehavior implements Behavior<Mesh> {
  95508. /**
  95509. * Time in milliseconds to delay before fading in (Default: 0)
  95510. */
  95511. delay: number;
  95512. /**
  95513. * Time in milliseconds for the mesh to fade in (Default: 300)
  95514. */
  95515. fadeInTime: number;
  95516. private _millisecondsPerFrame;
  95517. private _hovered;
  95518. private _hoverValue;
  95519. private _ownerNode;
  95520. /**
  95521. * Instatiates the FadeInOutBehavior
  95522. */
  95523. constructor();
  95524. /**
  95525. * The name of the behavior
  95526. */
  95527. readonly name: string;
  95528. /**
  95529. * Initializes the behavior
  95530. */
  95531. init(): void;
  95532. /**
  95533. * Attaches the fade behavior on the passed in mesh
  95534. * @param ownerNode The mesh that will be faded in/out once attached
  95535. */
  95536. attach(ownerNode: Mesh): void;
  95537. /**
  95538. * Detaches the behavior from the mesh
  95539. */
  95540. detach(): void;
  95541. /**
  95542. * Triggers the mesh to begin fading in or out
  95543. * @param value if the object should fade in or out (true to fade in)
  95544. */
  95545. fadeIn(value: boolean): void;
  95546. private _update;
  95547. private _setAllVisibility;
  95548. }
  95549. }
  95550. declare module BABYLON {
  95551. /**
  95552. * Class containing a set of static utilities functions for managing Pivots
  95553. * @hidden
  95554. */
  95555. export class PivotTools {
  95556. private static _PivotCached;
  95557. private static _OldPivotPoint;
  95558. private static _PivotTranslation;
  95559. private static _PivotTmpVector;
  95560. /** @hidden */
  95561. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95562. /** @hidden */
  95563. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95564. }
  95565. }
  95566. declare module BABYLON {
  95567. /**
  95568. * Class containing static functions to help procedurally build meshes
  95569. */
  95570. export class PlaneBuilder {
  95571. /**
  95572. * Creates a plane mesh
  95573. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95574. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95575. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95579. * @param name defines the name of the mesh
  95580. * @param options defines the options used to create the mesh
  95581. * @param scene defines the hosting scene
  95582. * @returns the plane mesh
  95583. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95584. */
  95585. static CreatePlane(name: string, options: {
  95586. size?: number;
  95587. width?: number;
  95588. height?: number;
  95589. sideOrientation?: number;
  95590. frontUVs?: Vector4;
  95591. backUVs?: Vector4;
  95592. updatable?: boolean;
  95593. sourcePlane?: Plane;
  95594. }, scene?: Nullable<Scene>): Mesh;
  95595. }
  95596. }
  95597. declare module BABYLON {
  95598. /**
  95599. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95600. */
  95601. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95602. private static _AnyMouseID;
  95603. private _attachedNode;
  95604. private _dragPlane;
  95605. private _scene;
  95606. private _pointerObserver;
  95607. private _beforeRenderObserver;
  95608. private static _planeScene;
  95609. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95610. /**
  95611. * 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)
  95612. */
  95613. maxDragAngle: number;
  95614. /**
  95615. * @hidden
  95616. */
  95617. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95618. /**
  95619. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95620. */
  95621. currentDraggingPointerID: number;
  95622. /**
  95623. * The last position where the pointer hit the drag plane in world space
  95624. */
  95625. lastDragPosition: Vector3;
  95626. /**
  95627. * If the behavior is currently in a dragging state
  95628. */
  95629. dragging: boolean;
  95630. /**
  95631. * 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)
  95632. */
  95633. dragDeltaRatio: number;
  95634. /**
  95635. * If the drag plane orientation should be updated during the dragging (Default: true)
  95636. */
  95637. updateDragPlane: boolean;
  95638. private _debugMode;
  95639. private _moving;
  95640. /**
  95641. * Fires each time the attached mesh is dragged with the pointer
  95642. * * delta between last drag position and current drag position in world space
  95643. * * dragDistance along the drag axis
  95644. * * dragPlaneNormal normal of the current drag plane used during the drag
  95645. * * dragPlanePoint in world space where the drag intersects the drag plane
  95646. */
  95647. onDragObservable: Observable<{
  95648. delta: Vector3;
  95649. dragPlanePoint: Vector3;
  95650. dragPlaneNormal: Vector3;
  95651. dragDistance: number;
  95652. pointerId: number;
  95653. }>;
  95654. /**
  95655. * Fires each time a drag begins (eg. mouse down on mesh)
  95656. */
  95657. onDragStartObservable: Observable<{
  95658. dragPlanePoint: Vector3;
  95659. pointerId: number;
  95660. }>;
  95661. /**
  95662. * Fires each time a drag ends (eg. mouse release after drag)
  95663. */
  95664. onDragEndObservable: Observable<{
  95665. dragPlanePoint: Vector3;
  95666. pointerId: number;
  95667. }>;
  95668. /**
  95669. * If the attached mesh should be moved when dragged
  95670. */
  95671. moveAttached: boolean;
  95672. /**
  95673. * If the drag behavior will react to drag events (Default: true)
  95674. */
  95675. enabled: boolean;
  95676. /**
  95677. * If camera controls should be detached during the drag
  95678. */
  95679. detachCameraControls: boolean;
  95680. /**
  95681. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95682. */
  95683. useObjectOrienationForDragging: boolean;
  95684. private _options;
  95685. /**
  95686. * Creates a pointer drag behavior that can be attached to a mesh
  95687. * @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)
  95688. */
  95689. constructor(options?: {
  95690. dragAxis?: Vector3;
  95691. dragPlaneNormal?: Vector3;
  95692. });
  95693. /**
  95694. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95695. */
  95696. validateDrag: (targetPosition: Vector3) => boolean;
  95697. /**
  95698. * The name of the behavior
  95699. */
  95700. readonly name: string;
  95701. /**
  95702. * Initializes the behavior
  95703. */
  95704. init(): void;
  95705. private _tmpVector;
  95706. private _alternatePickedPoint;
  95707. private _worldDragAxis;
  95708. private _targetPosition;
  95709. private _attachedElement;
  95710. /**
  95711. * Attaches the drag behavior the passed in mesh
  95712. * @param ownerNode The mesh that will be dragged around once attached
  95713. */
  95714. attach(ownerNode: AbstractMesh): void;
  95715. /**
  95716. * Force relase the drag action by code.
  95717. */
  95718. releaseDrag(): void;
  95719. private _startDragRay;
  95720. private _lastPointerRay;
  95721. /**
  95722. * Simulates the start of a pointer drag event on the behavior
  95723. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95724. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95725. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95726. */
  95727. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95728. private _startDrag;
  95729. private _dragDelta;
  95730. private _moveDrag;
  95731. private _pickWithRayOnDragPlane;
  95732. private _pointA;
  95733. private _pointB;
  95734. private _pointC;
  95735. private _lineA;
  95736. private _lineB;
  95737. private _localAxis;
  95738. private _lookAt;
  95739. private _updateDragPlanePosition;
  95740. /**
  95741. * Detaches the behavior from the mesh
  95742. */
  95743. detach(): void;
  95744. }
  95745. }
  95746. declare module BABYLON {
  95747. /**
  95748. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95749. */
  95750. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95751. private _dragBehaviorA;
  95752. private _dragBehaviorB;
  95753. private _startDistance;
  95754. private _initialScale;
  95755. private _targetScale;
  95756. private _ownerNode;
  95757. private _sceneRenderObserver;
  95758. /**
  95759. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95760. */
  95761. constructor();
  95762. /**
  95763. * The name of the behavior
  95764. */
  95765. readonly name: string;
  95766. /**
  95767. * Initializes the behavior
  95768. */
  95769. init(): void;
  95770. private _getCurrentDistance;
  95771. /**
  95772. * Attaches the scale behavior the passed in mesh
  95773. * @param ownerNode The mesh that will be scaled around once attached
  95774. */
  95775. attach(ownerNode: Mesh): void;
  95776. /**
  95777. * Detaches the behavior from the mesh
  95778. */
  95779. detach(): void;
  95780. }
  95781. }
  95782. declare module BABYLON {
  95783. /**
  95784. * 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
  95785. */
  95786. export class SixDofDragBehavior implements Behavior<Mesh> {
  95787. private static _virtualScene;
  95788. private _ownerNode;
  95789. private _sceneRenderObserver;
  95790. private _scene;
  95791. private _targetPosition;
  95792. private _virtualOriginMesh;
  95793. private _virtualDragMesh;
  95794. private _pointerObserver;
  95795. private _moving;
  95796. private _startingOrientation;
  95797. /**
  95798. * 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)
  95799. */
  95800. private zDragFactor;
  95801. /**
  95802. * If the object should rotate to face the drag origin
  95803. */
  95804. rotateDraggedObject: boolean;
  95805. /**
  95806. * If the behavior is currently in a dragging state
  95807. */
  95808. dragging: boolean;
  95809. /**
  95810. * 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)
  95811. */
  95812. dragDeltaRatio: number;
  95813. /**
  95814. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95815. */
  95816. currentDraggingPointerID: number;
  95817. /**
  95818. * If camera controls should be detached during the drag
  95819. */
  95820. detachCameraControls: boolean;
  95821. /**
  95822. * Fires each time a drag starts
  95823. */
  95824. onDragStartObservable: Observable<{}>;
  95825. /**
  95826. * Fires each time a drag ends (eg. mouse release after drag)
  95827. */
  95828. onDragEndObservable: Observable<{}>;
  95829. /**
  95830. * 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
  95831. */
  95832. constructor();
  95833. /**
  95834. * The name of the behavior
  95835. */
  95836. readonly name: string;
  95837. /**
  95838. * Initializes the behavior
  95839. */
  95840. init(): void;
  95841. /**
  95842. * Attaches the scale behavior the passed in mesh
  95843. * @param ownerNode The mesh that will be scaled around once attached
  95844. */
  95845. attach(ownerNode: Mesh): void;
  95846. /**
  95847. * Detaches the behavior from the mesh
  95848. */
  95849. detach(): void;
  95850. }
  95851. }
  95852. declare module BABYLON {
  95853. /**
  95854. * Class used to apply inverse kinematics to bones
  95855. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95856. */
  95857. export class BoneIKController {
  95858. private static _tmpVecs;
  95859. private static _tmpQuat;
  95860. private static _tmpMats;
  95861. /**
  95862. * Gets or sets the target mesh
  95863. */
  95864. targetMesh: AbstractMesh;
  95865. /** Gets or sets the mesh used as pole */
  95866. poleTargetMesh: AbstractMesh;
  95867. /**
  95868. * Gets or sets the bone used as pole
  95869. */
  95870. poleTargetBone: Nullable<Bone>;
  95871. /**
  95872. * Gets or sets the target position
  95873. */
  95874. targetPosition: Vector3;
  95875. /**
  95876. * Gets or sets the pole target position
  95877. */
  95878. poleTargetPosition: Vector3;
  95879. /**
  95880. * Gets or sets the pole target local offset
  95881. */
  95882. poleTargetLocalOffset: Vector3;
  95883. /**
  95884. * Gets or sets the pole angle
  95885. */
  95886. poleAngle: number;
  95887. /**
  95888. * Gets or sets the mesh associated with the controller
  95889. */
  95890. mesh: AbstractMesh;
  95891. /**
  95892. * 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)
  95893. */
  95894. slerpAmount: number;
  95895. private _bone1Quat;
  95896. private _bone1Mat;
  95897. private _bone2Ang;
  95898. private _bone1;
  95899. private _bone2;
  95900. private _bone1Length;
  95901. private _bone2Length;
  95902. private _maxAngle;
  95903. private _maxReach;
  95904. private _rightHandedSystem;
  95905. private _bendAxis;
  95906. private _slerping;
  95907. private _adjustRoll;
  95908. /**
  95909. * Gets or sets maximum allowed angle
  95910. */
  95911. maxAngle: number;
  95912. /**
  95913. * Creates a new BoneIKController
  95914. * @param mesh defines the mesh to control
  95915. * @param bone defines the bone to control
  95916. * @param options defines options to set up the controller
  95917. */
  95918. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95919. targetMesh?: AbstractMesh;
  95920. poleTargetMesh?: AbstractMesh;
  95921. poleTargetBone?: Bone;
  95922. poleTargetLocalOffset?: Vector3;
  95923. poleAngle?: number;
  95924. bendAxis?: Vector3;
  95925. maxAngle?: number;
  95926. slerpAmount?: number;
  95927. });
  95928. private _setMaxAngle;
  95929. /**
  95930. * Force the controller to update the bones
  95931. */
  95932. update(): void;
  95933. }
  95934. }
  95935. declare module BABYLON {
  95936. /**
  95937. * Class used to make a bone look toward a point in space
  95938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95939. */
  95940. export class BoneLookController {
  95941. private static _tmpVecs;
  95942. private static _tmpQuat;
  95943. private static _tmpMats;
  95944. /**
  95945. * The target Vector3 that the bone will look at
  95946. */
  95947. target: Vector3;
  95948. /**
  95949. * The mesh that the bone is attached to
  95950. */
  95951. mesh: AbstractMesh;
  95952. /**
  95953. * The bone that will be looking to the target
  95954. */
  95955. bone: Bone;
  95956. /**
  95957. * The up axis of the coordinate system that is used when the bone is rotated
  95958. */
  95959. upAxis: Vector3;
  95960. /**
  95961. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95962. */
  95963. upAxisSpace: Space;
  95964. /**
  95965. * Used to make an adjustment to the yaw of the bone
  95966. */
  95967. adjustYaw: number;
  95968. /**
  95969. * Used to make an adjustment to the pitch of the bone
  95970. */
  95971. adjustPitch: number;
  95972. /**
  95973. * Used to make an adjustment to the roll of the bone
  95974. */
  95975. adjustRoll: number;
  95976. /**
  95977. * 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)
  95978. */
  95979. slerpAmount: number;
  95980. private _minYaw;
  95981. private _maxYaw;
  95982. private _minPitch;
  95983. private _maxPitch;
  95984. private _minYawSin;
  95985. private _minYawCos;
  95986. private _maxYawSin;
  95987. private _maxYawCos;
  95988. private _midYawConstraint;
  95989. private _minPitchTan;
  95990. private _maxPitchTan;
  95991. private _boneQuat;
  95992. private _slerping;
  95993. private _transformYawPitch;
  95994. private _transformYawPitchInv;
  95995. private _firstFrameSkipped;
  95996. private _yawRange;
  95997. private _fowardAxis;
  95998. /**
  95999. * Gets or sets the minimum yaw angle that the bone can look to
  96000. */
  96001. minYaw: number;
  96002. /**
  96003. * Gets or sets the maximum yaw angle that the bone can look to
  96004. */
  96005. maxYaw: number;
  96006. /**
  96007. * Gets or sets the minimum pitch angle that the bone can look to
  96008. */
  96009. minPitch: number;
  96010. /**
  96011. * Gets or sets the maximum pitch angle that the bone can look to
  96012. */
  96013. maxPitch: number;
  96014. /**
  96015. * Create a BoneLookController
  96016. * @param mesh the mesh that the bone belongs to
  96017. * @param bone the bone that will be looking to the target
  96018. * @param target the target Vector3 to look at
  96019. * @param options optional settings:
  96020. * * maxYaw: the maximum angle the bone will yaw to
  96021. * * minYaw: the minimum angle the bone will yaw to
  96022. * * maxPitch: the maximum angle the bone will pitch to
  96023. * * minPitch: the minimum angle the bone will yaw to
  96024. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96025. * * upAxis: the up axis of the coordinate system
  96026. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96027. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96028. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96029. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96030. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96031. * * adjustRoll: used to make an adjustment to the roll of the bone
  96032. **/
  96033. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96034. maxYaw?: number;
  96035. minYaw?: number;
  96036. maxPitch?: number;
  96037. minPitch?: number;
  96038. slerpAmount?: number;
  96039. upAxis?: Vector3;
  96040. upAxisSpace?: Space;
  96041. yawAxis?: Vector3;
  96042. pitchAxis?: Vector3;
  96043. adjustYaw?: number;
  96044. adjustPitch?: number;
  96045. adjustRoll?: number;
  96046. });
  96047. /**
  96048. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96049. */
  96050. update(): void;
  96051. private _getAngleDiff;
  96052. private _getAngleBetween;
  96053. private _isAngleBetween;
  96054. }
  96055. }
  96056. declare module BABYLON {
  96057. /**
  96058. * Manage the gamepad inputs to control an arc rotate camera.
  96059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96060. */
  96061. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96062. /**
  96063. * Defines the camera the input is attached to.
  96064. */
  96065. camera: ArcRotateCamera;
  96066. /**
  96067. * Defines the gamepad the input is gathering event from.
  96068. */
  96069. gamepad: Nullable<Gamepad>;
  96070. /**
  96071. * Defines the gamepad rotation sensiblity.
  96072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96073. */
  96074. gamepadRotationSensibility: number;
  96075. /**
  96076. * Defines the gamepad move sensiblity.
  96077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96078. */
  96079. gamepadMoveSensibility: number;
  96080. private _onGamepadConnectedObserver;
  96081. private _onGamepadDisconnectedObserver;
  96082. /**
  96083. * Attach the input controls to a specific dom element to get the input from.
  96084. * @param element Defines the element the controls should be listened from
  96085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96086. */
  96087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96088. /**
  96089. * Detach the current controls from the specified dom element.
  96090. * @param element Defines the element to stop listening the inputs from
  96091. */
  96092. detachControl(element: Nullable<HTMLElement>): void;
  96093. /**
  96094. * Update the current camera state depending on the inputs that have been used this frame.
  96095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96096. */
  96097. checkInputs(): void;
  96098. /**
  96099. * Gets the class name of the current intput.
  96100. * @returns the class name
  96101. */
  96102. getClassName(): string;
  96103. /**
  96104. * Get the friendly name associated with the input class.
  96105. * @returns the input friendly name
  96106. */
  96107. getSimpleName(): string;
  96108. }
  96109. }
  96110. declare module BABYLON {
  96111. interface ArcRotateCameraInputsManager {
  96112. /**
  96113. * Add orientation input support to the input manager.
  96114. * @returns the current input manager
  96115. */
  96116. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96117. }
  96118. /**
  96119. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96121. */
  96122. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96123. /**
  96124. * Defines the camera the input is attached to.
  96125. */
  96126. camera: ArcRotateCamera;
  96127. /**
  96128. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96129. */
  96130. alphaCorrection: number;
  96131. /**
  96132. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96133. */
  96134. gammaCorrection: number;
  96135. private _alpha;
  96136. private _gamma;
  96137. private _dirty;
  96138. private _deviceOrientationHandler;
  96139. /**
  96140. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96141. */
  96142. constructor();
  96143. /**
  96144. * Attach the input controls to a specific dom element to get the input from.
  96145. * @param element Defines the element the controls should be listened from
  96146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96147. */
  96148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96149. /** @hidden */
  96150. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96151. /**
  96152. * Update the current camera state depending on the inputs that have been used this frame.
  96153. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96154. */
  96155. checkInputs(): void;
  96156. /**
  96157. * Detach the current controls from the specified dom element.
  96158. * @param element Defines the element to stop listening the inputs from
  96159. */
  96160. detachControl(element: Nullable<HTMLElement>): void;
  96161. /**
  96162. * Gets the class name of the current intput.
  96163. * @returns the class name
  96164. */
  96165. getClassName(): string;
  96166. /**
  96167. * Get the friendly name associated with the input class.
  96168. * @returns the input friendly name
  96169. */
  96170. getSimpleName(): string;
  96171. }
  96172. }
  96173. declare module BABYLON {
  96174. /**
  96175. * Listen to mouse events to control the camera.
  96176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96177. */
  96178. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96179. /**
  96180. * Defines the camera the input is attached to.
  96181. */
  96182. camera: FlyCamera;
  96183. /**
  96184. * Defines if touch is enabled. (Default is true.)
  96185. */
  96186. touchEnabled: boolean;
  96187. /**
  96188. * Defines the buttons associated with the input to handle camera rotation.
  96189. */
  96190. buttons: number[];
  96191. /**
  96192. * Assign buttons for Yaw control.
  96193. */
  96194. buttonsYaw: number[];
  96195. /**
  96196. * Assign buttons for Pitch control.
  96197. */
  96198. buttonsPitch: number[];
  96199. /**
  96200. * Assign buttons for Roll control.
  96201. */
  96202. buttonsRoll: number[];
  96203. /**
  96204. * Detect if any button is being pressed while mouse is moved.
  96205. * -1 = Mouse locked.
  96206. * 0 = Left button.
  96207. * 1 = Middle Button.
  96208. * 2 = Right Button.
  96209. */
  96210. activeButton: number;
  96211. /**
  96212. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96213. * Higher values reduce its sensitivity.
  96214. */
  96215. angularSensibility: number;
  96216. private _mousemoveCallback;
  96217. private _observer;
  96218. private _rollObserver;
  96219. private previousPosition;
  96220. private noPreventDefault;
  96221. private element;
  96222. /**
  96223. * Listen to mouse events to control the camera.
  96224. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96226. */
  96227. constructor(touchEnabled?: boolean);
  96228. /**
  96229. * Attach the mouse control to the HTML DOM element.
  96230. * @param element Defines the element that listens to the input events.
  96231. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96232. */
  96233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96234. /**
  96235. * Detach the current controls from the specified dom element.
  96236. * @param element Defines the element to stop listening the inputs from
  96237. */
  96238. detachControl(element: Nullable<HTMLElement>): void;
  96239. /**
  96240. * Gets the class name of the current input.
  96241. * @returns the class name.
  96242. */
  96243. getClassName(): string;
  96244. /**
  96245. * Get the friendly name associated with the input class.
  96246. * @returns the input's friendly name.
  96247. */
  96248. getSimpleName(): string;
  96249. private _pointerInput;
  96250. private _onMouseMove;
  96251. /**
  96252. * Rotate camera by mouse offset.
  96253. */
  96254. private rotateCamera;
  96255. }
  96256. }
  96257. declare module BABYLON {
  96258. /**
  96259. * Default Inputs manager for the FlyCamera.
  96260. * It groups all the default supported inputs for ease of use.
  96261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96262. */
  96263. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96264. /**
  96265. * Instantiates a new FlyCameraInputsManager.
  96266. * @param camera Defines the camera the inputs belong to.
  96267. */
  96268. constructor(camera: FlyCamera);
  96269. /**
  96270. * Add keyboard input support to the input manager.
  96271. * @returns the new FlyCameraKeyboardMoveInput().
  96272. */
  96273. addKeyboard(): FlyCameraInputsManager;
  96274. /**
  96275. * Add mouse input support to the input manager.
  96276. * @param touchEnabled Enable touch screen support.
  96277. * @returns the new FlyCameraMouseInput().
  96278. */
  96279. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96280. }
  96281. }
  96282. declare module BABYLON {
  96283. /**
  96284. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96285. * such as in a 3D Space Shooter or a Flight Simulator.
  96286. */
  96287. export class FlyCamera extends TargetCamera {
  96288. /**
  96289. * Define the collision ellipsoid of the camera.
  96290. * This is helpful for simulating a camera body, like a player's body.
  96291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96292. */
  96293. ellipsoid: Vector3;
  96294. /**
  96295. * Define an offset for the position of the ellipsoid around the camera.
  96296. * This can be helpful if the camera is attached away from the player's body center,
  96297. * such as at its head.
  96298. */
  96299. ellipsoidOffset: Vector3;
  96300. /**
  96301. * Enable or disable collisions of the camera with the rest of the scene objects.
  96302. */
  96303. checkCollisions: boolean;
  96304. /**
  96305. * Enable or disable gravity on the camera.
  96306. */
  96307. applyGravity: boolean;
  96308. /**
  96309. * Define the current direction the camera is moving to.
  96310. */
  96311. cameraDirection: Vector3;
  96312. /**
  96313. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96314. * This overrides and empties cameraRotation.
  96315. */
  96316. rotationQuaternion: Quaternion;
  96317. /**
  96318. * Track Roll to maintain the wanted Rolling when looking around.
  96319. */
  96320. _trackRoll: number;
  96321. /**
  96322. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96323. */
  96324. rollCorrect: number;
  96325. /**
  96326. * Mimic a banked turn, Rolling the camera when Yawing.
  96327. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96328. */
  96329. bankedTurn: boolean;
  96330. /**
  96331. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96332. */
  96333. bankedTurnLimit: number;
  96334. /**
  96335. * Value of 0 disables the banked Roll.
  96336. * Value of 1 is equal to the Yaw angle in radians.
  96337. */
  96338. bankedTurnMultiplier: number;
  96339. /**
  96340. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96341. */
  96342. inputs: FlyCameraInputsManager;
  96343. /**
  96344. * Gets the input sensibility for mouse input.
  96345. * Higher values reduce sensitivity.
  96346. */
  96347. /**
  96348. * Sets the input sensibility for a mouse input.
  96349. * Higher values reduce sensitivity.
  96350. */
  96351. angularSensibility: number;
  96352. /**
  96353. * Get the keys for camera movement forward.
  96354. */
  96355. /**
  96356. * Set the keys for camera movement forward.
  96357. */
  96358. keysForward: number[];
  96359. /**
  96360. * Get the keys for camera movement backward.
  96361. */
  96362. keysBackward: number[];
  96363. /**
  96364. * Get the keys for camera movement up.
  96365. */
  96366. /**
  96367. * Set the keys for camera movement up.
  96368. */
  96369. keysUp: number[];
  96370. /**
  96371. * Get the keys for camera movement down.
  96372. */
  96373. /**
  96374. * Set the keys for camera movement down.
  96375. */
  96376. keysDown: number[];
  96377. /**
  96378. * Get the keys for camera movement left.
  96379. */
  96380. /**
  96381. * Set the keys for camera movement left.
  96382. */
  96383. keysLeft: number[];
  96384. /**
  96385. * Set the keys for camera movement right.
  96386. */
  96387. /**
  96388. * Set the keys for camera movement right.
  96389. */
  96390. keysRight: number[];
  96391. /**
  96392. * Event raised when the camera collides with a mesh in the scene.
  96393. */
  96394. onCollide: (collidedMesh: AbstractMesh) => void;
  96395. private _collider;
  96396. private _needMoveForGravity;
  96397. private _oldPosition;
  96398. private _diffPosition;
  96399. private _newPosition;
  96400. /** @hidden */
  96401. _localDirection: Vector3;
  96402. /** @hidden */
  96403. _transformedDirection: Vector3;
  96404. /**
  96405. * Instantiates a FlyCamera.
  96406. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96407. * such as in a 3D Space Shooter or a Flight Simulator.
  96408. * @param name Define the name of the camera in the scene.
  96409. * @param position Define the starting position of the camera in the scene.
  96410. * @param scene Define the scene the camera belongs to.
  96411. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96412. */
  96413. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96414. /**
  96415. * Attach a control to the HTML DOM element.
  96416. * @param element Defines the element that listens to the input events.
  96417. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96418. */
  96419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96420. /**
  96421. * Detach a control from the HTML DOM element.
  96422. * The camera will stop reacting to that input.
  96423. * @param element Defines the element that listens to the input events.
  96424. */
  96425. detachControl(element: HTMLElement): void;
  96426. private _collisionMask;
  96427. /**
  96428. * Get the mask that the camera ignores in collision events.
  96429. */
  96430. /**
  96431. * Set the mask that the camera ignores in collision events.
  96432. */
  96433. collisionMask: number;
  96434. /** @hidden */
  96435. _collideWithWorld(displacement: Vector3): void;
  96436. /** @hidden */
  96437. private _onCollisionPositionChange;
  96438. /** @hidden */
  96439. _checkInputs(): void;
  96440. /** @hidden */
  96441. _decideIfNeedsToMove(): boolean;
  96442. /** @hidden */
  96443. _updatePosition(): void;
  96444. /**
  96445. * Restore the Roll to its target value at the rate specified.
  96446. * @param rate - Higher means slower restoring.
  96447. * @hidden
  96448. */
  96449. restoreRoll(rate: number): void;
  96450. /**
  96451. * Destroy the camera and release the current resources held by it.
  96452. */
  96453. dispose(): void;
  96454. /**
  96455. * Get the current object class name.
  96456. * @returns the class name.
  96457. */
  96458. getClassName(): string;
  96459. }
  96460. }
  96461. declare module BABYLON {
  96462. /**
  96463. * Listen to keyboard events to control the camera.
  96464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96465. */
  96466. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96467. /**
  96468. * Defines the camera the input is attached to.
  96469. */
  96470. camera: FlyCamera;
  96471. /**
  96472. * The list of keyboard keys used to control the forward move of the camera.
  96473. */
  96474. keysForward: number[];
  96475. /**
  96476. * The list of keyboard keys used to control the backward move of the camera.
  96477. */
  96478. keysBackward: number[];
  96479. /**
  96480. * The list of keyboard keys used to control the forward move of the camera.
  96481. */
  96482. keysUp: number[];
  96483. /**
  96484. * The list of keyboard keys used to control the backward move of the camera.
  96485. */
  96486. keysDown: number[];
  96487. /**
  96488. * The list of keyboard keys used to control the right strafe move of the camera.
  96489. */
  96490. keysRight: number[];
  96491. /**
  96492. * The list of keyboard keys used to control the left strafe move of the camera.
  96493. */
  96494. keysLeft: number[];
  96495. private _keys;
  96496. private _onCanvasBlurObserver;
  96497. private _onKeyboardObserver;
  96498. private _engine;
  96499. private _scene;
  96500. /**
  96501. * Attach the input controls to a specific dom element to get the input from.
  96502. * @param element Defines the element the controls should be listened from
  96503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96504. */
  96505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96506. /**
  96507. * Detach the current controls from the specified dom element.
  96508. * @param element Defines the element to stop listening the inputs from
  96509. */
  96510. detachControl(element: Nullable<HTMLElement>): void;
  96511. /**
  96512. * Gets the class name of the current intput.
  96513. * @returns the class name
  96514. */
  96515. getClassName(): string;
  96516. /** @hidden */
  96517. _onLostFocus(e: FocusEvent): void;
  96518. /**
  96519. * Get the friendly name associated with the input class.
  96520. * @returns the input friendly name
  96521. */
  96522. getSimpleName(): string;
  96523. /**
  96524. * Update the current camera state depending on the inputs that have been used this frame.
  96525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96526. */
  96527. checkInputs(): void;
  96528. }
  96529. }
  96530. declare module BABYLON {
  96531. /**
  96532. * Manage the mouse wheel inputs to control a follow camera.
  96533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96534. */
  96535. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96536. /**
  96537. * Defines the camera the input is attached to.
  96538. */
  96539. camera: FollowCamera;
  96540. /**
  96541. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96542. */
  96543. axisControlRadius: boolean;
  96544. /**
  96545. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96546. */
  96547. axisControlHeight: boolean;
  96548. /**
  96549. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96550. */
  96551. axisControlRotation: boolean;
  96552. /**
  96553. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96554. * relation to mouseWheel events.
  96555. */
  96556. wheelPrecision: number;
  96557. /**
  96558. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96559. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96560. */
  96561. wheelDeltaPercentage: number;
  96562. private _wheel;
  96563. private _observer;
  96564. /**
  96565. * Attach the input controls to a specific dom element to get the input from.
  96566. * @param element Defines the element the controls should be listened from
  96567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96568. */
  96569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96570. /**
  96571. * Detach the current controls from the specified dom element.
  96572. * @param element Defines the element to stop listening the inputs from
  96573. */
  96574. detachControl(element: Nullable<HTMLElement>): void;
  96575. /**
  96576. * Gets the class name of the current intput.
  96577. * @returns the class name
  96578. */
  96579. getClassName(): string;
  96580. /**
  96581. * Get the friendly name associated with the input class.
  96582. * @returns the input friendly name
  96583. */
  96584. getSimpleName(): string;
  96585. }
  96586. }
  96587. declare module BABYLON {
  96588. /**
  96589. * Manage the pointers inputs to control an follow camera.
  96590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96591. */
  96592. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96593. /**
  96594. * Defines the camera the input is attached to.
  96595. */
  96596. camera: FollowCamera;
  96597. /**
  96598. * Gets the class name of the current input.
  96599. * @returns the class name
  96600. */
  96601. getClassName(): string;
  96602. /**
  96603. * Defines the pointer angular sensibility along the X axis or how fast is
  96604. * the camera rotating.
  96605. * A negative number will reverse the axis direction.
  96606. */
  96607. angularSensibilityX: number;
  96608. /**
  96609. * Defines the pointer angular sensibility along the Y axis or how fast is
  96610. * the camera rotating.
  96611. * A negative number will reverse the axis direction.
  96612. */
  96613. angularSensibilityY: number;
  96614. /**
  96615. * Defines the pointer pinch precision or how fast is the camera zooming.
  96616. * A negative number will reverse the axis direction.
  96617. */
  96618. pinchPrecision: number;
  96619. /**
  96620. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96621. * from 0.
  96622. * It defines the percentage of current camera.radius to use as delta when
  96623. * pinch zoom is used.
  96624. */
  96625. pinchDeltaPercentage: number;
  96626. /**
  96627. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96628. */
  96629. axisXControlRadius: boolean;
  96630. /**
  96631. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96632. */
  96633. axisXControlHeight: boolean;
  96634. /**
  96635. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96636. */
  96637. axisXControlRotation: boolean;
  96638. /**
  96639. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96640. */
  96641. axisYControlRadius: boolean;
  96642. /**
  96643. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96644. */
  96645. axisYControlHeight: boolean;
  96646. /**
  96647. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96648. */
  96649. axisYControlRotation: boolean;
  96650. /**
  96651. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96652. */
  96653. axisPinchControlRadius: boolean;
  96654. /**
  96655. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96656. */
  96657. axisPinchControlHeight: boolean;
  96658. /**
  96659. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96660. */
  96661. axisPinchControlRotation: boolean;
  96662. /**
  96663. * Log error messages if basic misconfiguration has occurred.
  96664. */
  96665. warningEnable: boolean;
  96666. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96667. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96668. private _warningCounter;
  96669. private _warning;
  96670. }
  96671. }
  96672. declare module BABYLON {
  96673. /**
  96674. * Default Inputs manager for the FollowCamera.
  96675. * It groups all the default supported inputs for ease of use.
  96676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96677. */
  96678. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96679. /**
  96680. * Instantiates a new FollowCameraInputsManager.
  96681. * @param camera Defines the camera the inputs belong to
  96682. */
  96683. constructor(camera: FollowCamera);
  96684. /**
  96685. * Add keyboard input support to the input manager.
  96686. * @returns the current input manager
  96687. */
  96688. addKeyboard(): FollowCameraInputsManager;
  96689. /**
  96690. * Add mouse wheel input support to the input manager.
  96691. * @returns the current input manager
  96692. */
  96693. addMouseWheel(): FollowCameraInputsManager;
  96694. /**
  96695. * Add pointers input support to the input manager.
  96696. * @returns the current input manager
  96697. */
  96698. addPointers(): FollowCameraInputsManager;
  96699. /**
  96700. * Add orientation input support to the input manager.
  96701. * @returns the current input manager
  96702. */
  96703. addVRDeviceOrientation(): FollowCameraInputsManager;
  96704. }
  96705. }
  96706. declare module BABYLON {
  96707. /**
  96708. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96709. * an arc rotate version arcFollowCamera are available.
  96710. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96711. */
  96712. export class FollowCamera extends TargetCamera {
  96713. /**
  96714. * Distance the follow camera should follow an object at
  96715. */
  96716. radius: number;
  96717. /**
  96718. * Minimum allowed distance of the camera to the axis of rotation
  96719. * (The camera can not get closer).
  96720. * This can help limiting how the Camera is able to move in the scene.
  96721. */
  96722. lowerRadiusLimit: Nullable<number>;
  96723. /**
  96724. * Maximum allowed distance of the camera to the axis of rotation
  96725. * (The camera can not get further).
  96726. * This can help limiting how the Camera is able to move in the scene.
  96727. */
  96728. upperRadiusLimit: Nullable<number>;
  96729. /**
  96730. * Define a rotation offset between the camera and the object it follows
  96731. */
  96732. rotationOffset: number;
  96733. /**
  96734. * Minimum allowed angle to camera position relative to target object.
  96735. * This can help limiting how the Camera is able to move in the scene.
  96736. */
  96737. lowerRotationOffsetLimit: Nullable<number>;
  96738. /**
  96739. * Maximum allowed angle to camera position relative to target object.
  96740. * This can help limiting how the Camera is able to move in the scene.
  96741. */
  96742. upperRotationOffsetLimit: Nullable<number>;
  96743. /**
  96744. * Define a height offset between the camera and the object it follows.
  96745. * It can help following an object from the top (like a car chaing a plane)
  96746. */
  96747. heightOffset: number;
  96748. /**
  96749. * Minimum allowed height of camera position relative to target object.
  96750. * This can help limiting how the Camera is able to move in the scene.
  96751. */
  96752. lowerHeightOffsetLimit: Nullable<number>;
  96753. /**
  96754. * Maximum allowed height of camera position relative to target object.
  96755. * This can help limiting how the Camera is able to move in the scene.
  96756. */
  96757. upperHeightOffsetLimit: Nullable<number>;
  96758. /**
  96759. * Define how fast the camera can accelerate to follow it s target.
  96760. */
  96761. cameraAcceleration: number;
  96762. /**
  96763. * Define the speed limit of the camera following an object.
  96764. */
  96765. maxCameraSpeed: number;
  96766. /**
  96767. * Define the target of the camera.
  96768. */
  96769. lockedTarget: Nullable<AbstractMesh>;
  96770. /**
  96771. * Defines the input associated with the camera.
  96772. */
  96773. inputs: FollowCameraInputsManager;
  96774. /**
  96775. * Instantiates the follow camera.
  96776. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96777. * @param name Define the name of the camera in the scene
  96778. * @param position Define the position of the camera
  96779. * @param scene Define the scene the camera belong to
  96780. * @param lockedTarget Define the target of the camera
  96781. */
  96782. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96783. private _follow;
  96784. /**
  96785. * Attached controls to the current camera.
  96786. * @param element Defines the element the controls should be listened from
  96787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96788. */
  96789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96790. /**
  96791. * Detach the current controls from the camera.
  96792. * The camera will stop reacting to inputs.
  96793. * @param element Defines the element to stop listening the inputs from
  96794. */
  96795. detachControl(element: HTMLElement): void;
  96796. /** @hidden */
  96797. _checkInputs(): void;
  96798. private _checkLimits;
  96799. /**
  96800. * Gets the camera class name.
  96801. * @returns the class name
  96802. */
  96803. getClassName(): string;
  96804. }
  96805. /**
  96806. * Arc Rotate version of the follow camera.
  96807. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96808. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96809. */
  96810. export class ArcFollowCamera extends TargetCamera {
  96811. /** The longitudinal angle of the camera */
  96812. alpha: number;
  96813. /** The latitudinal angle of the camera */
  96814. beta: number;
  96815. /** The radius of the camera from its target */
  96816. radius: number;
  96817. /** Define the camera target (the messh it should follow) */
  96818. target: Nullable<AbstractMesh>;
  96819. private _cartesianCoordinates;
  96820. /**
  96821. * Instantiates a new ArcFollowCamera
  96822. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96823. * @param name Define the name of the camera
  96824. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96825. * @param beta Define the rotation angle of the camera around the elevation axis
  96826. * @param radius Define the radius of the camera from its target point
  96827. * @param target Define the target of the camera
  96828. * @param scene Define the scene the camera belongs to
  96829. */
  96830. constructor(name: string,
  96831. /** The longitudinal angle of the camera */
  96832. alpha: number,
  96833. /** The latitudinal angle of the camera */
  96834. beta: number,
  96835. /** The radius of the camera from its target */
  96836. radius: number,
  96837. /** Define the camera target (the messh it should follow) */
  96838. target: Nullable<AbstractMesh>, scene: Scene);
  96839. private _follow;
  96840. /** @hidden */
  96841. _checkInputs(): void;
  96842. /**
  96843. * Returns the class name of the object.
  96844. * It is mostly used internally for serialization purposes.
  96845. */
  96846. getClassName(): string;
  96847. }
  96848. }
  96849. declare module BABYLON {
  96850. /**
  96851. * Manage the keyboard inputs to control the movement of a follow camera.
  96852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96853. */
  96854. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96855. /**
  96856. * Defines the camera the input is attached to.
  96857. */
  96858. camera: FollowCamera;
  96859. /**
  96860. * Defines the list of key codes associated with the up action (increase heightOffset)
  96861. */
  96862. keysHeightOffsetIncr: number[];
  96863. /**
  96864. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96865. */
  96866. keysHeightOffsetDecr: number[];
  96867. /**
  96868. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96869. */
  96870. keysHeightOffsetModifierAlt: boolean;
  96871. /**
  96872. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96873. */
  96874. keysHeightOffsetModifierCtrl: boolean;
  96875. /**
  96876. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96877. */
  96878. keysHeightOffsetModifierShift: boolean;
  96879. /**
  96880. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96881. */
  96882. keysRotationOffsetIncr: number[];
  96883. /**
  96884. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96885. */
  96886. keysRotationOffsetDecr: number[];
  96887. /**
  96888. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96889. */
  96890. keysRotationOffsetModifierAlt: boolean;
  96891. /**
  96892. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96893. */
  96894. keysRotationOffsetModifierCtrl: boolean;
  96895. /**
  96896. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96897. */
  96898. keysRotationOffsetModifierShift: boolean;
  96899. /**
  96900. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96901. */
  96902. keysRadiusIncr: number[];
  96903. /**
  96904. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96905. */
  96906. keysRadiusDecr: number[];
  96907. /**
  96908. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96909. */
  96910. keysRadiusModifierAlt: boolean;
  96911. /**
  96912. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96913. */
  96914. keysRadiusModifierCtrl: boolean;
  96915. /**
  96916. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96917. */
  96918. keysRadiusModifierShift: boolean;
  96919. /**
  96920. * Defines the rate of change of heightOffset.
  96921. */
  96922. heightSensibility: number;
  96923. /**
  96924. * Defines the rate of change of rotationOffset.
  96925. */
  96926. rotationSensibility: number;
  96927. /**
  96928. * Defines the rate of change of radius.
  96929. */
  96930. radiusSensibility: number;
  96931. private _keys;
  96932. private _ctrlPressed;
  96933. private _altPressed;
  96934. private _shiftPressed;
  96935. private _onCanvasBlurObserver;
  96936. private _onKeyboardObserver;
  96937. private _engine;
  96938. private _scene;
  96939. /**
  96940. * Attach the input controls to a specific dom element to get the input from.
  96941. * @param element Defines the element the controls should be listened from
  96942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96943. */
  96944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96945. /**
  96946. * Detach the current controls from the specified dom element.
  96947. * @param element Defines the element to stop listening the inputs from
  96948. */
  96949. detachControl(element: Nullable<HTMLElement>): void;
  96950. /**
  96951. * Update the current camera state depending on the inputs that have been used this frame.
  96952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96953. */
  96954. checkInputs(): void;
  96955. /**
  96956. * Gets the class name of the current input.
  96957. * @returns the class name
  96958. */
  96959. getClassName(): string;
  96960. /**
  96961. * Get the friendly name associated with the input class.
  96962. * @returns the input friendly name
  96963. */
  96964. getSimpleName(): string;
  96965. /**
  96966. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96967. * allow modification of the heightOffset value.
  96968. */
  96969. private _modifierHeightOffset;
  96970. /**
  96971. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96972. * allow modification of the rotationOffset value.
  96973. */
  96974. private _modifierRotationOffset;
  96975. /**
  96976. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96977. * allow modification of the radius value.
  96978. */
  96979. private _modifierRadius;
  96980. }
  96981. }
  96982. declare module BABYLON {
  96983. interface FreeCameraInputsManager {
  96984. /**
  96985. * @hidden
  96986. */
  96987. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96988. /**
  96989. * Add orientation input support to the input manager.
  96990. * @returns the current input manager
  96991. */
  96992. addDeviceOrientation(): FreeCameraInputsManager;
  96993. }
  96994. /**
  96995. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96996. * Screen rotation is taken into account.
  96997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96998. */
  96999. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97000. private _camera;
  97001. private _screenOrientationAngle;
  97002. private _constantTranform;
  97003. private _screenQuaternion;
  97004. private _alpha;
  97005. private _beta;
  97006. private _gamma;
  97007. /**
  97008. * @hidden
  97009. */
  97010. _onDeviceOrientationChangedObservable: Observable<void>;
  97011. /**
  97012. * Instantiates a new input
  97013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97014. */
  97015. constructor();
  97016. /**
  97017. * Define the camera controlled by the input.
  97018. */
  97019. camera: FreeCamera;
  97020. /**
  97021. * Attach the input controls to a specific dom element to get the input from.
  97022. * @param element Defines the element the controls should be listened from
  97023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97024. */
  97025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97026. private _orientationChanged;
  97027. private _deviceOrientation;
  97028. /**
  97029. * Detach the current controls from the specified dom element.
  97030. * @param element Defines the element to stop listening the inputs from
  97031. */
  97032. detachControl(element: Nullable<HTMLElement>): void;
  97033. /**
  97034. * Update the current camera state depending on the inputs that have been used this frame.
  97035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97036. */
  97037. checkInputs(): void;
  97038. /**
  97039. * Gets the class name of the current intput.
  97040. * @returns the class name
  97041. */
  97042. getClassName(): string;
  97043. /**
  97044. * Get the friendly name associated with the input class.
  97045. * @returns the input friendly name
  97046. */
  97047. getSimpleName(): string;
  97048. }
  97049. }
  97050. declare module BABYLON {
  97051. /**
  97052. * Manage the gamepad inputs to control a free camera.
  97053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97054. */
  97055. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97056. /**
  97057. * Define the camera the input is attached to.
  97058. */
  97059. camera: FreeCamera;
  97060. /**
  97061. * Define the Gamepad controlling the input
  97062. */
  97063. gamepad: Nullable<Gamepad>;
  97064. /**
  97065. * Defines the gamepad rotation sensiblity.
  97066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97067. */
  97068. gamepadAngularSensibility: number;
  97069. /**
  97070. * Defines the gamepad move sensiblity.
  97071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97072. */
  97073. gamepadMoveSensibility: number;
  97074. private _onGamepadConnectedObserver;
  97075. private _onGamepadDisconnectedObserver;
  97076. private _cameraTransform;
  97077. private _deltaTransform;
  97078. private _vector3;
  97079. private _vector2;
  97080. /**
  97081. * Attach the input controls to a specific dom element to get the input from.
  97082. * @param element Defines the element the controls should be listened from
  97083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97084. */
  97085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97086. /**
  97087. * Detach the current controls from the specified dom element.
  97088. * @param element Defines the element to stop listening the inputs from
  97089. */
  97090. detachControl(element: Nullable<HTMLElement>): void;
  97091. /**
  97092. * Update the current camera state depending on the inputs that have been used this frame.
  97093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97094. */
  97095. checkInputs(): void;
  97096. /**
  97097. * Gets the class name of the current intput.
  97098. * @returns the class name
  97099. */
  97100. getClassName(): string;
  97101. /**
  97102. * Get the friendly name associated with the input class.
  97103. * @returns the input friendly name
  97104. */
  97105. getSimpleName(): string;
  97106. }
  97107. }
  97108. declare module BABYLON {
  97109. /**
  97110. * Defines the potential axis of a Joystick
  97111. */
  97112. export enum JoystickAxis {
  97113. /** X axis */
  97114. X = 0,
  97115. /** Y axis */
  97116. Y = 1,
  97117. /** Z axis */
  97118. Z = 2
  97119. }
  97120. /**
  97121. * Class used to define virtual joystick (used in touch mode)
  97122. */
  97123. export class VirtualJoystick {
  97124. /**
  97125. * Gets or sets a boolean indicating that left and right values must be inverted
  97126. */
  97127. reverseLeftRight: boolean;
  97128. /**
  97129. * Gets or sets a boolean indicating that up and down values must be inverted
  97130. */
  97131. reverseUpDown: boolean;
  97132. /**
  97133. * Gets the offset value for the position (ie. the change of the position value)
  97134. */
  97135. deltaPosition: Vector3;
  97136. /**
  97137. * Gets a boolean indicating if the virtual joystick was pressed
  97138. */
  97139. pressed: boolean;
  97140. /**
  97141. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97142. */
  97143. static Canvas: Nullable<HTMLCanvasElement>;
  97144. private static _globalJoystickIndex;
  97145. private static vjCanvasContext;
  97146. private static vjCanvasWidth;
  97147. private static vjCanvasHeight;
  97148. private static halfWidth;
  97149. private _action;
  97150. private _axisTargetedByLeftAndRight;
  97151. private _axisTargetedByUpAndDown;
  97152. private _joystickSensibility;
  97153. private _inversedSensibility;
  97154. private _joystickPointerID;
  97155. private _joystickColor;
  97156. private _joystickPointerPos;
  97157. private _joystickPreviousPointerPos;
  97158. private _joystickPointerStartPos;
  97159. private _deltaJoystickVector;
  97160. private _leftJoystick;
  97161. private _touches;
  97162. private _onPointerDownHandlerRef;
  97163. private _onPointerMoveHandlerRef;
  97164. private _onPointerUpHandlerRef;
  97165. private _onResize;
  97166. /**
  97167. * Creates a new virtual joystick
  97168. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97169. */
  97170. constructor(leftJoystick?: boolean);
  97171. /**
  97172. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97173. * @param newJoystickSensibility defines the new sensibility
  97174. */
  97175. setJoystickSensibility(newJoystickSensibility: number): void;
  97176. private _onPointerDown;
  97177. private _onPointerMove;
  97178. private _onPointerUp;
  97179. /**
  97180. * Change the color of the virtual joystick
  97181. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97182. */
  97183. setJoystickColor(newColor: string): void;
  97184. /**
  97185. * Defines a callback to call when the joystick is touched
  97186. * @param action defines the callback
  97187. */
  97188. setActionOnTouch(action: () => any): void;
  97189. /**
  97190. * Defines which axis you'd like to control for left & right
  97191. * @param axis defines the axis to use
  97192. */
  97193. setAxisForLeftRight(axis: JoystickAxis): void;
  97194. /**
  97195. * Defines which axis you'd like to control for up & down
  97196. * @param axis defines the axis to use
  97197. */
  97198. setAxisForUpDown(axis: JoystickAxis): void;
  97199. private _drawVirtualJoystick;
  97200. /**
  97201. * Release internal HTML canvas
  97202. */
  97203. releaseCanvas(): void;
  97204. }
  97205. }
  97206. declare module BABYLON {
  97207. interface FreeCameraInputsManager {
  97208. /**
  97209. * Add virtual joystick input support to the input manager.
  97210. * @returns the current input manager
  97211. */
  97212. addVirtualJoystick(): FreeCameraInputsManager;
  97213. }
  97214. /**
  97215. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97217. */
  97218. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97219. /**
  97220. * Defines the camera the input is attached to.
  97221. */
  97222. camera: FreeCamera;
  97223. private _leftjoystick;
  97224. private _rightjoystick;
  97225. /**
  97226. * Gets the left stick of the virtual joystick.
  97227. * @returns The virtual Joystick
  97228. */
  97229. getLeftJoystick(): VirtualJoystick;
  97230. /**
  97231. * Gets the right stick of the virtual joystick.
  97232. * @returns The virtual Joystick
  97233. */
  97234. getRightJoystick(): VirtualJoystick;
  97235. /**
  97236. * Update the current camera state depending on the inputs that have been used this frame.
  97237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97238. */
  97239. checkInputs(): void;
  97240. /**
  97241. * Attach the input controls to a specific dom element to get the input from.
  97242. * @param element Defines the element the controls should be listened from
  97243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97244. */
  97245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97246. /**
  97247. * Detach the current controls from the specified dom element.
  97248. * @param element Defines the element to stop listening the inputs from
  97249. */
  97250. detachControl(element: Nullable<HTMLElement>): void;
  97251. /**
  97252. * Gets the class name of the current intput.
  97253. * @returns the class name
  97254. */
  97255. getClassName(): string;
  97256. /**
  97257. * Get the friendly name associated with the input class.
  97258. * @returns the input friendly name
  97259. */
  97260. getSimpleName(): string;
  97261. }
  97262. }
  97263. declare module BABYLON {
  97264. /**
  97265. * This represents a FPS type of camera controlled by touch.
  97266. * This is like a universal camera minus the Gamepad controls.
  97267. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97268. */
  97269. export class TouchCamera extends FreeCamera {
  97270. /**
  97271. * Defines the touch sensibility for rotation.
  97272. * The higher the faster.
  97273. */
  97274. touchAngularSensibility: number;
  97275. /**
  97276. * Defines the touch sensibility for move.
  97277. * The higher the faster.
  97278. */
  97279. touchMoveSensibility: number;
  97280. /**
  97281. * Instantiates a new touch camera.
  97282. * This represents a FPS type of camera controlled by touch.
  97283. * This is like a universal camera minus the Gamepad controls.
  97284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97285. * @param name Define the name of the camera in the scene
  97286. * @param position Define the start position of the camera in the scene
  97287. * @param scene Define the scene the camera belongs to
  97288. */
  97289. constructor(name: string, position: Vector3, scene: Scene);
  97290. /**
  97291. * Gets the current object class name.
  97292. * @return the class name
  97293. */
  97294. getClassName(): string;
  97295. /** @hidden */
  97296. _setupInputs(): void;
  97297. }
  97298. }
  97299. declare module BABYLON {
  97300. /**
  97301. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97302. * being tilted forward or back and left or right.
  97303. */
  97304. export class DeviceOrientationCamera extends FreeCamera {
  97305. private _initialQuaternion;
  97306. private _quaternionCache;
  97307. private _tmpDragQuaternion;
  97308. /**
  97309. * Creates a new device orientation camera
  97310. * @param name The name of the camera
  97311. * @param position The start position camera
  97312. * @param scene The scene the camera belongs to
  97313. */
  97314. constructor(name: string, position: Vector3, scene: Scene);
  97315. /**
  97316. * @hidden
  97317. * Disabled pointer input on first orientation sensor update (Default: true)
  97318. */
  97319. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97320. private _dragFactor;
  97321. /**
  97322. * Enabled turning on the y axis when the orientation sensor is active
  97323. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97324. */
  97325. enableHorizontalDragging(dragFactor?: number): void;
  97326. /**
  97327. * Gets the current instance class name ("DeviceOrientationCamera").
  97328. * This helps avoiding instanceof at run time.
  97329. * @returns the class name
  97330. */
  97331. getClassName(): string;
  97332. /**
  97333. * @hidden
  97334. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97335. */
  97336. _checkInputs(): void;
  97337. /**
  97338. * Reset the camera to its default orientation on the specified axis only.
  97339. * @param axis The axis to reset
  97340. */
  97341. resetToCurrentRotation(axis?: Axis): void;
  97342. }
  97343. }
  97344. declare module BABYLON {
  97345. /**
  97346. * 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,
  97347. * which still works and will still be found in many Playgrounds.
  97348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97349. */
  97350. export class UniversalCamera extends TouchCamera {
  97351. /**
  97352. * Defines the gamepad rotation sensiblity.
  97353. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97354. */
  97355. gamepadAngularSensibility: number;
  97356. /**
  97357. * Defines the gamepad move sensiblity.
  97358. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97359. */
  97360. gamepadMoveSensibility: number;
  97361. /**
  97362. * 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,
  97363. * which still works and will still be found in many Playgrounds.
  97364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97365. * @param name Define the name of the camera in the scene
  97366. * @param position Define the start position of the camera in the scene
  97367. * @param scene Define the scene the camera belongs to
  97368. */
  97369. constructor(name: string, position: Vector3, scene: Scene);
  97370. /**
  97371. * Gets the current object class name.
  97372. * @return the class name
  97373. */
  97374. getClassName(): string;
  97375. }
  97376. }
  97377. declare module BABYLON {
  97378. /**
  97379. * This represents a FPS type of camera. This is only here for back compat purpose.
  97380. * Please use the UniversalCamera instead as both are identical.
  97381. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97382. */
  97383. export class GamepadCamera extends UniversalCamera {
  97384. /**
  97385. * Instantiates a new Gamepad Camera
  97386. * This represents a FPS type of camera. This is only here for back compat purpose.
  97387. * Please use the UniversalCamera instead as both are identical.
  97388. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97389. * @param name Define the name of the camera in the scene
  97390. * @param position Define the start position of the camera in the scene
  97391. * @param scene Define the scene the camera belongs to
  97392. */
  97393. constructor(name: string, position: Vector3, scene: Scene);
  97394. /**
  97395. * Gets the current object class name.
  97396. * @return the class name
  97397. */
  97398. getClassName(): string;
  97399. }
  97400. }
  97401. declare module BABYLON {
  97402. /** @hidden */
  97403. export var passPixelShader: {
  97404. name: string;
  97405. shader: string;
  97406. };
  97407. }
  97408. declare module BABYLON {
  97409. /** @hidden */
  97410. export var passCubePixelShader: {
  97411. name: string;
  97412. shader: string;
  97413. };
  97414. }
  97415. declare module BABYLON {
  97416. /**
  97417. * PassPostProcess which produces an output the same as it's input
  97418. */
  97419. export class PassPostProcess extends PostProcess {
  97420. /**
  97421. * Creates the PassPostProcess
  97422. * @param name The name of the effect.
  97423. * @param options The required width/height ratio to downsize to before computing the render pass.
  97424. * @param camera The camera to apply the render pass to.
  97425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97426. * @param engine The engine which the post process will be applied. (default: current engine)
  97427. * @param reusable If the post process can be reused on the same frame. (default: false)
  97428. * @param textureType The type of texture to be used when performing the post processing.
  97429. * @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)
  97430. */
  97431. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97432. }
  97433. /**
  97434. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97435. */
  97436. export class PassCubePostProcess extends PostProcess {
  97437. private _face;
  97438. /**
  97439. * Gets or sets the cube face to display.
  97440. * * 0 is +X
  97441. * * 1 is -X
  97442. * * 2 is +Y
  97443. * * 3 is -Y
  97444. * * 4 is +Z
  97445. * * 5 is -Z
  97446. */
  97447. face: number;
  97448. /**
  97449. * Creates the PassCubePostProcess
  97450. * @param name The name of the effect.
  97451. * @param options The required width/height ratio to downsize to before computing the render pass.
  97452. * @param camera The camera to apply the render pass to.
  97453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97454. * @param engine The engine which the post process will be applied. (default: current engine)
  97455. * @param reusable If the post process can be reused on the same frame. (default: false)
  97456. * @param textureType The type of texture to be used when performing the post processing.
  97457. * @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)
  97458. */
  97459. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97460. }
  97461. }
  97462. declare module BABYLON {
  97463. /** @hidden */
  97464. export var anaglyphPixelShader: {
  97465. name: string;
  97466. shader: string;
  97467. };
  97468. }
  97469. declare module BABYLON {
  97470. /**
  97471. * Postprocess used to generate anaglyphic rendering
  97472. */
  97473. export class AnaglyphPostProcess extends PostProcess {
  97474. private _passedProcess;
  97475. /**
  97476. * Creates a new AnaglyphPostProcess
  97477. * @param name defines postprocess name
  97478. * @param options defines creation options or target ratio scale
  97479. * @param rigCameras defines cameras using this postprocess
  97480. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97481. * @param engine defines hosting engine
  97482. * @param reusable defines if the postprocess will be reused multiple times per frame
  97483. */
  97484. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97485. }
  97486. }
  97487. declare module BABYLON {
  97488. /**
  97489. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97490. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97491. */
  97492. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97493. /**
  97494. * Creates a new AnaglyphArcRotateCamera
  97495. * @param name defines camera name
  97496. * @param alpha defines alpha angle (in radians)
  97497. * @param beta defines beta angle (in radians)
  97498. * @param radius defines radius
  97499. * @param target defines camera target
  97500. * @param interaxialDistance defines distance between each color axis
  97501. * @param scene defines the hosting scene
  97502. */
  97503. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97504. /**
  97505. * Gets camera class name
  97506. * @returns AnaglyphArcRotateCamera
  97507. */
  97508. getClassName(): string;
  97509. }
  97510. }
  97511. declare module BABYLON {
  97512. /**
  97513. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97514. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97515. */
  97516. export class AnaglyphFreeCamera extends FreeCamera {
  97517. /**
  97518. * Creates a new AnaglyphFreeCamera
  97519. * @param name defines camera name
  97520. * @param position defines initial position
  97521. * @param interaxialDistance defines distance between each color axis
  97522. * @param scene defines the hosting scene
  97523. */
  97524. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97525. /**
  97526. * Gets camera class name
  97527. * @returns AnaglyphFreeCamera
  97528. */
  97529. getClassName(): string;
  97530. }
  97531. }
  97532. declare module BABYLON {
  97533. /**
  97534. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97535. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97536. */
  97537. export class AnaglyphGamepadCamera extends GamepadCamera {
  97538. /**
  97539. * Creates a new AnaglyphGamepadCamera
  97540. * @param name defines camera name
  97541. * @param position defines initial position
  97542. * @param interaxialDistance defines distance between each color axis
  97543. * @param scene defines the hosting scene
  97544. */
  97545. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97546. /**
  97547. * Gets camera class name
  97548. * @returns AnaglyphGamepadCamera
  97549. */
  97550. getClassName(): string;
  97551. }
  97552. }
  97553. declare module BABYLON {
  97554. /**
  97555. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97556. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97557. */
  97558. export class AnaglyphUniversalCamera extends UniversalCamera {
  97559. /**
  97560. * Creates a new AnaglyphUniversalCamera
  97561. * @param name defines camera name
  97562. * @param position defines initial position
  97563. * @param interaxialDistance defines distance between each color axis
  97564. * @param scene defines the hosting scene
  97565. */
  97566. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97567. /**
  97568. * Gets camera class name
  97569. * @returns AnaglyphUniversalCamera
  97570. */
  97571. getClassName(): string;
  97572. }
  97573. }
  97574. declare module BABYLON {
  97575. /** @hidden */
  97576. export var stereoscopicInterlacePixelShader: {
  97577. name: string;
  97578. shader: string;
  97579. };
  97580. }
  97581. declare module BABYLON {
  97582. /**
  97583. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97584. */
  97585. export class StereoscopicInterlacePostProcess extends PostProcess {
  97586. private _stepSize;
  97587. private _passedProcess;
  97588. /**
  97589. * Initializes a StereoscopicInterlacePostProcess
  97590. * @param name The name of the effect.
  97591. * @param rigCameras The rig cameras to be appled to the post process
  97592. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97594. * @param engine The engine which the post process will be applied. (default: current engine)
  97595. * @param reusable If the post process can be reused on the same frame. (default: false)
  97596. */
  97597. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97598. }
  97599. }
  97600. declare module BABYLON {
  97601. /**
  97602. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97603. * @see http://doc.babylonjs.com/features/cameras
  97604. */
  97605. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97606. /**
  97607. * Creates a new StereoscopicArcRotateCamera
  97608. * @param name defines camera name
  97609. * @param alpha defines alpha angle (in radians)
  97610. * @param beta defines beta angle (in radians)
  97611. * @param radius defines radius
  97612. * @param target defines camera target
  97613. * @param interaxialDistance defines distance between each color axis
  97614. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97615. * @param scene defines the hosting scene
  97616. */
  97617. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97618. /**
  97619. * Gets camera class name
  97620. * @returns StereoscopicArcRotateCamera
  97621. */
  97622. getClassName(): string;
  97623. }
  97624. }
  97625. declare module BABYLON {
  97626. /**
  97627. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97628. * @see http://doc.babylonjs.com/features/cameras
  97629. */
  97630. export class StereoscopicFreeCamera extends FreeCamera {
  97631. /**
  97632. * Creates a new StereoscopicFreeCamera
  97633. * @param name defines camera name
  97634. * @param position defines initial position
  97635. * @param interaxialDistance defines distance between each color axis
  97636. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97637. * @param scene defines the hosting scene
  97638. */
  97639. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97640. /**
  97641. * Gets camera class name
  97642. * @returns StereoscopicFreeCamera
  97643. */
  97644. getClassName(): string;
  97645. }
  97646. }
  97647. declare module BABYLON {
  97648. /**
  97649. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97650. * @see http://doc.babylonjs.com/features/cameras
  97651. */
  97652. export class StereoscopicGamepadCamera extends GamepadCamera {
  97653. /**
  97654. * Creates a new StereoscopicGamepadCamera
  97655. * @param name defines camera name
  97656. * @param position defines initial position
  97657. * @param interaxialDistance defines distance between each color axis
  97658. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97659. * @param scene defines the hosting scene
  97660. */
  97661. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97662. /**
  97663. * Gets camera class name
  97664. * @returns StereoscopicGamepadCamera
  97665. */
  97666. getClassName(): string;
  97667. }
  97668. }
  97669. declare module BABYLON {
  97670. /**
  97671. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97672. * @see http://doc.babylonjs.com/features/cameras
  97673. */
  97674. export class StereoscopicUniversalCamera extends UniversalCamera {
  97675. /**
  97676. * Creates a new StereoscopicUniversalCamera
  97677. * @param name defines camera name
  97678. * @param position defines initial position
  97679. * @param interaxialDistance defines distance between each color axis
  97680. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97681. * @param scene defines the hosting scene
  97682. */
  97683. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97684. /**
  97685. * Gets camera class name
  97686. * @returns StereoscopicUniversalCamera
  97687. */
  97688. getClassName(): string;
  97689. }
  97690. }
  97691. declare module BABYLON {
  97692. /**
  97693. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97694. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97695. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97696. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97697. */
  97698. export class VirtualJoysticksCamera extends FreeCamera {
  97699. /**
  97700. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97701. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97702. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97703. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97704. * @param name Define the name of the camera in the scene
  97705. * @param position Define the start position of the camera in the scene
  97706. * @param scene Define the scene the camera belongs to
  97707. */
  97708. constructor(name: string, position: Vector3, scene: Scene);
  97709. /**
  97710. * Gets the current object class name.
  97711. * @return the class name
  97712. */
  97713. getClassName(): string;
  97714. }
  97715. }
  97716. declare module BABYLON {
  97717. /**
  97718. * This represents all the required metrics to create a VR camera.
  97719. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97720. */
  97721. export class VRCameraMetrics {
  97722. /**
  97723. * Define the horizontal resolution off the screen.
  97724. */
  97725. hResolution: number;
  97726. /**
  97727. * Define the vertical resolution off the screen.
  97728. */
  97729. vResolution: number;
  97730. /**
  97731. * Define the horizontal screen size.
  97732. */
  97733. hScreenSize: number;
  97734. /**
  97735. * Define the vertical screen size.
  97736. */
  97737. vScreenSize: number;
  97738. /**
  97739. * Define the vertical screen center position.
  97740. */
  97741. vScreenCenter: number;
  97742. /**
  97743. * Define the distance of the eyes to the screen.
  97744. */
  97745. eyeToScreenDistance: number;
  97746. /**
  97747. * Define the distance between both lenses
  97748. */
  97749. lensSeparationDistance: number;
  97750. /**
  97751. * Define the distance between both viewer's eyes.
  97752. */
  97753. interpupillaryDistance: number;
  97754. /**
  97755. * Define the distortion factor of the VR postprocess.
  97756. * Please, touch with care.
  97757. */
  97758. distortionK: number[];
  97759. /**
  97760. * Define the chromatic aberration correction factors for the VR post process.
  97761. */
  97762. chromaAbCorrection: number[];
  97763. /**
  97764. * Define the scale factor of the post process.
  97765. * The smaller the better but the slower.
  97766. */
  97767. postProcessScaleFactor: number;
  97768. /**
  97769. * Define an offset for the lens center.
  97770. */
  97771. lensCenterOffset: number;
  97772. /**
  97773. * Define if the current vr camera should compensate the distortion of the lense or not.
  97774. */
  97775. compensateDistortion: boolean;
  97776. /**
  97777. * Defines if multiview should be enabled when rendering (Default: false)
  97778. */
  97779. multiviewEnabled: boolean;
  97780. /**
  97781. * Gets the rendering aspect ratio based on the provided resolutions.
  97782. */
  97783. readonly aspectRatio: number;
  97784. /**
  97785. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97786. */
  97787. readonly aspectRatioFov: number;
  97788. /**
  97789. * @hidden
  97790. */
  97791. readonly leftHMatrix: Matrix;
  97792. /**
  97793. * @hidden
  97794. */
  97795. readonly rightHMatrix: Matrix;
  97796. /**
  97797. * @hidden
  97798. */
  97799. readonly leftPreViewMatrix: Matrix;
  97800. /**
  97801. * @hidden
  97802. */
  97803. readonly rightPreViewMatrix: Matrix;
  97804. /**
  97805. * Get the default VRMetrics based on the most generic setup.
  97806. * @returns the default vr metrics
  97807. */
  97808. static GetDefault(): VRCameraMetrics;
  97809. }
  97810. }
  97811. declare module BABYLON {
  97812. /** @hidden */
  97813. export var vrDistortionCorrectionPixelShader: {
  97814. name: string;
  97815. shader: string;
  97816. };
  97817. }
  97818. declare module BABYLON {
  97819. /**
  97820. * VRDistortionCorrectionPostProcess used for mobile VR
  97821. */
  97822. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97823. private _isRightEye;
  97824. private _distortionFactors;
  97825. private _postProcessScaleFactor;
  97826. private _lensCenterOffset;
  97827. private _scaleIn;
  97828. private _scaleFactor;
  97829. private _lensCenter;
  97830. /**
  97831. * Initializes the VRDistortionCorrectionPostProcess
  97832. * @param name The name of the effect.
  97833. * @param camera The camera to apply the render pass to.
  97834. * @param isRightEye If this is for the right eye distortion
  97835. * @param vrMetrics All the required metrics for the VR camera
  97836. */
  97837. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97838. }
  97839. }
  97840. declare module BABYLON {
  97841. /**
  97842. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97843. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97844. */
  97845. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97846. /**
  97847. * Creates a new VRDeviceOrientationArcRotateCamera
  97848. * @param name defines camera name
  97849. * @param alpha defines the camera rotation along the logitudinal axis
  97850. * @param beta defines the camera rotation along the latitudinal axis
  97851. * @param radius defines the camera distance from its target
  97852. * @param target defines the camera target
  97853. * @param scene defines the scene the camera belongs to
  97854. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97855. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97856. */
  97857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97858. /**
  97859. * Gets camera class name
  97860. * @returns VRDeviceOrientationArcRotateCamera
  97861. */
  97862. getClassName(): string;
  97863. }
  97864. }
  97865. declare module BABYLON {
  97866. /**
  97867. * Camera used to simulate VR rendering (based on FreeCamera)
  97868. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97869. */
  97870. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97871. /**
  97872. * Creates a new VRDeviceOrientationFreeCamera
  97873. * @param name defines camera name
  97874. * @param position defines the start position of the camera
  97875. * @param scene defines the scene the camera belongs to
  97876. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97877. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97878. */
  97879. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97880. /**
  97881. * Gets camera class name
  97882. * @returns VRDeviceOrientationFreeCamera
  97883. */
  97884. getClassName(): string;
  97885. }
  97886. }
  97887. declare module BABYLON {
  97888. /**
  97889. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97890. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97891. */
  97892. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97893. /**
  97894. * Creates a new VRDeviceOrientationGamepadCamera
  97895. * @param name defines camera name
  97896. * @param position defines the start position of the camera
  97897. * @param scene defines the scene the camera belongs to
  97898. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97899. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97900. */
  97901. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97902. /**
  97903. * Gets camera class name
  97904. * @returns VRDeviceOrientationGamepadCamera
  97905. */
  97906. getClassName(): string;
  97907. }
  97908. }
  97909. declare module BABYLON {
  97910. /**
  97911. * Defines supported buttons for XBox360 compatible gamepads
  97912. */
  97913. export enum Xbox360Button {
  97914. /** A */
  97915. A = 0,
  97916. /** B */
  97917. B = 1,
  97918. /** X */
  97919. X = 2,
  97920. /** Y */
  97921. Y = 3,
  97922. /** Start */
  97923. Start = 4,
  97924. /** Back */
  97925. Back = 5,
  97926. /** Left button */
  97927. LB = 6,
  97928. /** Right button */
  97929. RB = 7,
  97930. /** Left stick */
  97931. LeftStick = 8,
  97932. /** Right stick */
  97933. RightStick = 9
  97934. }
  97935. /** Defines values for XBox360 DPad */
  97936. export enum Xbox360Dpad {
  97937. /** Up */
  97938. Up = 0,
  97939. /** Down */
  97940. Down = 1,
  97941. /** Left */
  97942. Left = 2,
  97943. /** Right */
  97944. Right = 3
  97945. }
  97946. /**
  97947. * Defines a XBox360 gamepad
  97948. */
  97949. export class Xbox360Pad extends Gamepad {
  97950. private _leftTrigger;
  97951. private _rightTrigger;
  97952. private _onlefttriggerchanged;
  97953. private _onrighttriggerchanged;
  97954. private _onbuttondown;
  97955. private _onbuttonup;
  97956. private _ondpaddown;
  97957. private _ondpadup;
  97958. /** Observable raised when a button is pressed */
  97959. onButtonDownObservable: Observable<Xbox360Button>;
  97960. /** Observable raised when a button is released */
  97961. onButtonUpObservable: Observable<Xbox360Button>;
  97962. /** Observable raised when a pad is pressed */
  97963. onPadDownObservable: Observable<Xbox360Dpad>;
  97964. /** Observable raised when a pad is released */
  97965. onPadUpObservable: Observable<Xbox360Dpad>;
  97966. private _buttonA;
  97967. private _buttonB;
  97968. private _buttonX;
  97969. private _buttonY;
  97970. private _buttonBack;
  97971. private _buttonStart;
  97972. private _buttonLB;
  97973. private _buttonRB;
  97974. private _buttonLeftStick;
  97975. private _buttonRightStick;
  97976. private _dPadUp;
  97977. private _dPadDown;
  97978. private _dPadLeft;
  97979. private _dPadRight;
  97980. private _isXboxOnePad;
  97981. /**
  97982. * Creates a new XBox360 gamepad object
  97983. * @param id defines the id of this gamepad
  97984. * @param index defines its index
  97985. * @param gamepad defines the internal HTML gamepad object
  97986. * @param xboxOne defines if it is a XBox One gamepad
  97987. */
  97988. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97989. /**
  97990. * Defines the callback to call when left trigger is pressed
  97991. * @param callback defines the callback to use
  97992. */
  97993. onlefttriggerchanged(callback: (value: number) => void): void;
  97994. /**
  97995. * Defines the callback to call when right trigger is pressed
  97996. * @param callback defines the callback to use
  97997. */
  97998. onrighttriggerchanged(callback: (value: number) => void): void;
  97999. /**
  98000. * Gets the left trigger value
  98001. */
  98002. /**
  98003. * Sets the left trigger value
  98004. */
  98005. leftTrigger: number;
  98006. /**
  98007. * Gets the right trigger value
  98008. */
  98009. /**
  98010. * Sets the right trigger value
  98011. */
  98012. rightTrigger: number;
  98013. /**
  98014. * Defines the callback to call when a button is pressed
  98015. * @param callback defines the callback to use
  98016. */
  98017. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98018. /**
  98019. * Defines the callback to call when a button is released
  98020. * @param callback defines the callback to use
  98021. */
  98022. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98023. /**
  98024. * Defines the callback to call when a pad is pressed
  98025. * @param callback defines the callback to use
  98026. */
  98027. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98028. /**
  98029. * Defines the callback to call when a pad is released
  98030. * @param callback defines the callback to use
  98031. */
  98032. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98033. private _setButtonValue;
  98034. private _setDPadValue;
  98035. /**
  98036. * Gets the value of the `A` button
  98037. */
  98038. /**
  98039. * Sets the value of the `A` button
  98040. */
  98041. buttonA: number;
  98042. /**
  98043. * Gets the value of the `B` button
  98044. */
  98045. /**
  98046. * Sets the value of the `B` button
  98047. */
  98048. buttonB: number;
  98049. /**
  98050. * Gets the value of the `X` button
  98051. */
  98052. /**
  98053. * Sets the value of the `X` button
  98054. */
  98055. buttonX: number;
  98056. /**
  98057. * Gets the value of the `Y` button
  98058. */
  98059. /**
  98060. * Sets the value of the `Y` button
  98061. */
  98062. buttonY: number;
  98063. /**
  98064. * Gets the value of the `Start` button
  98065. */
  98066. /**
  98067. * Sets the value of the `Start` button
  98068. */
  98069. buttonStart: number;
  98070. /**
  98071. * Gets the value of the `Back` button
  98072. */
  98073. /**
  98074. * Sets the value of the `Back` button
  98075. */
  98076. buttonBack: number;
  98077. /**
  98078. * Gets the value of the `Left` button
  98079. */
  98080. /**
  98081. * Sets the value of the `Left` button
  98082. */
  98083. buttonLB: number;
  98084. /**
  98085. * Gets the value of the `Right` button
  98086. */
  98087. /**
  98088. * Sets the value of the `Right` button
  98089. */
  98090. buttonRB: number;
  98091. /**
  98092. * Gets the value of the Left joystick
  98093. */
  98094. /**
  98095. * Sets the value of the Left joystick
  98096. */
  98097. buttonLeftStick: number;
  98098. /**
  98099. * Gets the value of the Right joystick
  98100. */
  98101. /**
  98102. * Sets the value of the Right joystick
  98103. */
  98104. buttonRightStick: number;
  98105. /**
  98106. * Gets the value of D-pad up
  98107. */
  98108. /**
  98109. * Sets the value of D-pad up
  98110. */
  98111. dPadUp: number;
  98112. /**
  98113. * Gets the value of D-pad down
  98114. */
  98115. /**
  98116. * Sets the value of D-pad down
  98117. */
  98118. dPadDown: number;
  98119. /**
  98120. * Gets the value of D-pad left
  98121. */
  98122. /**
  98123. * Sets the value of D-pad left
  98124. */
  98125. dPadLeft: number;
  98126. /**
  98127. * Gets the value of D-pad right
  98128. */
  98129. /**
  98130. * Sets the value of D-pad right
  98131. */
  98132. dPadRight: number;
  98133. /**
  98134. * Force the gamepad to synchronize with device values
  98135. */
  98136. update(): void;
  98137. /**
  98138. * Disposes the gamepad
  98139. */
  98140. dispose(): void;
  98141. }
  98142. }
  98143. declare module BABYLON {
  98144. /**
  98145. * Base class of materials working in push mode in babylon JS
  98146. * @hidden
  98147. */
  98148. export class PushMaterial extends Material {
  98149. protected _activeEffect: Effect;
  98150. protected _normalMatrix: Matrix;
  98151. /**
  98152. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98153. * This means that the material can keep using a previous shader while a new one is being compiled.
  98154. * This is mostly used when shader parallel compilation is supported (true by default)
  98155. */
  98156. allowShaderHotSwapping: boolean;
  98157. constructor(name: string, scene: Scene);
  98158. getEffect(): Effect;
  98159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98160. /**
  98161. * Binds the given world matrix to the active effect
  98162. *
  98163. * @param world the matrix to bind
  98164. */
  98165. bindOnlyWorldMatrix(world: Matrix): void;
  98166. /**
  98167. * Binds the given normal matrix to the active effect
  98168. *
  98169. * @param normalMatrix the matrix to bind
  98170. */
  98171. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98172. bind(world: Matrix, mesh?: Mesh): void;
  98173. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98174. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98175. }
  98176. }
  98177. declare module BABYLON {
  98178. /**
  98179. * This groups all the flags used to control the materials channel.
  98180. */
  98181. export class MaterialFlags {
  98182. private static _DiffuseTextureEnabled;
  98183. /**
  98184. * Are diffuse textures enabled in the application.
  98185. */
  98186. static DiffuseTextureEnabled: boolean;
  98187. private static _AmbientTextureEnabled;
  98188. /**
  98189. * Are ambient textures enabled in the application.
  98190. */
  98191. static AmbientTextureEnabled: boolean;
  98192. private static _OpacityTextureEnabled;
  98193. /**
  98194. * Are opacity textures enabled in the application.
  98195. */
  98196. static OpacityTextureEnabled: boolean;
  98197. private static _ReflectionTextureEnabled;
  98198. /**
  98199. * Are reflection textures enabled in the application.
  98200. */
  98201. static ReflectionTextureEnabled: boolean;
  98202. private static _EmissiveTextureEnabled;
  98203. /**
  98204. * Are emissive textures enabled in the application.
  98205. */
  98206. static EmissiveTextureEnabled: boolean;
  98207. private static _SpecularTextureEnabled;
  98208. /**
  98209. * Are specular textures enabled in the application.
  98210. */
  98211. static SpecularTextureEnabled: boolean;
  98212. private static _BumpTextureEnabled;
  98213. /**
  98214. * Are bump textures enabled in the application.
  98215. */
  98216. static BumpTextureEnabled: boolean;
  98217. private static _LightmapTextureEnabled;
  98218. /**
  98219. * Are lightmap textures enabled in the application.
  98220. */
  98221. static LightmapTextureEnabled: boolean;
  98222. private static _RefractionTextureEnabled;
  98223. /**
  98224. * Are refraction textures enabled in the application.
  98225. */
  98226. static RefractionTextureEnabled: boolean;
  98227. private static _ColorGradingTextureEnabled;
  98228. /**
  98229. * Are color grading textures enabled in the application.
  98230. */
  98231. static ColorGradingTextureEnabled: boolean;
  98232. private static _FresnelEnabled;
  98233. /**
  98234. * Are fresnels enabled in the application.
  98235. */
  98236. static FresnelEnabled: boolean;
  98237. private static _ClearCoatTextureEnabled;
  98238. /**
  98239. * Are clear coat textures enabled in the application.
  98240. */
  98241. static ClearCoatTextureEnabled: boolean;
  98242. private static _ClearCoatBumpTextureEnabled;
  98243. /**
  98244. * Are clear coat bump textures enabled in the application.
  98245. */
  98246. static ClearCoatBumpTextureEnabled: boolean;
  98247. private static _ClearCoatTintTextureEnabled;
  98248. /**
  98249. * Are clear coat tint textures enabled in the application.
  98250. */
  98251. static ClearCoatTintTextureEnabled: boolean;
  98252. private static _SheenTextureEnabled;
  98253. /**
  98254. * Are sheen textures enabled in the application.
  98255. */
  98256. static SheenTextureEnabled: boolean;
  98257. private static _AnisotropicTextureEnabled;
  98258. /**
  98259. * Are anisotropic textures enabled in the application.
  98260. */
  98261. static AnisotropicTextureEnabled: boolean;
  98262. private static _ThicknessTextureEnabled;
  98263. /**
  98264. * Are thickness textures enabled in the application.
  98265. */
  98266. static ThicknessTextureEnabled: boolean;
  98267. }
  98268. }
  98269. declare module BABYLON {
  98270. /** @hidden */
  98271. export var defaultFragmentDeclaration: {
  98272. name: string;
  98273. shader: string;
  98274. };
  98275. }
  98276. declare module BABYLON {
  98277. /** @hidden */
  98278. export var defaultUboDeclaration: {
  98279. name: string;
  98280. shader: string;
  98281. };
  98282. }
  98283. declare module BABYLON {
  98284. /** @hidden */
  98285. export var lightFragmentDeclaration: {
  98286. name: string;
  98287. shader: string;
  98288. };
  98289. }
  98290. declare module BABYLON {
  98291. /** @hidden */
  98292. export var lightUboDeclaration: {
  98293. name: string;
  98294. shader: string;
  98295. };
  98296. }
  98297. declare module BABYLON {
  98298. /** @hidden */
  98299. export var lightsFragmentFunctions: {
  98300. name: string;
  98301. shader: string;
  98302. };
  98303. }
  98304. declare module BABYLON {
  98305. /** @hidden */
  98306. export var shadowsFragmentFunctions: {
  98307. name: string;
  98308. shader: string;
  98309. };
  98310. }
  98311. declare module BABYLON {
  98312. /** @hidden */
  98313. export var fresnelFunction: {
  98314. name: string;
  98315. shader: string;
  98316. };
  98317. }
  98318. declare module BABYLON {
  98319. /** @hidden */
  98320. export var reflectionFunction: {
  98321. name: string;
  98322. shader: string;
  98323. };
  98324. }
  98325. declare module BABYLON {
  98326. /** @hidden */
  98327. export var bumpFragmentFunctions: {
  98328. name: string;
  98329. shader: string;
  98330. };
  98331. }
  98332. declare module BABYLON {
  98333. /** @hidden */
  98334. export var logDepthDeclaration: {
  98335. name: string;
  98336. shader: string;
  98337. };
  98338. }
  98339. declare module BABYLON {
  98340. /** @hidden */
  98341. export var bumpFragment: {
  98342. name: string;
  98343. shader: string;
  98344. };
  98345. }
  98346. declare module BABYLON {
  98347. /** @hidden */
  98348. export var depthPrePass: {
  98349. name: string;
  98350. shader: string;
  98351. };
  98352. }
  98353. declare module BABYLON {
  98354. /** @hidden */
  98355. export var lightFragment: {
  98356. name: string;
  98357. shader: string;
  98358. };
  98359. }
  98360. declare module BABYLON {
  98361. /** @hidden */
  98362. export var logDepthFragment: {
  98363. name: string;
  98364. shader: string;
  98365. };
  98366. }
  98367. declare module BABYLON {
  98368. /** @hidden */
  98369. export var defaultPixelShader: {
  98370. name: string;
  98371. shader: string;
  98372. };
  98373. }
  98374. declare module BABYLON {
  98375. /** @hidden */
  98376. export var defaultVertexDeclaration: {
  98377. name: string;
  98378. shader: string;
  98379. };
  98380. }
  98381. declare module BABYLON {
  98382. /** @hidden */
  98383. export var bumpVertexDeclaration: {
  98384. name: string;
  98385. shader: string;
  98386. };
  98387. }
  98388. declare module BABYLON {
  98389. /** @hidden */
  98390. export var bumpVertex: {
  98391. name: string;
  98392. shader: string;
  98393. };
  98394. }
  98395. declare module BABYLON {
  98396. /** @hidden */
  98397. export var fogVertex: {
  98398. name: string;
  98399. shader: string;
  98400. };
  98401. }
  98402. declare module BABYLON {
  98403. /** @hidden */
  98404. export var shadowsVertex: {
  98405. name: string;
  98406. shader: string;
  98407. };
  98408. }
  98409. declare module BABYLON {
  98410. /** @hidden */
  98411. export var pointCloudVertex: {
  98412. name: string;
  98413. shader: string;
  98414. };
  98415. }
  98416. declare module BABYLON {
  98417. /** @hidden */
  98418. export var logDepthVertex: {
  98419. name: string;
  98420. shader: string;
  98421. };
  98422. }
  98423. declare module BABYLON {
  98424. /** @hidden */
  98425. export var defaultVertexShader: {
  98426. name: string;
  98427. shader: string;
  98428. };
  98429. }
  98430. declare module BABYLON {
  98431. /** @hidden */
  98432. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98433. MAINUV1: boolean;
  98434. MAINUV2: boolean;
  98435. DIFFUSE: boolean;
  98436. DIFFUSEDIRECTUV: number;
  98437. AMBIENT: boolean;
  98438. AMBIENTDIRECTUV: number;
  98439. OPACITY: boolean;
  98440. OPACITYDIRECTUV: number;
  98441. OPACITYRGB: boolean;
  98442. REFLECTION: boolean;
  98443. EMISSIVE: boolean;
  98444. EMISSIVEDIRECTUV: number;
  98445. SPECULAR: boolean;
  98446. SPECULARDIRECTUV: number;
  98447. BUMP: boolean;
  98448. BUMPDIRECTUV: number;
  98449. PARALLAX: boolean;
  98450. PARALLAXOCCLUSION: boolean;
  98451. SPECULAROVERALPHA: boolean;
  98452. CLIPPLANE: boolean;
  98453. CLIPPLANE2: boolean;
  98454. CLIPPLANE3: boolean;
  98455. CLIPPLANE4: boolean;
  98456. ALPHATEST: boolean;
  98457. DEPTHPREPASS: boolean;
  98458. ALPHAFROMDIFFUSE: boolean;
  98459. POINTSIZE: boolean;
  98460. FOG: boolean;
  98461. SPECULARTERM: boolean;
  98462. DIFFUSEFRESNEL: boolean;
  98463. OPACITYFRESNEL: boolean;
  98464. REFLECTIONFRESNEL: boolean;
  98465. REFRACTIONFRESNEL: boolean;
  98466. EMISSIVEFRESNEL: boolean;
  98467. FRESNEL: boolean;
  98468. NORMAL: boolean;
  98469. UV1: boolean;
  98470. UV2: boolean;
  98471. VERTEXCOLOR: boolean;
  98472. VERTEXALPHA: boolean;
  98473. NUM_BONE_INFLUENCERS: number;
  98474. BonesPerMesh: number;
  98475. BONETEXTURE: boolean;
  98476. INSTANCES: boolean;
  98477. GLOSSINESS: boolean;
  98478. ROUGHNESS: boolean;
  98479. EMISSIVEASILLUMINATION: boolean;
  98480. LINKEMISSIVEWITHDIFFUSE: boolean;
  98481. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98482. LIGHTMAP: boolean;
  98483. LIGHTMAPDIRECTUV: number;
  98484. OBJECTSPACE_NORMALMAP: boolean;
  98485. USELIGHTMAPASSHADOWMAP: boolean;
  98486. REFLECTIONMAP_3D: boolean;
  98487. REFLECTIONMAP_SPHERICAL: boolean;
  98488. REFLECTIONMAP_PLANAR: boolean;
  98489. REFLECTIONMAP_CUBIC: boolean;
  98490. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98491. REFLECTIONMAP_PROJECTION: boolean;
  98492. REFLECTIONMAP_SKYBOX: boolean;
  98493. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98494. REFLECTIONMAP_EXPLICIT: boolean;
  98495. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98496. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98497. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98498. INVERTCUBICMAP: boolean;
  98499. LOGARITHMICDEPTH: boolean;
  98500. REFRACTION: boolean;
  98501. REFRACTIONMAP_3D: boolean;
  98502. REFLECTIONOVERALPHA: boolean;
  98503. TWOSIDEDLIGHTING: boolean;
  98504. SHADOWFLOAT: boolean;
  98505. MORPHTARGETS: boolean;
  98506. MORPHTARGETS_NORMAL: boolean;
  98507. MORPHTARGETS_TANGENT: boolean;
  98508. NUM_MORPH_INFLUENCERS: number;
  98509. NONUNIFORMSCALING: boolean;
  98510. PREMULTIPLYALPHA: boolean;
  98511. IMAGEPROCESSING: boolean;
  98512. VIGNETTE: boolean;
  98513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98514. VIGNETTEBLENDMODEOPAQUE: boolean;
  98515. TONEMAPPING: boolean;
  98516. TONEMAPPING_ACES: boolean;
  98517. CONTRAST: boolean;
  98518. COLORCURVES: boolean;
  98519. COLORGRADING: boolean;
  98520. COLORGRADING3D: boolean;
  98521. SAMPLER3DGREENDEPTH: boolean;
  98522. SAMPLER3DBGRMAP: boolean;
  98523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98524. MULTIVIEW: boolean;
  98525. /**
  98526. * If the reflection texture on this material is in linear color space
  98527. * @hidden
  98528. */
  98529. IS_REFLECTION_LINEAR: boolean;
  98530. /**
  98531. * If the refraction texture on this material is in linear color space
  98532. * @hidden
  98533. */
  98534. IS_REFRACTION_LINEAR: boolean;
  98535. EXPOSURE: boolean;
  98536. constructor();
  98537. setReflectionMode(modeToEnable: string): void;
  98538. }
  98539. /**
  98540. * This is the default material used in Babylon. It is the best trade off between quality
  98541. * and performances.
  98542. * @see http://doc.babylonjs.com/babylon101/materials
  98543. */
  98544. export class StandardMaterial extends PushMaterial {
  98545. private _diffuseTexture;
  98546. /**
  98547. * The basic texture of the material as viewed under a light.
  98548. */
  98549. diffuseTexture: Nullable<BaseTexture>;
  98550. private _ambientTexture;
  98551. /**
  98552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98553. */
  98554. ambientTexture: Nullable<BaseTexture>;
  98555. private _opacityTexture;
  98556. /**
  98557. * Define the transparency of the material from a texture.
  98558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98560. */
  98561. opacityTexture: Nullable<BaseTexture>;
  98562. private _reflectionTexture;
  98563. /**
  98564. * Define the texture used to display the reflection.
  98565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98566. */
  98567. reflectionTexture: Nullable<BaseTexture>;
  98568. private _emissiveTexture;
  98569. /**
  98570. * Define texture of the material as if self lit.
  98571. * This will be mixed in the final result even in the absence of light.
  98572. */
  98573. emissiveTexture: Nullable<BaseTexture>;
  98574. private _specularTexture;
  98575. /**
  98576. * Define how the color and intensity of the highlight given by the light in the material.
  98577. */
  98578. specularTexture: Nullable<BaseTexture>;
  98579. private _bumpTexture;
  98580. /**
  98581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98582. * 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.
  98583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98584. */
  98585. bumpTexture: Nullable<BaseTexture>;
  98586. private _lightmapTexture;
  98587. /**
  98588. * Complex lighting can be computationally expensive to compute at runtime.
  98589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98591. */
  98592. lightmapTexture: Nullable<BaseTexture>;
  98593. private _refractionTexture;
  98594. /**
  98595. * Define the texture used to display the refraction.
  98596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98597. */
  98598. refractionTexture: Nullable<BaseTexture>;
  98599. /**
  98600. * The color of the material lit by the environmental background lighting.
  98601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98602. */
  98603. ambientColor: Color3;
  98604. /**
  98605. * The basic color of the material as viewed under a light.
  98606. */
  98607. diffuseColor: Color3;
  98608. /**
  98609. * Define how the color and intensity of the highlight given by the light in the material.
  98610. */
  98611. specularColor: Color3;
  98612. /**
  98613. * Define the color of the material as if self lit.
  98614. * This will be mixed in the final result even in the absence of light.
  98615. */
  98616. emissiveColor: Color3;
  98617. /**
  98618. * Defines how sharp are the highlights in the material.
  98619. * The bigger the value the sharper giving a more glossy feeling to the result.
  98620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98621. */
  98622. specularPower: number;
  98623. private _useAlphaFromDiffuseTexture;
  98624. /**
  98625. * Does the transparency come from the diffuse texture alpha channel.
  98626. */
  98627. useAlphaFromDiffuseTexture: boolean;
  98628. private _useEmissiveAsIllumination;
  98629. /**
  98630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98631. */
  98632. useEmissiveAsIllumination: boolean;
  98633. private _linkEmissiveWithDiffuse;
  98634. /**
  98635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98636. * the emissive level when the final color is close to one.
  98637. */
  98638. linkEmissiveWithDiffuse: boolean;
  98639. private _useSpecularOverAlpha;
  98640. /**
  98641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98643. */
  98644. useSpecularOverAlpha: boolean;
  98645. private _useReflectionOverAlpha;
  98646. /**
  98647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98649. */
  98650. useReflectionOverAlpha: boolean;
  98651. private _disableLighting;
  98652. /**
  98653. * Does lights from the scene impacts this material.
  98654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98655. */
  98656. disableLighting: boolean;
  98657. private _useObjectSpaceNormalMap;
  98658. /**
  98659. * Allows using an object space normal map (instead of tangent space).
  98660. */
  98661. useObjectSpaceNormalMap: boolean;
  98662. private _useParallax;
  98663. /**
  98664. * Is parallax enabled or not.
  98665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98666. */
  98667. useParallax: boolean;
  98668. private _useParallaxOcclusion;
  98669. /**
  98670. * Is parallax occlusion enabled or not.
  98671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98673. */
  98674. useParallaxOcclusion: boolean;
  98675. /**
  98676. * 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.
  98677. */
  98678. parallaxScaleBias: number;
  98679. private _roughness;
  98680. /**
  98681. * Helps to define how blurry the reflections should appears in the material.
  98682. */
  98683. roughness: number;
  98684. /**
  98685. * In case of refraction, define the value of the indice of refraction.
  98686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98687. */
  98688. indexOfRefraction: number;
  98689. /**
  98690. * Invert the refraction texture alongside the y axis.
  98691. * It can be useful with procedural textures or probe for instance.
  98692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98693. */
  98694. invertRefractionY: boolean;
  98695. /**
  98696. * Defines the alpha limits in alpha test mode.
  98697. */
  98698. alphaCutOff: number;
  98699. private _useLightmapAsShadowmap;
  98700. /**
  98701. * In case of light mapping, define whether the map contains light or shadow informations.
  98702. */
  98703. useLightmapAsShadowmap: boolean;
  98704. private _diffuseFresnelParameters;
  98705. /**
  98706. * Define the diffuse fresnel parameters of the material.
  98707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98708. */
  98709. diffuseFresnelParameters: FresnelParameters;
  98710. private _opacityFresnelParameters;
  98711. /**
  98712. * Define the opacity fresnel parameters of the material.
  98713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98714. */
  98715. opacityFresnelParameters: FresnelParameters;
  98716. private _reflectionFresnelParameters;
  98717. /**
  98718. * Define the reflection fresnel parameters of the material.
  98719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98720. */
  98721. reflectionFresnelParameters: FresnelParameters;
  98722. private _refractionFresnelParameters;
  98723. /**
  98724. * Define the refraction fresnel parameters of the material.
  98725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98726. */
  98727. refractionFresnelParameters: FresnelParameters;
  98728. private _emissiveFresnelParameters;
  98729. /**
  98730. * Define the emissive fresnel parameters of the material.
  98731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98732. */
  98733. emissiveFresnelParameters: FresnelParameters;
  98734. private _useReflectionFresnelFromSpecular;
  98735. /**
  98736. * If true automatically deducts the fresnels values from the material specularity.
  98737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98738. */
  98739. useReflectionFresnelFromSpecular: boolean;
  98740. private _useGlossinessFromSpecularMapAlpha;
  98741. /**
  98742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98743. */
  98744. useGlossinessFromSpecularMapAlpha: boolean;
  98745. private _maxSimultaneousLights;
  98746. /**
  98747. * Defines the maximum number of lights that can be used in the material
  98748. */
  98749. maxSimultaneousLights: number;
  98750. private _invertNormalMapX;
  98751. /**
  98752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98753. */
  98754. invertNormalMapX: boolean;
  98755. private _invertNormalMapY;
  98756. /**
  98757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98758. */
  98759. invertNormalMapY: boolean;
  98760. private _twoSidedLighting;
  98761. /**
  98762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98763. */
  98764. twoSidedLighting: boolean;
  98765. /**
  98766. * Default configuration related to image processing available in the standard Material.
  98767. */
  98768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98769. /**
  98770. * Gets the image processing configuration used either in this material.
  98771. */
  98772. /**
  98773. * Sets the Default image processing configuration used either in the this material.
  98774. *
  98775. * If sets to null, the scene one is in use.
  98776. */
  98777. imageProcessingConfiguration: ImageProcessingConfiguration;
  98778. /**
  98779. * Keep track of the image processing observer to allow dispose and replace.
  98780. */
  98781. private _imageProcessingObserver;
  98782. /**
  98783. * Attaches a new image processing configuration to the Standard Material.
  98784. * @param configuration
  98785. */
  98786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98787. /**
  98788. * Gets wether the color curves effect is enabled.
  98789. */
  98790. /**
  98791. * Sets wether the color curves effect is enabled.
  98792. */
  98793. cameraColorCurvesEnabled: boolean;
  98794. /**
  98795. * Gets wether the color grading effect is enabled.
  98796. */
  98797. /**
  98798. * Gets wether the color grading effect is enabled.
  98799. */
  98800. cameraColorGradingEnabled: boolean;
  98801. /**
  98802. * Gets wether tonemapping is enabled or not.
  98803. */
  98804. /**
  98805. * Sets wether tonemapping is enabled or not
  98806. */
  98807. cameraToneMappingEnabled: boolean;
  98808. /**
  98809. * The camera exposure used on this material.
  98810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98811. * This corresponds to a photographic exposure.
  98812. */
  98813. /**
  98814. * The camera exposure used on this material.
  98815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98816. * This corresponds to a photographic exposure.
  98817. */
  98818. cameraExposure: number;
  98819. /**
  98820. * Gets The camera contrast used on this material.
  98821. */
  98822. /**
  98823. * Sets The camera contrast used on this material.
  98824. */
  98825. cameraContrast: number;
  98826. /**
  98827. * Gets the Color Grading 2D Lookup Texture.
  98828. */
  98829. /**
  98830. * Sets the Color Grading 2D Lookup Texture.
  98831. */
  98832. cameraColorGradingTexture: Nullable<BaseTexture>;
  98833. /**
  98834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98836. * 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;
  98837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98838. */
  98839. /**
  98840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98842. * 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;
  98843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98844. */
  98845. cameraColorCurves: Nullable<ColorCurves>;
  98846. /**
  98847. * Custom callback helping to override the default shader used in the material.
  98848. */
  98849. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98850. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98851. protected _worldViewProjectionMatrix: Matrix;
  98852. protected _globalAmbientColor: Color3;
  98853. protected _useLogarithmicDepth: boolean;
  98854. /**
  98855. * Instantiates a new standard material.
  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. * @param name Define the name of the material in the scene
  98860. * @param scene Define the scene the material belong to
  98861. */
  98862. constructor(name: string, scene: Scene);
  98863. /**
  98864. * Gets a boolean indicating that current material needs to register RTT
  98865. */
  98866. readonly hasRenderTargetTextures: boolean;
  98867. /**
  98868. * Gets the current class name of the material e.g. "StandardMaterial"
  98869. * Mainly use in serialization.
  98870. * @returns the class name
  98871. */
  98872. getClassName(): string;
  98873. /**
  98874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98875. * You can try switching to logarithmic depth.
  98876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98877. */
  98878. useLogarithmicDepth: boolean;
  98879. /**
  98880. * Specifies if the material will require alpha blending
  98881. * @returns a boolean specifying if alpha blending is needed
  98882. */
  98883. needAlphaBlending(): boolean;
  98884. /**
  98885. * Specifies if this material should be rendered in alpha test mode
  98886. * @returns a boolean specifying if an alpha test is needed.
  98887. */
  98888. needAlphaTesting(): boolean;
  98889. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98890. /**
  98891. * Get the texture used for alpha test purpose.
  98892. * @returns the diffuse texture in case of the standard material.
  98893. */
  98894. getAlphaTestTexture(): Nullable<BaseTexture>;
  98895. /**
  98896. * Get if the submesh is ready to be used and all its information available.
  98897. * Child classes can use it to update shaders
  98898. * @param mesh defines the mesh to check
  98899. * @param subMesh defines which submesh to check
  98900. * @param useInstances specifies that instances should be used
  98901. * @returns a boolean indicating that the submesh is ready or not
  98902. */
  98903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98904. /**
  98905. * Builds the material UBO layouts.
  98906. * Used internally during the effect preparation.
  98907. */
  98908. buildUniformLayout(): void;
  98909. /**
  98910. * Unbinds the material from the mesh
  98911. */
  98912. unbind(): void;
  98913. /**
  98914. * Binds the submesh to this material by preparing the effect and shader to draw
  98915. * @param world defines the world transformation matrix
  98916. * @param mesh defines the mesh containing the submesh
  98917. * @param subMesh defines the submesh to bind the material to
  98918. */
  98919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98920. /**
  98921. * Get the list of animatables in the material.
  98922. * @returns the list of animatables object used in the material
  98923. */
  98924. getAnimatables(): IAnimatable[];
  98925. /**
  98926. * Gets the active textures from the material
  98927. * @returns an array of textures
  98928. */
  98929. getActiveTextures(): BaseTexture[];
  98930. /**
  98931. * Specifies if the material uses a texture
  98932. * @param texture defines the texture to check against the material
  98933. * @returns a boolean specifying if the material uses the texture
  98934. */
  98935. hasTexture(texture: BaseTexture): boolean;
  98936. /**
  98937. * Disposes the material
  98938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98940. */
  98941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98942. /**
  98943. * Makes a duplicate of the material, and gives it a new name
  98944. * @param name defines the new name for the duplicated material
  98945. * @returns the cloned material
  98946. */
  98947. clone(name: string): StandardMaterial;
  98948. /**
  98949. * Serializes this material in a JSON representation
  98950. * @returns the serialized material object
  98951. */
  98952. serialize(): any;
  98953. /**
  98954. * Creates a standard material from parsed material data
  98955. * @param source defines the JSON representation of the material
  98956. * @param scene defines the hosting scene
  98957. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98958. * @returns a new standard material
  98959. */
  98960. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98961. /**
  98962. * Are diffuse textures enabled in the application.
  98963. */
  98964. static DiffuseTextureEnabled: boolean;
  98965. /**
  98966. * Are ambient textures enabled in the application.
  98967. */
  98968. static AmbientTextureEnabled: boolean;
  98969. /**
  98970. * Are opacity textures enabled in the application.
  98971. */
  98972. static OpacityTextureEnabled: boolean;
  98973. /**
  98974. * Are reflection textures enabled in the application.
  98975. */
  98976. static ReflectionTextureEnabled: boolean;
  98977. /**
  98978. * Are emissive textures enabled in the application.
  98979. */
  98980. static EmissiveTextureEnabled: boolean;
  98981. /**
  98982. * Are specular textures enabled in the application.
  98983. */
  98984. static SpecularTextureEnabled: boolean;
  98985. /**
  98986. * Are bump textures enabled in the application.
  98987. */
  98988. static BumpTextureEnabled: boolean;
  98989. /**
  98990. * Are lightmap textures enabled in the application.
  98991. */
  98992. static LightmapTextureEnabled: boolean;
  98993. /**
  98994. * Are refraction textures enabled in the application.
  98995. */
  98996. static RefractionTextureEnabled: boolean;
  98997. /**
  98998. * Are color grading textures enabled in the application.
  98999. */
  99000. static ColorGradingTextureEnabled: boolean;
  99001. /**
  99002. * Are fresnels enabled in the application.
  99003. */
  99004. static FresnelEnabled: boolean;
  99005. }
  99006. }
  99007. declare module BABYLON {
  99008. /**
  99009. * A class extending Texture allowing drawing on a texture
  99010. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99011. */
  99012. export class DynamicTexture extends Texture {
  99013. private _generateMipMaps;
  99014. private _canvas;
  99015. private _context;
  99016. private _engine;
  99017. /**
  99018. * Creates a DynamicTexture
  99019. * @param name defines the name of the texture
  99020. * @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
  99021. * @param scene defines the scene where you want the texture
  99022. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99024. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99025. */
  99026. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99027. /**
  99028. * Get the current class name of the texture useful for serialization or dynamic coding.
  99029. * @returns "DynamicTexture"
  99030. */
  99031. getClassName(): string;
  99032. /**
  99033. * Gets the current state of canRescale
  99034. */
  99035. readonly canRescale: boolean;
  99036. private _recreate;
  99037. /**
  99038. * Scales the texture
  99039. * @param ratio the scale factor to apply to both width and height
  99040. */
  99041. scale(ratio: number): void;
  99042. /**
  99043. * Resizes the texture
  99044. * @param width the new width
  99045. * @param height the new height
  99046. */
  99047. scaleTo(width: number, height: number): void;
  99048. /**
  99049. * Gets the context of the canvas used by the texture
  99050. * @returns the canvas context of the dynamic texture
  99051. */
  99052. getContext(): CanvasRenderingContext2D;
  99053. /**
  99054. * Clears the texture
  99055. */
  99056. clear(): void;
  99057. /**
  99058. * Updates the texture
  99059. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99060. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99061. */
  99062. update(invertY?: boolean, premulAlpha?: boolean): void;
  99063. /**
  99064. * Draws text onto the texture
  99065. * @param text defines the text to be drawn
  99066. * @param x defines the placement of the text from the left
  99067. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99068. * @param font defines the font to be used with font-style, font-size, font-name
  99069. * @param color defines the color used for the text
  99070. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99071. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99072. * @param update defines whether texture is immediately update (default is true)
  99073. */
  99074. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99075. /**
  99076. * Clones the texture
  99077. * @returns the clone of the texture.
  99078. */
  99079. clone(): DynamicTexture;
  99080. /**
  99081. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99082. * @returns a serialized dynamic texture object
  99083. */
  99084. serialize(): any;
  99085. /** @hidden */
  99086. _rebuild(): void;
  99087. }
  99088. }
  99089. declare module BABYLON {
  99090. /** @hidden */
  99091. export var imageProcessingPixelShader: {
  99092. name: string;
  99093. shader: string;
  99094. };
  99095. }
  99096. declare module BABYLON {
  99097. /**
  99098. * ImageProcessingPostProcess
  99099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99100. */
  99101. export class ImageProcessingPostProcess extends PostProcess {
  99102. /**
  99103. * Default configuration related to image processing available in the PBR Material.
  99104. */
  99105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99106. /**
  99107. * Gets the image processing configuration used either in this material.
  99108. */
  99109. /**
  99110. * Sets the Default image processing configuration used either in the this material.
  99111. *
  99112. * If sets to null, the scene one is in use.
  99113. */
  99114. imageProcessingConfiguration: ImageProcessingConfiguration;
  99115. /**
  99116. * Keep track of the image processing observer to allow dispose and replace.
  99117. */
  99118. private _imageProcessingObserver;
  99119. /**
  99120. * Attaches a new image processing configuration to the PBR Material.
  99121. * @param configuration
  99122. */
  99123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99124. /**
  99125. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99126. */
  99127. /**
  99128. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99129. */
  99130. colorCurves: Nullable<ColorCurves>;
  99131. /**
  99132. * Gets wether the color curves effect is enabled.
  99133. */
  99134. /**
  99135. * Sets wether the color curves effect is enabled.
  99136. */
  99137. colorCurvesEnabled: boolean;
  99138. /**
  99139. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99140. */
  99141. /**
  99142. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99143. */
  99144. colorGradingTexture: Nullable<BaseTexture>;
  99145. /**
  99146. * Gets wether the color grading effect is enabled.
  99147. */
  99148. /**
  99149. * Gets wether the color grading effect is enabled.
  99150. */
  99151. colorGradingEnabled: boolean;
  99152. /**
  99153. * Gets exposure used in the effect.
  99154. */
  99155. /**
  99156. * Sets exposure used in the effect.
  99157. */
  99158. exposure: number;
  99159. /**
  99160. * Gets wether tonemapping is enabled or not.
  99161. */
  99162. /**
  99163. * Sets wether tonemapping is enabled or not
  99164. */
  99165. toneMappingEnabled: boolean;
  99166. /**
  99167. * Gets the type of tone mapping effect.
  99168. */
  99169. /**
  99170. * Sets the type of tone mapping effect.
  99171. */
  99172. toneMappingType: number;
  99173. /**
  99174. * Gets contrast used in the effect.
  99175. */
  99176. /**
  99177. * Sets contrast used in the effect.
  99178. */
  99179. contrast: number;
  99180. /**
  99181. * Gets Vignette stretch size.
  99182. */
  99183. /**
  99184. * Sets Vignette stretch size.
  99185. */
  99186. vignetteStretch: number;
  99187. /**
  99188. * Gets Vignette centre X Offset.
  99189. */
  99190. /**
  99191. * Sets Vignette centre X Offset.
  99192. */
  99193. vignetteCentreX: number;
  99194. /**
  99195. * Gets Vignette centre Y Offset.
  99196. */
  99197. /**
  99198. * Sets Vignette centre Y Offset.
  99199. */
  99200. vignetteCentreY: number;
  99201. /**
  99202. * Gets Vignette weight or intensity of the vignette effect.
  99203. */
  99204. /**
  99205. * Sets Vignette weight or intensity of the vignette effect.
  99206. */
  99207. vignetteWeight: number;
  99208. /**
  99209. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99210. * if vignetteEnabled is set to true.
  99211. */
  99212. /**
  99213. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99214. * if vignetteEnabled is set to true.
  99215. */
  99216. vignetteColor: Color4;
  99217. /**
  99218. * Gets Camera field of view used by the Vignette effect.
  99219. */
  99220. /**
  99221. * Sets Camera field of view used by the Vignette effect.
  99222. */
  99223. vignetteCameraFov: number;
  99224. /**
  99225. * Gets the vignette blend mode allowing different kind of effect.
  99226. */
  99227. /**
  99228. * Sets the vignette blend mode allowing different kind of effect.
  99229. */
  99230. vignetteBlendMode: number;
  99231. /**
  99232. * Gets wether the vignette effect is enabled.
  99233. */
  99234. /**
  99235. * Sets wether the vignette effect is enabled.
  99236. */
  99237. vignetteEnabled: boolean;
  99238. private _fromLinearSpace;
  99239. /**
  99240. * Gets wether the input of the processing is in Gamma or Linear Space.
  99241. */
  99242. /**
  99243. * Sets wether the input of the processing is in Gamma or Linear Space.
  99244. */
  99245. fromLinearSpace: boolean;
  99246. /**
  99247. * Defines cache preventing GC.
  99248. */
  99249. private _defines;
  99250. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99251. /**
  99252. * "ImageProcessingPostProcess"
  99253. * @returns "ImageProcessingPostProcess"
  99254. */
  99255. getClassName(): string;
  99256. protected _updateParameters(): void;
  99257. dispose(camera?: Camera): void;
  99258. }
  99259. }
  99260. declare module BABYLON {
  99261. /**
  99262. * Class containing static functions to help procedurally build meshes
  99263. */
  99264. export class GroundBuilder {
  99265. /**
  99266. * Creates a ground mesh
  99267. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99268. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99270. * @param name defines the name of the mesh
  99271. * @param options defines the options used to create the mesh
  99272. * @param scene defines the hosting scene
  99273. * @returns the ground mesh
  99274. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99275. */
  99276. static CreateGround(name: string, options: {
  99277. width?: number;
  99278. height?: number;
  99279. subdivisions?: number;
  99280. subdivisionsX?: number;
  99281. subdivisionsY?: number;
  99282. updatable?: boolean;
  99283. }, scene: any): Mesh;
  99284. /**
  99285. * Creates a tiled ground mesh
  99286. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99287. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99288. * * 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
  99289. * * 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
  99290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99291. * @param name defines the name of the mesh
  99292. * @param options defines the options used to create the mesh
  99293. * @param scene defines the hosting scene
  99294. * @returns the tiled ground mesh
  99295. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99296. */
  99297. static CreateTiledGround(name: string, options: {
  99298. xmin: number;
  99299. zmin: number;
  99300. xmax: number;
  99301. zmax: number;
  99302. subdivisions?: {
  99303. w: number;
  99304. h: number;
  99305. };
  99306. precision?: {
  99307. w: number;
  99308. h: number;
  99309. };
  99310. updatable?: boolean;
  99311. }, scene?: Nullable<Scene>): Mesh;
  99312. /**
  99313. * Creates a ground mesh from a height map
  99314. * * The parameter `url` sets the URL of the height map image resource.
  99315. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99316. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99317. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99318. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99319. * * 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.
  99320. * * 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).
  99321. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99323. * @param name defines the name of the mesh
  99324. * @param url defines the url to the height map
  99325. * @param options defines the options used to create the mesh
  99326. * @param scene defines the hosting scene
  99327. * @returns the ground mesh
  99328. * @see https://doc.babylonjs.com/babylon101/height_map
  99329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99330. */
  99331. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99332. width?: number;
  99333. height?: number;
  99334. subdivisions?: number;
  99335. minHeight?: number;
  99336. maxHeight?: number;
  99337. colorFilter?: Color3;
  99338. alphaFilter?: number;
  99339. updatable?: boolean;
  99340. onReady?: (mesh: GroundMesh) => void;
  99341. }, scene?: Nullable<Scene>): GroundMesh;
  99342. }
  99343. }
  99344. declare module BABYLON {
  99345. /**
  99346. * Class containing static functions to help procedurally build meshes
  99347. */
  99348. export class TorusBuilder {
  99349. /**
  99350. * Creates a torus mesh
  99351. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99352. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99353. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99357. * @param name defines the name of the mesh
  99358. * @param options defines the options used to create the mesh
  99359. * @param scene defines the hosting scene
  99360. * @returns the torus mesh
  99361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99362. */
  99363. static CreateTorus(name: string, options: {
  99364. diameter?: number;
  99365. thickness?: number;
  99366. tessellation?: number;
  99367. updatable?: boolean;
  99368. sideOrientation?: number;
  99369. frontUVs?: Vector4;
  99370. backUVs?: Vector4;
  99371. }, scene: any): Mesh;
  99372. }
  99373. }
  99374. declare module BABYLON {
  99375. /**
  99376. * Class containing static functions to help procedurally build meshes
  99377. */
  99378. export class CylinderBuilder {
  99379. /**
  99380. * Creates a cylinder or a cone mesh
  99381. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99382. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99383. * * 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.
  99384. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99385. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99386. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99387. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99388. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99389. * * 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).
  99390. * * 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
  99391. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99392. * * 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
  99393. * * 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.
  99394. * * If `enclose` is false, a ring surface is one element.
  99395. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99396. * * 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
  99397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99400. * @param name defines the name of the mesh
  99401. * @param options defines the options used to create the mesh
  99402. * @param scene defines the hosting scene
  99403. * @returns the cylinder mesh
  99404. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99405. */
  99406. static CreateCylinder(name: string, options: {
  99407. height?: number;
  99408. diameterTop?: number;
  99409. diameterBottom?: number;
  99410. diameter?: number;
  99411. tessellation?: number;
  99412. subdivisions?: number;
  99413. arc?: number;
  99414. faceColors?: Color4[];
  99415. faceUV?: Vector4[];
  99416. updatable?: boolean;
  99417. hasRings?: boolean;
  99418. enclose?: boolean;
  99419. sideOrientation?: number;
  99420. frontUVs?: Vector4;
  99421. backUVs?: Vector4;
  99422. }, scene: any): Mesh;
  99423. }
  99424. }
  99425. declare module BABYLON {
  99426. /**
  99427. * Manager for handling gamepads
  99428. */
  99429. export class GamepadManager {
  99430. private _scene?;
  99431. private _babylonGamepads;
  99432. private _oneGamepadConnected;
  99433. /** @hidden */
  99434. _isMonitoring: boolean;
  99435. private _gamepadEventSupported;
  99436. private _gamepadSupport;
  99437. /**
  99438. * observable to be triggered when the gamepad controller has been connected
  99439. */
  99440. onGamepadConnectedObservable: Observable<Gamepad>;
  99441. /**
  99442. * observable to be triggered when the gamepad controller has been disconnected
  99443. */
  99444. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99445. private _onGamepadConnectedEvent;
  99446. private _onGamepadDisconnectedEvent;
  99447. /**
  99448. * Initializes the gamepad manager
  99449. * @param _scene BabylonJS scene
  99450. */
  99451. constructor(_scene?: Scene | undefined);
  99452. /**
  99453. * The gamepads in the game pad manager
  99454. */
  99455. readonly gamepads: Gamepad[];
  99456. /**
  99457. * Get the gamepad controllers based on type
  99458. * @param type The type of gamepad controller
  99459. * @returns Nullable gamepad
  99460. */
  99461. getGamepadByType(type?: number): Nullable<Gamepad>;
  99462. /**
  99463. * Disposes the gamepad manager
  99464. */
  99465. dispose(): void;
  99466. private _addNewGamepad;
  99467. private _startMonitoringGamepads;
  99468. private _stopMonitoringGamepads;
  99469. /** @hidden */
  99470. _checkGamepadsStatus(): void;
  99471. private _updateGamepadObjects;
  99472. }
  99473. }
  99474. declare module BABYLON {
  99475. interface Scene {
  99476. /** @hidden */
  99477. _gamepadManager: Nullable<GamepadManager>;
  99478. /**
  99479. * Gets the gamepad manager associated with the scene
  99480. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99481. */
  99482. gamepadManager: GamepadManager;
  99483. }
  99484. /**
  99485. * Interface representing a free camera inputs manager
  99486. */
  99487. interface FreeCameraInputsManager {
  99488. /**
  99489. * Adds gamepad input support to the FreeCameraInputsManager.
  99490. * @returns the FreeCameraInputsManager
  99491. */
  99492. addGamepad(): FreeCameraInputsManager;
  99493. }
  99494. /**
  99495. * Interface representing an arc rotate camera inputs manager
  99496. */
  99497. interface ArcRotateCameraInputsManager {
  99498. /**
  99499. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99500. * @returns the camera inputs manager
  99501. */
  99502. addGamepad(): ArcRotateCameraInputsManager;
  99503. }
  99504. /**
  99505. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99506. */
  99507. export class GamepadSystemSceneComponent implements ISceneComponent {
  99508. /**
  99509. * The component name helpfull to identify the component in the list of scene components.
  99510. */
  99511. readonly name: string;
  99512. /**
  99513. * The scene the component belongs to.
  99514. */
  99515. scene: Scene;
  99516. /**
  99517. * Creates a new instance of the component for the given scene
  99518. * @param scene Defines the scene to register the component in
  99519. */
  99520. constructor(scene: Scene);
  99521. /**
  99522. * Registers the component in a given scene
  99523. */
  99524. register(): void;
  99525. /**
  99526. * Rebuilds the elements related to this component in case of
  99527. * context lost for instance.
  99528. */
  99529. rebuild(): void;
  99530. /**
  99531. * Disposes the component and the associated ressources
  99532. */
  99533. dispose(): void;
  99534. private _beforeCameraUpdate;
  99535. }
  99536. }
  99537. declare module BABYLON {
  99538. /**
  99539. * Options to modify the vr teleportation behavior.
  99540. */
  99541. export interface VRTeleportationOptions {
  99542. /**
  99543. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99544. */
  99545. floorMeshName?: string;
  99546. /**
  99547. * A list of meshes to be used as the teleportation floor. (default: empty)
  99548. */
  99549. floorMeshes?: Mesh[];
  99550. }
  99551. /**
  99552. * Options to modify the vr experience helper's behavior.
  99553. */
  99554. export interface VRExperienceHelperOptions extends WebVROptions {
  99555. /**
  99556. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99557. */
  99558. createDeviceOrientationCamera?: boolean;
  99559. /**
  99560. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99561. */
  99562. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99563. /**
  99564. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99565. */
  99566. laserToggle?: boolean;
  99567. /**
  99568. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99569. */
  99570. floorMeshes?: Mesh[];
  99571. /**
  99572. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99573. */
  99574. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99575. }
  99576. /**
  99577. * Event containing information after VR has been entered
  99578. */
  99579. export class OnAfterEnteringVRObservableEvent {
  99580. /**
  99581. * If entering vr was successful
  99582. */
  99583. success: boolean;
  99584. }
  99585. /**
  99586. * Helps to quickly add VR support to an existing scene.
  99587. * See http://doc.babylonjs.com/how_to/webvr_helper
  99588. */
  99589. export class VRExperienceHelper {
  99590. /** Options to modify the vr experience helper's behavior. */
  99591. webVROptions: VRExperienceHelperOptions;
  99592. private _scene;
  99593. private _position;
  99594. private _btnVR;
  99595. private _btnVRDisplayed;
  99596. private _webVRsupported;
  99597. private _webVRready;
  99598. private _webVRrequesting;
  99599. private _webVRpresenting;
  99600. private _hasEnteredVR;
  99601. private _fullscreenVRpresenting;
  99602. private _canvas;
  99603. private _webVRCamera;
  99604. private _vrDeviceOrientationCamera;
  99605. private _deviceOrientationCamera;
  99606. private _existingCamera;
  99607. private _onKeyDown;
  99608. private _onVrDisplayPresentChange;
  99609. private _onVRDisplayChanged;
  99610. private _onVRRequestPresentStart;
  99611. private _onVRRequestPresentComplete;
  99612. /**
  99613. * Observable raised right before entering VR.
  99614. */
  99615. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99616. /**
  99617. * Observable raised when entering VR has completed.
  99618. */
  99619. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99620. /**
  99621. * Observable raised when exiting VR.
  99622. */
  99623. onExitingVRObservable: Observable<VRExperienceHelper>;
  99624. /**
  99625. * Observable raised when controller mesh is loaded.
  99626. */
  99627. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99628. /** Return this.onEnteringVRObservable
  99629. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99630. */
  99631. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99632. /** Return this.onExitingVRObservable
  99633. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99634. */
  99635. readonly onExitingVR: Observable<VRExperienceHelper>;
  99636. /** Return this.onControllerMeshLoadedObservable
  99637. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99638. */
  99639. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99640. private _rayLength;
  99641. private _useCustomVRButton;
  99642. private _teleportationRequested;
  99643. private _teleportActive;
  99644. private _floorMeshName;
  99645. private _floorMeshesCollection;
  99646. private _rotationAllowed;
  99647. private _teleportBackwardsVector;
  99648. private _teleportationTarget;
  99649. private _isDefaultTeleportationTarget;
  99650. private _postProcessMove;
  99651. private _teleportationFillColor;
  99652. private _teleportationBorderColor;
  99653. private _rotationAngle;
  99654. private _haloCenter;
  99655. private _cameraGazer;
  99656. private _padSensibilityUp;
  99657. private _padSensibilityDown;
  99658. private _leftController;
  99659. private _rightController;
  99660. /**
  99661. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99662. */
  99663. onNewMeshSelected: Observable<AbstractMesh>;
  99664. /**
  99665. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99666. */
  99667. onNewMeshPicked: Observable<PickingInfo>;
  99668. private _circleEase;
  99669. /**
  99670. * Observable raised before camera teleportation
  99671. */
  99672. onBeforeCameraTeleport: Observable<Vector3>;
  99673. /**
  99674. * Observable raised after camera teleportation
  99675. */
  99676. onAfterCameraTeleport: Observable<Vector3>;
  99677. /**
  99678. * Observable raised when current selected mesh gets unselected
  99679. */
  99680. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99681. private _raySelectionPredicate;
  99682. /**
  99683. * To be optionaly changed by user to define custom ray selection
  99684. */
  99685. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99686. /**
  99687. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99688. */
  99689. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99690. /**
  99691. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99692. */
  99693. teleportationEnabled: boolean;
  99694. private _defaultHeight;
  99695. private _teleportationInitialized;
  99696. private _interactionsEnabled;
  99697. private _interactionsRequested;
  99698. private _displayGaze;
  99699. private _displayLaserPointer;
  99700. /**
  99701. * The mesh used to display where the user is going to teleport.
  99702. */
  99703. /**
  99704. * Sets the mesh to be used to display where the user is going to teleport.
  99705. */
  99706. teleportationTarget: Mesh;
  99707. /**
  99708. * 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
  99709. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99710. * See http://doc.babylonjs.com/resources/baking_transformations
  99711. */
  99712. gazeTrackerMesh: Mesh;
  99713. /**
  99714. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99715. */
  99716. updateGazeTrackerScale: boolean;
  99717. /**
  99718. * If the gaze trackers color should be updated when selecting meshes
  99719. */
  99720. updateGazeTrackerColor: boolean;
  99721. /**
  99722. * The gaze tracking mesh corresponding to the left controller
  99723. */
  99724. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99725. /**
  99726. * The gaze tracking mesh corresponding to the right controller
  99727. */
  99728. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99729. /**
  99730. * If the ray of the gaze should be displayed.
  99731. */
  99732. /**
  99733. * Sets if the ray of the gaze should be displayed.
  99734. */
  99735. displayGaze: boolean;
  99736. /**
  99737. * If the ray of the LaserPointer should be displayed.
  99738. */
  99739. /**
  99740. * Sets if the ray of the LaserPointer should be displayed.
  99741. */
  99742. displayLaserPointer: boolean;
  99743. /**
  99744. * The deviceOrientationCamera used as the camera when not in VR.
  99745. */
  99746. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99747. /**
  99748. * Based on the current WebVR support, returns the current VR camera used.
  99749. */
  99750. readonly currentVRCamera: Nullable<Camera>;
  99751. /**
  99752. * The webVRCamera which is used when in VR.
  99753. */
  99754. readonly webVRCamera: WebVRFreeCamera;
  99755. /**
  99756. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99757. */
  99758. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99759. private readonly _teleportationRequestInitiated;
  99760. /**
  99761. * Defines wether or not Pointer lock should be requested when switching to
  99762. * full screen.
  99763. */
  99764. requestPointerLockOnFullScreen: boolean;
  99765. /**
  99766. * Instantiates a VRExperienceHelper.
  99767. * Helps to quickly add VR support to an existing scene.
  99768. * @param scene The scene the VRExperienceHelper belongs to.
  99769. * @param webVROptions Options to modify the vr experience helper's behavior.
  99770. */
  99771. constructor(scene: Scene,
  99772. /** Options to modify the vr experience helper's behavior. */
  99773. webVROptions?: VRExperienceHelperOptions);
  99774. private _onDefaultMeshLoaded;
  99775. private _onResize;
  99776. private _onFullscreenChange;
  99777. /**
  99778. * Gets a value indicating if we are currently in VR mode.
  99779. */
  99780. readonly isInVRMode: boolean;
  99781. private onVrDisplayPresentChange;
  99782. private onVRDisplayChanged;
  99783. private moveButtonToBottomRight;
  99784. private displayVRButton;
  99785. private updateButtonVisibility;
  99786. private _cachedAngularSensibility;
  99787. /**
  99788. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99789. * Otherwise, will use the fullscreen API.
  99790. */
  99791. enterVR(): void;
  99792. /**
  99793. * Attempt to exit VR, or fullscreen.
  99794. */
  99795. exitVR(): void;
  99796. /**
  99797. * The position of the vr experience helper.
  99798. */
  99799. /**
  99800. * Sets the position of the vr experience helper.
  99801. */
  99802. position: Vector3;
  99803. /**
  99804. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99805. */
  99806. enableInteractions(): void;
  99807. private readonly _noControllerIsActive;
  99808. private beforeRender;
  99809. private _isTeleportationFloor;
  99810. /**
  99811. * Adds a floor mesh to be used for teleportation.
  99812. * @param floorMesh the mesh to be used for teleportation.
  99813. */
  99814. addFloorMesh(floorMesh: Mesh): void;
  99815. /**
  99816. * Removes a floor mesh from being used for teleportation.
  99817. * @param floorMesh the mesh to be removed.
  99818. */
  99819. removeFloorMesh(floorMesh: Mesh): void;
  99820. /**
  99821. * Enables interactions and teleportation using the VR controllers and gaze.
  99822. * @param vrTeleportationOptions options to modify teleportation behavior.
  99823. */
  99824. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99825. private _onNewGamepadConnected;
  99826. private _tryEnableInteractionOnController;
  99827. private _onNewGamepadDisconnected;
  99828. private _enableInteractionOnController;
  99829. private _checkTeleportWithRay;
  99830. private _checkRotate;
  99831. private _checkTeleportBackwards;
  99832. private _enableTeleportationOnController;
  99833. private _createTeleportationCircles;
  99834. private _displayTeleportationTarget;
  99835. private _hideTeleportationTarget;
  99836. private _rotateCamera;
  99837. private _moveTeleportationSelectorTo;
  99838. private _workingVector;
  99839. private _workingQuaternion;
  99840. private _workingMatrix;
  99841. /**
  99842. * Teleports the users feet to the desired location
  99843. * @param location The location where the user's feet should be placed
  99844. */
  99845. teleportCamera(location: Vector3): void;
  99846. private _convertNormalToDirectionOfRay;
  99847. private _castRayAndSelectObject;
  99848. private _notifySelectedMeshUnselected;
  99849. /**
  99850. * Sets the color of the laser ray from the vr controllers.
  99851. * @param color new color for the ray.
  99852. */
  99853. changeLaserColor(color: Color3): void;
  99854. /**
  99855. * Sets the color of the ray from the vr headsets gaze.
  99856. * @param color new color for the ray.
  99857. */
  99858. changeGazeColor(color: Color3): void;
  99859. /**
  99860. * Exits VR and disposes of the vr experience helper
  99861. */
  99862. dispose(): void;
  99863. /**
  99864. * Gets the name of the VRExperienceHelper class
  99865. * @returns "VRExperienceHelper"
  99866. */
  99867. getClassName(): string;
  99868. }
  99869. }
  99870. declare module BABYLON {
  99871. /**
  99872. * Manages an XRSession
  99873. * @see https://doc.babylonjs.com/how_to/webxr
  99874. */
  99875. export class WebXRSessionManager implements IDisposable {
  99876. private scene;
  99877. /**
  99878. * Fires every time a new xrFrame arrives which can be used to update the camera
  99879. */
  99880. onXRFrameObservable: Observable<any>;
  99881. /**
  99882. * Fires when the xr session is ended either by the device or manually done
  99883. */
  99884. onXRSessionEnded: Observable<any>;
  99885. /** @hidden */
  99886. _xrSession: XRSession;
  99887. /** @hidden */
  99888. _frameOfReference: XRFrameOfReference;
  99889. /** @hidden */
  99890. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99891. /** @hidden */
  99892. _currentXRFrame: Nullable<XRFrame>;
  99893. private _xrNavigator;
  99894. private _xrDevice;
  99895. private _tmpMatrix;
  99896. /**
  99897. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99898. * @param scene The scene which the session should be created for
  99899. */
  99900. constructor(scene: Scene);
  99901. /**
  99902. * Initializes the manager
  99903. * After initialization enterXR can be called to start an XR session
  99904. * @returns Promise which resolves after it is initialized
  99905. */
  99906. initializeAsync(): Promise<void>;
  99907. /**
  99908. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99909. * @param sessionCreationOptions xr options to create the session with
  99910. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99911. * @returns Promise which resolves after it enters XR
  99912. */
  99913. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99914. /**
  99915. * Stops the xrSession and restores the renderloop
  99916. * @returns Promise which resolves after it exits XR
  99917. */
  99918. exitXRAsync(): Promise<void>;
  99919. /**
  99920. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99921. * @param ray ray to cast into the environment
  99922. * @returns Promise which resolves with a collision point in the environment if it exists
  99923. */
  99924. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99925. /**
  99926. * Checks if a session would be supported for the creation options specified
  99927. * @param options creation options to check if they are supported
  99928. * @returns true if supported
  99929. */
  99930. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99931. /**
  99932. * @hidden
  99933. * Converts the render layer of xrSession to a render target
  99934. * @param session session to create render target for
  99935. * @param scene scene the new render target should be created for
  99936. */
  99937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99938. /**
  99939. * Disposes of the session manager
  99940. */
  99941. dispose(): void;
  99942. }
  99943. }
  99944. declare module BABYLON {
  99945. /**
  99946. * WebXR Camera which holds the views for the xrSession
  99947. * @see https://doc.babylonjs.com/how_to/webxr
  99948. */
  99949. export class WebXRCamera extends FreeCamera {
  99950. private static _TmpMatrix;
  99951. /**
  99952. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99953. * @param name the name of the camera
  99954. * @param scene the scene to add the camera to
  99955. */
  99956. constructor(name: string, scene: Scene);
  99957. private _updateNumberOfRigCameras;
  99958. /** @hidden */
  99959. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99960. /**
  99961. * Updates the cameras position from the current pose information of the XR session
  99962. * @param xrSessionManager the session containing pose information
  99963. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99964. */
  99965. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99966. }
  99967. }
  99968. declare module BABYLON {
  99969. /**
  99970. * States of the webXR experience
  99971. */
  99972. export enum WebXRState {
  99973. /**
  99974. * Transitioning to being in XR mode
  99975. */
  99976. ENTERING_XR = 0,
  99977. /**
  99978. * Transitioning to non XR mode
  99979. */
  99980. EXITING_XR = 1,
  99981. /**
  99982. * In XR mode and presenting
  99983. */
  99984. IN_XR = 2,
  99985. /**
  99986. * Not entered XR mode
  99987. */
  99988. NOT_IN_XR = 3
  99989. }
  99990. /**
  99991. * Helper class used to enable XR
  99992. * @see https://doc.babylonjs.com/how_to/webxr
  99993. */
  99994. export class WebXRExperienceHelper implements IDisposable {
  99995. private scene;
  99996. /**
  99997. * 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
  99998. */
  99999. container: AbstractMesh;
  100000. /**
  100001. * Camera used to render xr content
  100002. */
  100003. camera: WebXRCamera;
  100004. /**
  100005. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100006. */
  100007. state: WebXRState;
  100008. private _setState;
  100009. private static _TmpVector;
  100010. /**
  100011. * Fires when the state of the experience helper has changed
  100012. */
  100013. onStateChangedObservable: Observable<WebXRState>;
  100014. /** @hidden */
  100015. _sessionManager: WebXRSessionManager;
  100016. private _nonVRCamera;
  100017. private _originalSceneAutoClear;
  100018. private _supported;
  100019. /**
  100020. * Creates the experience helper
  100021. * @param scene the scene to attach the experience helper to
  100022. * @returns a promise for the experience helper
  100023. */
  100024. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100025. /**
  100026. * Creates a WebXRExperienceHelper
  100027. * @param scene The scene the helper should be created in
  100028. */
  100029. private constructor();
  100030. /**
  100031. * Exits XR mode and returns the scene to its original state
  100032. * @returns promise that resolves after xr mode has exited
  100033. */
  100034. exitXRAsync(): Promise<void>;
  100035. /**
  100036. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100037. * @param sessionCreationOptions options for the XR session
  100038. * @param frameOfReference frame of reference of the XR session
  100039. * @returns promise that resolves after xr mode has entered
  100040. */
  100041. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100042. /**
  100043. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100044. * @param ray ray to cast into the environment
  100045. * @returns Promise which resolves with a collision point in the environment if it exists
  100046. */
  100047. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100048. /**
  100049. * Updates the global position of the camera by moving the camera's container
  100050. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100051. * @param position The desired global position of the camera
  100052. */
  100053. setPositionOfCameraUsingContainer(position: Vector3): void;
  100054. /**
  100055. * Rotates the xr camera by rotating the camera's container around the camera's position
  100056. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100057. * @param rotation the desired quaternion rotation to apply to the camera
  100058. */
  100059. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100060. /**
  100061. * Checks if the creation options are supported by the xr session
  100062. * @param options creation options
  100063. * @returns true if supported
  100064. */
  100065. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100066. /**
  100067. * Disposes of the experience helper
  100068. */
  100069. dispose(): void;
  100070. }
  100071. }
  100072. declare module BABYLON {
  100073. /**
  100074. * Button which can be used to enter a different mode of XR
  100075. */
  100076. export class WebXREnterExitUIButton {
  100077. /** button element */
  100078. element: HTMLElement;
  100079. /** XR initialization options for the button */
  100080. initializationOptions: XRSessionCreationOptions;
  100081. /**
  100082. * Creates a WebXREnterExitUIButton
  100083. * @param element button element
  100084. * @param initializationOptions XR initialization options for the button
  100085. */
  100086. constructor(
  100087. /** button element */
  100088. element: HTMLElement,
  100089. /** XR initialization options for the button */
  100090. initializationOptions: XRSessionCreationOptions);
  100091. /**
  100092. * Overwritable function which can be used to update the button's visuals when the state changes
  100093. * @param activeButton the current active button in the UI
  100094. */
  100095. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100096. }
  100097. /**
  100098. * Options to create the webXR UI
  100099. */
  100100. export class WebXREnterExitUIOptions {
  100101. /**
  100102. * Context to enter xr with
  100103. */
  100104. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100105. /**
  100106. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100107. */
  100108. customButtons?: Array<WebXREnterExitUIButton>;
  100109. }
  100110. /**
  100111. * UI to allow the user to enter/exit XR mode
  100112. */
  100113. export class WebXREnterExitUI implements IDisposable {
  100114. private scene;
  100115. private _overlay;
  100116. private _buttons;
  100117. private _activeButton;
  100118. /**
  100119. * Fired every time the active button is changed.
  100120. *
  100121. * When xr is entered via a button that launches xr that button will be the callback parameter
  100122. *
  100123. * When exiting xr the callback parameter will be null)
  100124. */
  100125. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100126. /**
  100127. * Creates UI to allow the user to enter/exit XR mode
  100128. * @param scene the scene to add the ui to
  100129. * @param helper the xr experience helper to enter/exit xr with
  100130. * @param options options to configure the UI
  100131. * @returns the created ui
  100132. */
  100133. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100134. private constructor();
  100135. private _updateButtons;
  100136. /**
  100137. * Disposes of the object
  100138. */
  100139. dispose(): void;
  100140. }
  100141. }
  100142. declare module BABYLON {
  100143. /**
  100144. * Represents an XR input
  100145. */
  100146. export class WebXRController {
  100147. /**
  100148. * 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
  100149. */
  100150. grip?: AbstractMesh;
  100151. /**
  100152. * Pointer which can be used to select objects or attach a visible laser to
  100153. */
  100154. pointer: AbstractMesh;
  100155. /**
  100156. * Creates the controller
  100157. * @see https://doc.babylonjs.com/how_to/webxr
  100158. * @param scene the scene which the controller should be associated to
  100159. */
  100160. constructor(scene: Scene);
  100161. /**
  100162. * Disposes of the object
  100163. */
  100164. dispose(): void;
  100165. }
  100166. /**
  100167. * XR input used to track XR inputs such as controllers/rays
  100168. */
  100169. export class WebXRInput implements IDisposable {
  100170. private helper;
  100171. /**
  100172. * XR controllers being tracked
  100173. */
  100174. controllers: Array<WebXRController>;
  100175. private _tmpMatrix;
  100176. private _frameObserver;
  100177. /**
  100178. * Initializes the WebXRInput
  100179. * @param helper experience helper which the input should be created for
  100180. */
  100181. constructor(helper: WebXRExperienceHelper);
  100182. /**
  100183. * Disposes of the object
  100184. */
  100185. dispose(): void;
  100186. }
  100187. }
  100188. declare module BABYLON {
  100189. /**
  100190. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100191. */
  100192. export class WebXRManagedOutputCanvas implements IDisposable {
  100193. private _canvas;
  100194. /**
  100195. * xrpresent context of the canvas which can be used to display/mirror xr content
  100196. */
  100197. canvasContext: Nullable<WebGLRenderingContext>;
  100198. /**
  100199. * Initializes the canvas to be added/removed upon entering/exiting xr
  100200. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100201. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100202. */
  100203. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100204. /**
  100205. * Disposes of the object
  100206. */
  100207. dispose(): void;
  100208. private _setManagedOutputCanvas;
  100209. private _addCanvas;
  100210. private _removeCanvas;
  100211. }
  100212. }
  100213. declare module BABYLON {
  100214. /**
  100215. * Contains an array of blocks representing the octree
  100216. */
  100217. export interface IOctreeContainer<T> {
  100218. /**
  100219. * Blocks within the octree
  100220. */
  100221. blocks: Array<OctreeBlock<T>>;
  100222. }
  100223. /**
  100224. * Class used to store a cell in an octree
  100225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100226. */
  100227. export class OctreeBlock<T> {
  100228. /**
  100229. * Gets the content of the current block
  100230. */
  100231. entries: T[];
  100232. /**
  100233. * Gets the list of block children
  100234. */
  100235. blocks: Array<OctreeBlock<T>>;
  100236. private _depth;
  100237. private _maxDepth;
  100238. private _capacity;
  100239. private _minPoint;
  100240. private _maxPoint;
  100241. private _boundingVectors;
  100242. private _creationFunc;
  100243. /**
  100244. * Creates a new block
  100245. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100246. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100247. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100248. * @param depth defines the current depth of this block in the octree
  100249. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100250. * @param creationFunc defines a callback to call when an element is added to the block
  100251. */
  100252. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100253. /**
  100254. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100255. */
  100256. readonly capacity: number;
  100257. /**
  100258. * Gets the minimum vector (in world space) of the block's bounding box
  100259. */
  100260. readonly minPoint: Vector3;
  100261. /**
  100262. * Gets the maximum vector (in world space) of the block's bounding box
  100263. */
  100264. readonly maxPoint: Vector3;
  100265. /**
  100266. * Add a new element to this block
  100267. * @param entry defines the element to add
  100268. */
  100269. addEntry(entry: T): void;
  100270. /**
  100271. * Remove an element from this block
  100272. * @param entry defines the element to remove
  100273. */
  100274. removeEntry(entry: T): void;
  100275. /**
  100276. * Add an array of elements to this block
  100277. * @param entries defines the array of elements to add
  100278. */
  100279. addEntries(entries: T[]): void;
  100280. /**
  100281. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100282. * @param frustumPlanes defines the frustum planes to test
  100283. * @param selection defines the array to store current content if selection is positive
  100284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100285. */
  100286. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100287. /**
  100288. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100289. * @param sphereCenter defines the bounding sphere center
  100290. * @param sphereRadius defines the bounding sphere radius
  100291. * @param selection defines the array to store current content if selection is positive
  100292. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100293. */
  100294. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100295. /**
  100296. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100297. * @param ray defines the ray to test with
  100298. * @param selection defines the array to store current content if selection is positive
  100299. */
  100300. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100301. /**
  100302. * Subdivide the content into child blocks (this block will then be empty)
  100303. */
  100304. createInnerBlocks(): void;
  100305. /**
  100306. * @hidden
  100307. */
  100308. 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;
  100309. }
  100310. }
  100311. declare module BABYLON {
  100312. /**
  100313. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100315. */
  100316. export class Octree<T> {
  100317. /** 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.) */
  100318. maxDepth: number;
  100319. /**
  100320. * Blocks within the octree containing objects
  100321. */
  100322. blocks: Array<OctreeBlock<T>>;
  100323. /**
  100324. * Content stored in the octree
  100325. */
  100326. dynamicContent: T[];
  100327. private _maxBlockCapacity;
  100328. private _selectionContent;
  100329. private _creationFunc;
  100330. /**
  100331. * Creates a octree
  100332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100333. * @param creationFunc function to be used to instatiate the octree
  100334. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100335. * @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.)
  100336. */
  100337. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100338. /** 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.) */
  100339. maxDepth?: number);
  100340. /**
  100341. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100342. * @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);
  100343. * @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);
  100344. * @param entries meshes to be added to the octree blocks
  100345. */
  100346. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100347. /**
  100348. * Adds a mesh to the octree
  100349. * @param entry Mesh to add to the octree
  100350. */
  100351. addMesh(entry: T): void;
  100352. /**
  100353. * Remove an element from the octree
  100354. * @param entry defines the element to remove
  100355. */
  100356. removeMesh(entry: T): void;
  100357. /**
  100358. * Selects an array of meshes within the frustum
  100359. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100360. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100361. * @returns array of meshes within the frustum
  100362. */
  100363. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100364. /**
  100365. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100366. * @param sphereCenter defines the bounding sphere center
  100367. * @param sphereRadius defines the bounding sphere radius
  100368. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100369. * @returns an array of objects that intersect the sphere
  100370. */
  100371. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100372. /**
  100373. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100374. * @param ray defines the ray to test with
  100375. * @returns array of intersected objects
  100376. */
  100377. intersectsRay(ray: Ray): SmartArray<T>;
  100378. /**
  100379. * Adds a mesh into the octree block if it intersects the block
  100380. */
  100381. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100382. /**
  100383. * Adds a submesh into the octree block if it intersects the block
  100384. */
  100385. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100386. }
  100387. }
  100388. declare module BABYLON {
  100389. interface Scene {
  100390. /**
  100391. * @hidden
  100392. * Backing Filed
  100393. */
  100394. _selectionOctree: Octree<AbstractMesh>;
  100395. /**
  100396. * Gets the octree used to boost mesh selection (picking)
  100397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100398. */
  100399. selectionOctree: Octree<AbstractMesh>;
  100400. /**
  100401. * Creates or updates the octree used to boost selection (picking)
  100402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100403. * @param maxCapacity defines the maximum capacity per leaf
  100404. * @param maxDepth defines the maximum depth of the octree
  100405. * @returns an octree of AbstractMesh
  100406. */
  100407. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100408. }
  100409. interface AbstractMesh {
  100410. /**
  100411. * @hidden
  100412. * Backing Field
  100413. */
  100414. _submeshesOctree: Octree<SubMesh>;
  100415. /**
  100416. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100417. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100418. * @param maxCapacity defines the maximum size of each block (64 by default)
  100419. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100420. * @returns the new octree
  100421. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100423. */
  100424. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100425. }
  100426. /**
  100427. * Defines the octree scene component responsible to manage any octrees
  100428. * in a given scene.
  100429. */
  100430. export class OctreeSceneComponent {
  100431. /**
  100432. * The component name help to identify the component in the list of scene components.
  100433. */
  100434. readonly name: string;
  100435. /**
  100436. * The scene the component belongs to.
  100437. */
  100438. scene: Scene;
  100439. /**
  100440. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100441. */
  100442. readonly checksIsEnabled: boolean;
  100443. /**
  100444. * Creates a new instance of the component for the given scene
  100445. * @param scene Defines the scene to register the component in
  100446. */
  100447. constructor(scene: Scene);
  100448. /**
  100449. * Registers the component in a given scene
  100450. */
  100451. register(): void;
  100452. /**
  100453. * Return the list of active meshes
  100454. * @returns the list of active meshes
  100455. */
  100456. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100457. /**
  100458. * Return the list of active sub meshes
  100459. * @param mesh The mesh to get the candidates sub meshes from
  100460. * @returns the list of active sub meshes
  100461. */
  100462. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100463. private _tempRay;
  100464. /**
  100465. * Return the list of sub meshes intersecting with a given local ray
  100466. * @param mesh defines the mesh to find the submesh for
  100467. * @param localRay defines the ray in local space
  100468. * @returns the list of intersecting sub meshes
  100469. */
  100470. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100471. /**
  100472. * Return the list of sub meshes colliding with a collider
  100473. * @param mesh defines the mesh to find the submesh for
  100474. * @param collider defines the collider to evaluate the collision against
  100475. * @returns the list of colliding sub meshes
  100476. */
  100477. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100478. /**
  100479. * Rebuilds the elements related to this component in case of
  100480. * context lost for instance.
  100481. */
  100482. rebuild(): void;
  100483. /**
  100484. * Disposes the component and the associated ressources.
  100485. */
  100486. dispose(): void;
  100487. }
  100488. }
  100489. declare module BABYLON {
  100490. /**
  100491. * Renders a layer on top of an existing scene
  100492. */
  100493. export class UtilityLayerRenderer implements IDisposable {
  100494. /** the original scene that will be rendered on top of */
  100495. originalScene: Scene;
  100496. private _pointerCaptures;
  100497. private _lastPointerEvents;
  100498. private static _DefaultUtilityLayer;
  100499. private static _DefaultKeepDepthUtilityLayer;
  100500. private _sharedGizmoLight;
  100501. /**
  100502. * @hidden
  100503. * Light which used by gizmos to get light shading
  100504. */
  100505. _getSharedGizmoLight(): HemisphericLight;
  100506. /**
  100507. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100508. */
  100509. pickUtilitySceneFirst: boolean;
  100510. /**
  100511. * 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)
  100512. */
  100513. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100514. /**
  100515. * 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)
  100516. */
  100517. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100518. /**
  100519. * The scene that is rendered on top of the original scene
  100520. */
  100521. utilityLayerScene: Scene;
  100522. /**
  100523. * If the utility layer should automatically be rendered on top of existing scene
  100524. */
  100525. shouldRender: boolean;
  100526. /**
  100527. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100528. */
  100529. onlyCheckPointerDownEvents: boolean;
  100530. /**
  100531. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100532. */
  100533. processAllEvents: boolean;
  100534. /**
  100535. * Observable raised when the pointer move from the utility layer scene to the main scene
  100536. */
  100537. onPointerOutObservable: Observable<number>;
  100538. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100539. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100540. private _afterRenderObserver;
  100541. private _sceneDisposeObserver;
  100542. private _originalPointerObserver;
  100543. /**
  100544. * Instantiates a UtilityLayerRenderer
  100545. * @param originalScene the original scene that will be rendered on top of
  100546. * @param handleEvents boolean indicating if the utility layer should handle events
  100547. */
  100548. constructor(
  100549. /** the original scene that will be rendered on top of */
  100550. originalScene: Scene, handleEvents?: boolean);
  100551. private _notifyObservers;
  100552. /**
  100553. * Renders the utility layers scene on top of the original scene
  100554. */
  100555. render(): void;
  100556. /**
  100557. * Disposes of the renderer
  100558. */
  100559. dispose(): void;
  100560. private _updateCamera;
  100561. }
  100562. }
  100563. declare module BABYLON {
  100564. /**
  100565. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100566. */
  100567. export class Gizmo implements IDisposable {
  100568. /** The utility layer the gizmo will be added to */
  100569. gizmoLayer: UtilityLayerRenderer;
  100570. /**
  100571. * The root mesh of the gizmo
  100572. */
  100573. _rootMesh: Mesh;
  100574. private _attachedMesh;
  100575. /**
  100576. * Ratio for the scale of the gizmo (Default: 1)
  100577. */
  100578. scaleRatio: number;
  100579. /**
  100580. * If a custom mesh has been set (Default: false)
  100581. */
  100582. protected _customMeshSet: boolean;
  100583. /**
  100584. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100585. * * When set, interactions will be enabled
  100586. */
  100587. attachedMesh: Nullable<AbstractMesh>;
  100588. /**
  100589. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100590. * @param mesh The mesh to replace the default mesh of the gizmo
  100591. */
  100592. setCustomMesh(mesh: Mesh): void;
  100593. /**
  100594. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100595. */
  100596. updateGizmoRotationToMatchAttachedMesh: boolean;
  100597. /**
  100598. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100599. */
  100600. updateGizmoPositionToMatchAttachedMesh: boolean;
  100601. /**
  100602. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100603. */
  100604. protected _updateScale: boolean;
  100605. protected _interactionsEnabled: boolean;
  100606. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100607. private _beforeRenderObserver;
  100608. private _tempVector;
  100609. /**
  100610. * Creates a gizmo
  100611. * @param gizmoLayer The utility layer the gizmo will be added to
  100612. */
  100613. constructor(
  100614. /** The utility layer the gizmo will be added to */
  100615. gizmoLayer?: UtilityLayerRenderer);
  100616. /**
  100617. * Updates the gizmo to match the attached mesh's position/rotation
  100618. */
  100619. protected _update(): void;
  100620. /**
  100621. * Disposes of the gizmo
  100622. */
  100623. dispose(): void;
  100624. }
  100625. }
  100626. declare module BABYLON {
  100627. /**
  100628. * Single axis drag gizmo
  100629. */
  100630. export class AxisDragGizmo extends Gizmo {
  100631. /**
  100632. * Drag behavior responsible for the gizmos dragging interactions
  100633. */
  100634. dragBehavior: PointerDragBehavior;
  100635. private _pointerObserver;
  100636. /**
  100637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100638. */
  100639. snapDistance: number;
  100640. /**
  100641. * Event that fires each time the gizmo snaps to a new location.
  100642. * * snapDistance is the the change in distance
  100643. */
  100644. onSnapObservable: Observable<{
  100645. snapDistance: number;
  100646. }>;
  100647. /** @hidden */
  100648. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100649. /** @hidden */
  100650. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100651. /**
  100652. * Creates an AxisDragGizmo
  100653. * @param gizmoLayer The utility layer the gizmo will be added to
  100654. * @param dragAxis The axis which the gizmo will be able to drag on
  100655. * @param color The color of the gizmo
  100656. */
  100657. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100659. /**
  100660. * Disposes of the gizmo
  100661. */
  100662. dispose(): void;
  100663. }
  100664. }
  100665. declare module BABYLON.Debug {
  100666. /**
  100667. * The Axes viewer will show 3 axes in a specific point in space
  100668. */
  100669. export class AxesViewer {
  100670. private _xAxis;
  100671. private _yAxis;
  100672. private _zAxis;
  100673. private _scaleLinesFactor;
  100674. private _instanced;
  100675. /**
  100676. * Gets the hosting scene
  100677. */
  100678. scene: Scene;
  100679. /**
  100680. * Gets or sets a number used to scale line length
  100681. */
  100682. scaleLines: number;
  100683. /** Gets the node hierarchy used to render x-axis */
  100684. readonly xAxis: TransformNode;
  100685. /** Gets the node hierarchy used to render y-axis */
  100686. readonly yAxis: TransformNode;
  100687. /** Gets the node hierarchy used to render z-axis */
  100688. readonly zAxis: TransformNode;
  100689. /**
  100690. * Creates a new AxesViewer
  100691. * @param scene defines the hosting scene
  100692. * @param scaleLines defines a number used to scale line length (1 by default)
  100693. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100694. * @param xAxis defines the node hierarchy used to render the x-axis
  100695. * @param yAxis defines the node hierarchy used to render the y-axis
  100696. * @param zAxis defines the node hierarchy used to render the z-axis
  100697. */
  100698. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100699. /**
  100700. * Force the viewer to update
  100701. * @param position defines the position of the viewer
  100702. * @param xaxis defines the x axis of the viewer
  100703. * @param yaxis defines the y axis of the viewer
  100704. * @param zaxis defines the z axis of the viewer
  100705. */
  100706. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100707. /**
  100708. * Creates an instance of this axes viewer.
  100709. * @returns a new axes viewer with instanced meshes
  100710. */
  100711. createInstance(): AxesViewer;
  100712. /** Releases resources */
  100713. dispose(): void;
  100714. private static _SetRenderingGroupId;
  100715. }
  100716. }
  100717. declare module BABYLON.Debug {
  100718. /**
  100719. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100720. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100721. */
  100722. export class BoneAxesViewer extends AxesViewer {
  100723. /**
  100724. * Gets or sets the target mesh where to display the axes viewer
  100725. */
  100726. mesh: Nullable<Mesh>;
  100727. /**
  100728. * Gets or sets the target bone where to display the axes viewer
  100729. */
  100730. bone: Nullable<Bone>;
  100731. /** Gets current position */
  100732. pos: Vector3;
  100733. /** Gets direction of X axis */
  100734. xaxis: Vector3;
  100735. /** Gets direction of Y axis */
  100736. yaxis: Vector3;
  100737. /** Gets direction of Z axis */
  100738. zaxis: Vector3;
  100739. /**
  100740. * Creates a new BoneAxesViewer
  100741. * @param scene defines the hosting scene
  100742. * @param bone defines the target bone
  100743. * @param mesh defines the target mesh
  100744. * @param scaleLines defines a scaling factor for line length (1 by default)
  100745. */
  100746. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100747. /**
  100748. * Force the viewer to update
  100749. */
  100750. update(): void;
  100751. /** Releases resources */
  100752. dispose(): void;
  100753. }
  100754. }
  100755. declare module BABYLON {
  100756. /**
  100757. * Interface used to define scene explorer extensibility option
  100758. */
  100759. export interface IExplorerExtensibilityOption {
  100760. /**
  100761. * Define the option label
  100762. */
  100763. label: string;
  100764. /**
  100765. * Defines the action to execute on click
  100766. */
  100767. action: (entity: any) => void;
  100768. }
  100769. /**
  100770. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100771. */
  100772. export interface IExplorerExtensibilityGroup {
  100773. /**
  100774. * Defines a predicate to test if a given type mut be extended
  100775. */
  100776. predicate: (entity: any) => boolean;
  100777. /**
  100778. * Gets the list of options added to a type
  100779. */
  100780. entries: IExplorerExtensibilityOption[];
  100781. }
  100782. /**
  100783. * Interface used to define the options to use to create the Inspector
  100784. */
  100785. export interface IInspectorOptions {
  100786. /**
  100787. * Display in overlay mode (default: false)
  100788. */
  100789. overlay?: boolean;
  100790. /**
  100791. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100792. */
  100793. globalRoot?: HTMLElement;
  100794. /**
  100795. * Display the Scene explorer
  100796. */
  100797. showExplorer?: boolean;
  100798. /**
  100799. * Display the property inspector
  100800. */
  100801. showInspector?: boolean;
  100802. /**
  100803. * Display in embed mode (both panes on the right)
  100804. */
  100805. embedMode?: boolean;
  100806. /**
  100807. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100808. */
  100809. handleResize?: boolean;
  100810. /**
  100811. * Allow the panes to popup (default: true)
  100812. */
  100813. enablePopup?: boolean;
  100814. /**
  100815. * Allow the panes to be closed by users (default: true)
  100816. */
  100817. enableClose?: boolean;
  100818. /**
  100819. * Optional list of extensibility entries
  100820. */
  100821. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100822. /**
  100823. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100824. */
  100825. inspectorURL?: string;
  100826. }
  100827. interface Scene {
  100828. /**
  100829. * @hidden
  100830. * Backing field
  100831. */
  100832. _debugLayer: DebugLayer;
  100833. /**
  100834. * Gets the debug layer (aka Inspector) associated with the scene
  100835. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100836. */
  100837. debugLayer: DebugLayer;
  100838. }
  100839. /**
  100840. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100841. * what is happening in your scene
  100842. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100843. */
  100844. export class DebugLayer {
  100845. /**
  100846. * Define the url to get the inspector script from.
  100847. * By default it uses the babylonjs CDN.
  100848. * @ignoreNaming
  100849. */
  100850. static InspectorURL: string;
  100851. private _scene;
  100852. private BJSINSPECTOR;
  100853. /**
  100854. * Observable triggered when a property is changed through the inspector.
  100855. */
  100856. onPropertyChangedObservable: Observable<{
  100857. object: any;
  100858. property: string;
  100859. value: any;
  100860. initialValue: any;
  100861. }>;
  100862. /**
  100863. * Instantiates a new debug layer.
  100864. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100865. * what is happening in your scene
  100866. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100867. * @param scene Defines the scene to inspect
  100868. */
  100869. constructor(scene: Scene);
  100870. /** Creates the inspector window. */
  100871. private _createInspector;
  100872. /**
  100873. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100874. * @param entity defines the entity to select
  100875. * @param lineContainerTitle defines the specific block to highlight
  100876. */
  100877. select(entity: any, lineContainerTitle?: string): void;
  100878. /** Get the inspector from bundle or global */
  100879. private _getGlobalInspector;
  100880. /**
  100881. * Get if the inspector is visible or not.
  100882. * @returns true if visible otherwise, false
  100883. */
  100884. isVisible(): boolean;
  100885. /**
  100886. * Hide the inspector and close its window.
  100887. */
  100888. hide(): void;
  100889. /**
  100890. * Launch the debugLayer.
  100891. * @param config Define the configuration of the inspector
  100892. * @return a promise fulfilled when the debug layer is visible
  100893. */
  100894. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100895. }
  100896. }
  100897. declare module BABYLON {
  100898. /**
  100899. * Class containing static functions to help procedurally build meshes
  100900. */
  100901. export class BoxBuilder {
  100902. /**
  100903. * Creates a box mesh
  100904. * * The parameter `size` sets the size (float) of each box side (default 1)
  100905. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100906. * * 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)
  100907. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100911. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100912. * @param name defines the name of the mesh
  100913. * @param options defines the options used to create the mesh
  100914. * @param scene defines the hosting scene
  100915. * @returns the box mesh
  100916. */
  100917. static CreateBox(name: string, options: {
  100918. size?: number;
  100919. width?: number;
  100920. height?: number;
  100921. depth?: number;
  100922. faceUV?: Vector4[];
  100923. faceColors?: Color4[];
  100924. sideOrientation?: number;
  100925. frontUVs?: Vector4;
  100926. backUVs?: Vector4;
  100927. wrap?: boolean;
  100928. topBaseAt?: number;
  100929. bottomBaseAt?: number;
  100930. updatable?: boolean;
  100931. }, scene?: Nullable<Scene>): Mesh;
  100932. }
  100933. }
  100934. declare module BABYLON {
  100935. /**
  100936. * Class containing static functions to help procedurally build meshes
  100937. */
  100938. export class SphereBuilder {
  100939. /**
  100940. * Creates a sphere mesh
  100941. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100942. * * 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`)
  100943. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100944. * * 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
  100945. * * 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)
  100946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100949. * @param name defines the name of the mesh
  100950. * @param options defines the options used to create the mesh
  100951. * @param scene defines the hosting scene
  100952. * @returns the sphere mesh
  100953. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100954. */
  100955. static CreateSphere(name: string, options: {
  100956. segments?: number;
  100957. diameter?: number;
  100958. diameterX?: number;
  100959. diameterY?: number;
  100960. diameterZ?: number;
  100961. arc?: number;
  100962. slice?: number;
  100963. sideOrientation?: number;
  100964. frontUVs?: Vector4;
  100965. backUVs?: Vector4;
  100966. updatable?: boolean;
  100967. }, scene: any): Mesh;
  100968. }
  100969. }
  100970. declare module BABYLON.Debug {
  100971. /**
  100972. * Used to show the physics impostor around the specific mesh
  100973. */
  100974. export class PhysicsViewer {
  100975. /** @hidden */
  100976. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100977. /** @hidden */
  100978. protected _meshes: Array<Nullable<AbstractMesh>>;
  100979. /** @hidden */
  100980. protected _scene: Nullable<Scene>;
  100981. /** @hidden */
  100982. protected _numMeshes: number;
  100983. /** @hidden */
  100984. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100985. private _renderFunction;
  100986. private _utilityLayer;
  100987. private _debugBoxMesh;
  100988. private _debugSphereMesh;
  100989. private _debugCylinderMesh;
  100990. private _debugMaterial;
  100991. private _debugMeshMeshes;
  100992. /**
  100993. * Creates a new PhysicsViewer
  100994. * @param scene defines the hosting scene
  100995. */
  100996. constructor(scene: Scene);
  100997. /** @hidden */
  100998. protected _updateDebugMeshes(): void;
  100999. /**
  101000. * Renders a specified physic impostor
  101001. * @param impostor defines the impostor to render
  101002. * @param targetMesh defines the mesh represented by the impostor
  101003. * @returns the new debug mesh used to render the impostor
  101004. */
  101005. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101006. /**
  101007. * Hides a specified physic impostor
  101008. * @param impostor defines the impostor to hide
  101009. */
  101010. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101011. private _getDebugMaterial;
  101012. private _getDebugBoxMesh;
  101013. private _getDebugSphereMesh;
  101014. private _getDebugCylinderMesh;
  101015. private _getDebugMeshMesh;
  101016. private _getDebugMesh;
  101017. /** Releases all resources */
  101018. dispose(): void;
  101019. }
  101020. }
  101021. declare module BABYLON {
  101022. /**
  101023. * Class containing static functions to help procedurally build meshes
  101024. */
  101025. export class LinesBuilder {
  101026. /**
  101027. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101028. * * 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
  101029. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101030. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101031. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101032. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101033. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101034. * * 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
  101035. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101038. * @param name defines the name of the new line system
  101039. * @param options defines the options used to create the line system
  101040. * @param scene defines the hosting scene
  101041. * @returns a new line system mesh
  101042. */
  101043. static CreateLineSystem(name: string, options: {
  101044. lines: Vector3[][];
  101045. updatable?: boolean;
  101046. instance?: Nullable<LinesMesh>;
  101047. colors?: Nullable<Color4[][]>;
  101048. useVertexAlpha?: boolean;
  101049. }, scene: Nullable<Scene>): LinesMesh;
  101050. /**
  101051. * Creates a line mesh
  101052. * 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
  101053. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101054. * * The parameter `points` is an array successive Vector3
  101055. * * 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
  101056. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101057. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101058. * * When updating an instance, remember that only point positions can change, not the number of points
  101059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101061. * @param name defines the name of the new line system
  101062. * @param options defines the options used to create the line system
  101063. * @param scene defines the hosting scene
  101064. * @returns a new line mesh
  101065. */
  101066. static CreateLines(name: string, options: {
  101067. points: Vector3[];
  101068. updatable?: boolean;
  101069. instance?: Nullable<LinesMesh>;
  101070. colors?: Color4[];
  101071. useVertexAlpha?: boolean;
  101072. }, scene?: Nullable<Scene>): LinesMesh;
  101073. /**
  101074. * Creates a dashed line mesh
  101075. * * 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
  101076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101077. * * The parameter `points` is an array successive Vector3
  101078. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101079. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101080. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101081. * * 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
  101082. * * When updating an instance, remember that only point positions can change, not the number of points
  101083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101084. * @param name defines the name of the mesh
  101085. * @param options defines the options used to create the mesh
  101086. * @param scene defines the hosting scene
  101087. * @returns the dashed line mesh
  101088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101089. */
  101090. static CreateDashedLines(name: string, options: {
  101091. points: Vector3[];
  101092. dashSize?: number;
  101093. gapSize?: number;
  101094. dashNb?: number;
  101095. updatable?: boolean;
  101096. instance?: LinesMesh;
  101097. }, scene?: Nullable<Scene>): LinesMesh;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /**
  101102. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101103. * in order to better appreciate the issue one might have.
  101104. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101105. */
  101106. export class RayHelper {
  101107. /**
  101108. * Defines the ray we are currently tryin to visualize.
  101109. */
  101110. ray: Nullable<Ray>;
  101111. private _renderPoints;
  101112. private _renderLine;
  101113. private _renderFunction;
  101114. private _scene;
  101115. private _updateToMeshFunction;
  101116. private _attachedToMesh;
  101117. private _meshSpaceDirection;
  101118. private _meshSpaceOrigin;
  101119. /**
  101120. * Helper function to create a colored helper in a scene in one line.
  101121. * @param ray Defines the ray we are currently tryin to visualize
  101122. * @param scene Defines the scene the ray is used in
  101123. * @param color Defines the color we want to see the ray in
  101124. * @returns The newly created ray helper.
  101125. */
  101126. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101127. /**
  101128. * Instantiate a new ray helper.
  101129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101130. * in order to better appreciate the issue one might have.
  101131. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101132. * @param ray Defines the ray we are currently tryin to visualize
  101133. */
  101134. constructor(ray: Ray);
  101135. /**
  101136. * Shows the ray we are willing to debug.
  101137. * @param scene Defines the scene the ray needs to be rendered in
  101138. * @param color Defines the color the ray needs to be rendered in
  101139. */
  101140. show(scene: Scene, color?: Color3): void;
  101141. /**
  101142. * Hides the ray we are debugging.
  101143. */
  101144. hide(): void;
  101145. private _render;
  101146. /**
  101147. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101148. * @param mesh Defines the mesh we want the helper attached to
  101149. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101150. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101151. * @param length Defines the length of the ray
  101152. */
  101153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101154. /**
  101155. * Detach the ray helper from the mesh it has previously been attached to.
  101156. */
  101157. detachFromMesh(): void;
  101158. private _updateToMesh;
  101159. /**
  101160. * Dispose the helper and release its associated resources.
  101161. */
  101162. dispose(): void;
  101163. }
  101164. }
  101165. declare module BABYLON.Debug {
  101166. /**
  101167. * Class used to render a debug view of a given skeleton
  101168. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101169. */
  101170. export class SkeletonViewer {
  101171. /** defines the skeleton to render */
  101172. skeleton: Skeleton;
  101173. /** defines the mesh attached to the skeleton */
  101174. mesh: AbstractMesh;
  101175. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101176. autoUpdateBonesMatrices: boolean;
  101177. /** defines the rendering group id to use with the viewer */
  101178. renderingGroupId: number;
  101179. /** Gets or sets the color used to render the skeleton */
  101180. color: Color3;
  101181. private _scene;
  101182. private _debugLines;
  101183. private _debugMesh;
  101184. private _isEnabled;
  101185. private _renderFunction;
  101186. private _utilityLayer;
  101187. /**
  101188. * Returns the mesh used to render the bones
  101189. */
  101190. readonly debugMesh: Nullable<LinesMesh>;
  101191. /**
  101192. * Creates a new SkeletonViewer
  101193. * @param skeleton defines the skeleton to render
  101194. * @param mesh defines the mesh attached to the skeleton
  101195. * @param scene defines the hosting scene
  101196. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101197. * @param renderingGroupId defines the rendering group id to use with the viewer
  101198. */
  101199. constructor(
  101200. /** defines the skeleton to render */
  101201. skeleton: Skeleton,
  101202. /** defines the mesh attached to the skeleton */
  101203. mesh: AbstractMesh, scene: Scene,
  101204. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101205. autoUpdateBonesMatrices?: boolean,
  101206. /** defines the rendering group id to use with the viewer */
  101207. renderingGroupId?: number);
  101208. /** Gets or sets a boolean indicating if the viewer is enabled */
  101209. isEnabled: boolean;
  101210. private _getBonePosition;
  101211. private _getLinesForBonesWithLength;
  101212. private _getLinesForBonesNoLength;
  101213. /** Update the viewer to sync with current skeleton state */
  101214. update(): void;
  101215. /** Release associated resources */
  101216. dispose(): void;
  101217. }
  101218. }
  101219. declare module BABYLON {
  101220. /**
  101221. * Options to create the null engine
  101222. */
  101223. export class NullEngineOptions {
  101224. /**
  101225. * Render width (Default: 512)
  101226. */
  101227. renderWidth: number;
  101228. /**
  101229. * Render height (Default: 256)
  101230. */
  101231. renderHeight: number;
  101232. /**
  101233. * Texture size (Default: 512)
  101234. */
  101235. textureSize: number;
  101236. /**
  101237. * If delta time between frames should be constant
  101238. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101239. */
  101240. deterministicLockstep: boolean;
  101241. /**
  101242. * Maximum about of steps between frames (Default: 4)
  101243. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101244. */
  101245. lockstepMaxSteps: number;
  101246. }
  101247. /**
  101248. * The null engine class provides support for headless version of babylon.js.
  101249. * This can be used in server side scenario or for testing purposes
  101250. */
  101251. export class NullEngine extends Engine {
  101252. private _options;
  101253. /**
  101254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101255. */
  101256. isDeterministicLockStep(): boolean;
  101257. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101258. getLockstepMaxSteps(): number;
  101259. /**
  101260. * Sets hardware scaling, used to save performance if needed
  101261. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101262. */
  101263. getHardwareScalingLevel(): number;
  101264. constructor(options?: NullEngineOptions);
  101265. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101266. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101267. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101268. getRenderWidth(useScreen?: boolean): number;
  101269. getRenderHeight(useScreen?: boolean): number;
  101270. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101272. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101274. bindSamplers(effect: Effect): void;
  101275. enableEffect(effect: Effect): void;
  101276. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101277. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101278. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101279. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101280. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101281. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101282. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101283. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101284. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101285. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101286. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101287. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101288. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101289. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101290. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101291. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101292. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101293. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101294. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101295. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101296. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101297. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101298. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101299. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101300. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101301. bindBuffers(vertexBuffers: {
  101302. [key: string]: VertexBuffer;
  101303. }, indexBuffer: DataBuffer, effect: Effect): void;
  101304. wipeCaches(bruteForce?: boolean): void;
  101305. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101306. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101307. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101308. /** @hidden */
  101309. _createTexture(): WebGLTexture;
  101310. /** @hidden */
  101311. _releaseTexture(texture: InternalTexture): void;
  101312. 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;
  101313. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101314. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101315. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101316. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101317. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101318. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101319. areAllEffectsReady(): boolean;
  101320. /**
  101321. * @hidden
  101322. * Get the current error code of the webGL context
  101323. * @returns the error code
  101324. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101325. */
  101326. getError(): number;
  101327. /** @hidden */
  101328. _getUnpackAlignement(): number;
  101329. /** @hidden */
  101330. _unpackFlipY(value: boolean): void;
  101331. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101332. /**
  101333. * Updates a dynamic vertex buffer.
  101334. * @param vertexBuffer the vertex buffer to update
  101335. * @param data the data used to update the vertex buffer
  101336. * @param byteOffset the byte offset of the data (optional)
  101337. * @param byteLength the byte length of the data (optional)
  101338. */
  101339. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101340. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101341. /** @hidden */
  101342. _bindTexture(channel: number, texture: InternalTexture): void;
  101343. /** @hidden */
  101344. _releaseBuffer(buffer: DataBuffer): boolean;
  101345. releaseEffects(): void;
  101346. displayLoadingUI(): void;
  101347. hideLoadingUI(): void;
  101348. /** @hidden */
  101349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101350. /** @hidden */
  101351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101352. /** @hidden */
  101353. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101354. /** @hidden */
  101355. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101356. }
  101357. }
  101358. declare module BABYLON {
  101359. /** @hidden */
  101360. export class _OcclusionDataStorage {
  101361. /** @hidden */
  101362. occlusionInternalRetryCounter: number;
  101363. /** @hidden */
  101364. isOcclusionQueryInProgress: boolean;
  101365. /** @hidden */
  101366. isOccluded: boolean;
  101367. /** @hidden */
  101368. occlusionRetryCount: number;
  101369. /** @hidden */
  101370. occlusionType: number;
  101371. /** @hidden */
  101372. occlusionQueryAlgorithmType: number;
  101373. }
  101374. interface Engine {
  101375. /**
  101376. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101377. * @return the new query
  101378. */
  101379. createQuery(): WebGLQuery;
  101380. /**
  101381. * Delete and release a webGL query
  101382. * @param query defines the query to delete
  101383. * @return the current engine
  101384. */
  101385. deleteQuery(query: WebGLQuery): Engine;
  101386. /**
  101387. * Check if a given query has resolved and got its value
  101388. * @param query defines the query to check
  101389. * @returns true if the query got its value
  101390. */
  101391. isQueryResultAvailable(query: WebGLQuery): boolean;
  101392. /**
  101393. * Gets the value of a given query
  101394. * @param query defines the query to check
  101395. * @returns the value of the query
  101396. */
  101397. getQueryResult(query: WebGLQuery): number;
  101398. /**
  101399. * Initiates an occlusion query
  101400. * @param algorithmType defines the algorithm to use
  101401. * @param query defines the query to use
  101402. * @returns the current engine
  101403. * @see http://doc.babylonjs.com/features/occlusionquery
  101404. */
  101405. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101406. /**
  101407. * Ends an occlusion query
  101408. * @see http://doc.babylonjs.com/features/occlusionquery
  101409. * @param algorithmType defines the algorithm to use
  101410. * @returns the current engine
  101411. */
  101412. endOcclusionQuery(algorithmType: number): Engine;
  101413. /**
  101414. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101415. * Please note that only one query can be issued at a time
  101416. * @returns a time token used to track the time span
  101417. */
  101418. startTimeQuery(): Nullable<_TimeToken>;
  101419. /**
  101420. * Ends a time query
  101421. * @param token defines the token used to measure the time span
  101422. * @returns the time spent (in ns)
  101423. */
  101424. endTimeQuery(token: _TimeToken): int;
  101425. /** @hidden */
  101426. _currentNonTimestampToken: Nullable<_TimeToken>;
  101427. /** @hidden */
  101428. _createTimeQuery(): WebGLQuery;
  101429. /** @hidden */
  101430. _deleteTimeQuery(query: WebGLQuery): void;
  101431. /** @hidden */
  101432. _getGlAlgorithmType(algorithmType: number): number;
  101433. /** @hidden */
  101434. _getTimeQueryResult(query: WebGLQuery): any;
  101435. /** @hidden */
  101436. _getTimeQueryAvailability(query: WebGLQuery): any;
  101437. }
  101438. interface AbstractMesh {
  101439. /**
  101440. * Backing filed
  101441. * @hidden
  101442. */
  101443. __occlusionDataStorage: _OcclusionDataStorage;
  101444. /**
  101445. * Access property
  101446. * @hidden
  101447. */
  101448. _occlusionDataStorage: _OcclusionDataStorage;
  101449. /**
  101450. * 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.
  101451. * The default value is -1 which means don't break the query and wait till the result
  101452. * @see http://doc.babylonjs.com/features/occlusionquery
  101453. */
  101454. occlusionRetryCount: number;
  101455. /**
  101456. * 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:
  101457. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101458. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101459. * * 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.
  101460. * @see http://doc.babylonjs.com/features/occlusionquery
  101461. */
  101462. occlusionType: number;
  101463. /**
  101464. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101465. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101466. * * 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.
  101467. * @see http://doc.babylonjs.com/features/occlusionquery
  101468. */
  101469. occlusionQueryAlgorithmType: number;
  101470. /**
  101471. * 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
  101472. * @see http://doc.babylonjs.com/features/occlusionquery
  101473. */
  101474. isOccluded: boolean;
  101475. /**
  101476. * Flag to check the progress status of the query
  101477. * @see http://doc.babylonjs.com/features/occlusionquery
  101478. */
  101479. isOcclusionQueryInProgress: boolean;
  101480. }
  101481. }
  101482. declare module BABYLON {
  101483. /** @hidden */
  101484. export var _forceTransformFeedbackToBundle: boolean;
  101485. interface Engine {
  101486. /**
  101487. * Creates a webGL transform feedback object
  101488. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101489. * @returns the webGL transform feedback object
  101490. */
  101491. createTransformFeedback(): WebGLTransformFeedback;
  101492. /**
  101493. * Delete a webGL transform feedback object
  101494. * @param value defines the webGL transform feedback object to delete
  101495. */
  101496. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101497. /**
  101498. * Bind a webGL transform feedback object to the webgl context
  101499. * @param value defines the webGL transform feedback object to bind
  101500. */
  101501. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101502. /**
  101503. * Begins a transform feedback operation
  101504. * @param usePoints defines if points or triangles must be used
  101505. */
  101506. beginTransformFeedback(usePoints: boolean): void;
  101507. /**
  101508. * Ends a transform feedback operation
  101509. */
  101510. endTransformFeedback(): void;
  101511. /**
  101512. * Specify the varyings to use with transform feedback
  101513. * @param program defines the associated webGL program
  101514. * @param value defines the list of strings representing the varying names
  101515. */
  101516. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101517. /**
  101518. * Bind a webGL buffer for a transform feedback operation
  101519. * @param value defines the webGL buffer to bind
  101520. */
  101521. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101522. }
  101523. }
  101524. declare module BABYLON {
  101525. /**
  101526. * Creation options of the multi render target texture.
  101527. */
  101528. export interface IMultiRenderTargetOptions {
  101529. /**
  101530. * Define if the texture needs to create mip maps after render.
  101531. */
  101532. generateMipMaps?: boolean;
  101533. /**
  101534. * Define the types of all the draw buffers we want to create
  101535. */
  101536. types?: number[];
  101537. /**
  101538. * Define the sampling modes of all the draw buffers we want to create
  101539. */
  101540. samplingModes?: number[];
  101541. /**
  101542. * Define if a depth buffer is required
  101543. */
  101544. generateDepthBuffer?: boolean;
  101545. /**
  101546. * Define if a stencil buffer is required
  101547. */
  101548. generateStencilBuffer?: boolean;
  101549. /**
  101550. * Define if a depth texture is required instead of a depth buffer
  101551. */
  101552. generateDepthTexture?: boolean;
  101553. /**
  101554. * Define the number of desired draw buffers
  101555. */
  101556. textureCount?: number;
  101557. /**
  101558. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101559. */
  101560. doNotChangeAspectRatio?: boolean;
  101561. /**
  101562. * Define the default type of the buffers we are creating
  101563. */
  101564. defaultType?: number;
  101565. }
  101566. /**
  101567. * A multi render target, like a render target provides the ability to render to a texture.
  101568. * Unlike the render target, it can render to several draw buffers in one draw.
  101569. * This is specially interesting in deferred rendering or for any effects requiring more than
  101570. * just one color from a single pass.
  101571. */
  101572. export class MultiRenderTarget extends RenderTargetTexture {
  101573. private _internalTextures;
  101574. private _textures;
  101575. private _multiRenderTargetOptions;
  101576. /**
  101577. * Get if draw buffers are currently supported by the used hardware and browser.
  101578. */
  101579. readonly isSupported: boolean;
  101580. /**
  101581. * Get the list of textures generated by the multi render target.
  101582. */
  101583. readonly textures: Texture[];
  101584. /**
  101585. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101586. */
  101587. readonly depthTexture: Texture;
  101588. /**
  101589. * Set the wrapping mode on U of all the textures we are rendering to.
  101590. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101591. */
  101592. wrapU: number;
  101593. /**
  101594. * Set the wrapping mode on V of all the textures we are rendering to.
  101595. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101596. */
  101597. wrapV: number;
  101598. /**
  101599. * Instantiate a new multi render target texture.
  101600. * A multi render target, like a render target provides the ability to render to a texture.
  101601. * Unlike the render target, it can render to several draw buffers in one draw.
  101602. * This is specially interesting in deferred rendering or for any effects requiring more than
  101603. * just one color from a single pass.
  101604. * @param name Define the name of the texture
  101605. * @param size Define the size of the buffers to render to
  101606. * @param count Define the number of target we are rendering into
  101607. * @param scene Define the scene the texture belongs to
  101608. * @param options Define the options used to create the multi render target
  101609. */
  101610. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101611. /** @hidden */
  101612. _rebuild(): void;
  101613. private _createInternalTextures;
  101614. private _createTextures;
  101615. /**
  101616. * Define the number of samples used if MSAA is enabled.
  101617. */
  101618. samples: number;
  101619. /**
  101620. * Resize all the textures in the multi render target.
  101621. * Be carrefull as it will recreate all the data in the new texture.
  101622. * @param size Define the new size
  101623. */
  101624. resize(size: any): void;
  101625. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101626. /**
  101627. * Dispose the render targets and their associated resources
  101628. */
  101629. dispose(): void;
  101630. /**
  101631. * Release all the underlying texture used as draw buffers.
  101632. */
  101633. releaseInternalTextures(): void;
  101634. }
  101635. }
  101636. declare module BABYLON {
  101637. interface Engine {
  101638. /**
  101639. * Unbind a list of render target textures from the webGL context
  101640. * This is used only when drawBuffer extension or webGL2 are active
  101641. * @param textures defines the render target textures to unbind
  101642. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101643. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101644. */
  101645. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101646. /**
  101647. * Create a multi render target texture
  101648. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101649. * @param size defines the size of the texture
  101650. * @param options defines the creation options
  101651. * @returns the cube texture as an InternalTexture
  101652. */
  101653. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101654. /**
  101655. * Update the sample count for a given multiple render target texture
  101656. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101657. * @param textures defines the textures to update
  101658. * @param samples defines the sample count to set
  101659. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101660. */
  101661. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101662. }
  101663. }
  101664. declare module BABYLON {
  101665. /**
  101666. * Gather the list of clipboard event types as constants.
  101667. */
  101668. export class ClipboardEventTypes {
  101669. /**
  101670. * The clipboard event is fired when a copy command is active (pressed).
  101671. */
  101672. static readonly COPY: number;
  101673. /**
  101674. * The clipboard event is fired when a cut command is active (pressed).
  101675. */
  101676. static readonly CUT: number;
  101677. /**
  101678. * The clipboard event is fired when a paste command is active (pressed).
  101679. */
  101680. static readonly PASTE: number;
  101681. }
  101682. /**
  101683. * This class is used to store clipboard related info for the onClipboardObservable event.
  101684. */
  101685. export class ClipboardInfo {
  101686. /**
  101687. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101688. */
  101689. type: number;
  101690. /**
  101691. * Defines the related dom event
  101692. */
  101693. event: ClipboardEvent;
  101694. /**
  101695. *Creates an instance of ClipboardInfo.
  101696. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101697. * @param event Defines the related dom event
  101698. */
  101699. constructor(
  101700. /**
  101701. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101702. */
  101703. type: number,
  101704. /**
  101705. * Defines the related dom event
  101706. */
  101707. event: ClipboardEvent);
  101708. /**
  101709. * Get the clipboard event's type from the keycode.
  101710. * @param keyCode Defines the keyCode for the current keyboard event.
  101711. * @return {number}
  101712. */
  101713. static GetTypeFromCharacter(keyCode: number): number;
  101714. }
  101715. }
  101716. declare module BABYLON {
  101717. /**
  101718. * Class used to represent data loading progression
  101719. */
  101720. export class SceneLoaderProgressEvent {
  101721. /** defines if data length to load can be evaluated */
  101722. readonly lengthComputable: boolean;
  101723. /** defines the loaded data length */
  101724. readonly loaded: number;
  101725. /** defines the data length to load */
  101726. readonly total: number;
  101727. /**
  101728. * Create a new progress event
  101729. * @param lengthComputable defines if data length to load can be evaluated
  101730. * @param loaded defines the loaded data length
  101731. * @param total defines the data length to load
  101732. */
  101733. constructor(
  101734. /** defines if data length to load can be evaluated */
  101735. lengthComputable: boolean,
  101736. /** defines the loaded data length */
  101737. loaded: number,
  101738. /** defines the data length to load */
  101739. total: number);
  101740. /**
  101741. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101742. * @param event defines the source event
  101743. * @returns a new SceneLoaderProgressEvent
  101744. */
  101745. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101746. }
  101747. /**
  101748. * Interface used by SceneLoader plugins to define supported file extensions
  101749. */
  101750. export interface ISceneLoaderPluginExtensions {
  101751. /**
  101752. * Defines the list of supported extensions
  101753. */
  101754. [extension: string]: {
  101755. isBinary: boolean;
  101756. };
  101757. }
  101758. /**
  101759. * Interface used by SceneLoader plugin factory
  101760. */
  101761. export interface ISceneLoaderPluginFactory {
  101762. /**
  101763. * Defines the name of the factory
  101764. */
  101765. name: string;
  101766. /**
  101767. * Function called to create a new plugin
  101768. * @return the new plugin
  101769. */
  101770. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101771. /**
  101772. * Boolean indicating if the plugin can direct load specific data
  101773. */
  101774. canDirectLoad?: (data: string) => boolean;
  101775. }
  101776. /**
  101777. * Interface used to define a SceneLoader plugin
  101778. */
  101779. export interface ISceneLoaderPlugin {
  101780. /**
  101781. * The friendly name of this plugin.
  101782. */
  101783. name: string;
  101784. /**
  101785. * The file extensions supported by this plugin.
  101786. */
  101787. extensions: string | ISceneLoaderPluginExtensions;
  101788. /**
  101789. * Import meshes into a scene.
  101790. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101791. * @param scene The scene to import into
  101792. * @param data The data to import
  101793. * @param rootUrl The root url for scene and resources
  101794. * @param meshes The meshes array to import into
  101795. * @param particleSystems The particle systems array to import into
  101796. * @param skeletons The skeletons array to import into
  101797. * @param onError The callback when import fails
  101798. * @returns True if successful or false otherwise
  101799. */
  101800. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101801. /**
  101802. * Load into a scene.
  101803. * @param scene The scene to load into
  101804. * @param data The data to import
  101805. * @param rootUrl The root url for scene and resources
  101806. * @param onError The callback when import fails
  101807. * @returns true if successful or false otherwise
  101808. */
  101809. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101810. /**
  101811. * The callback that returns true if the data can be directly loaded.
  101812. */
  101813. canDirectLoad?: (data: string) => boolean;
  101814. /**
  101815. * The callback that allows custom handling of the root url based on the response url.
  101816. */
  101817. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101818. /**
  101819. * Load into an asset container.
  101820. * @param scene The scene to load into
  101821. * @param data The data to import
  101822. * @param rootUrl The root url for scene and resources
  101823. * @param onError The callback when import fails
  101824. * @returns The loaded asset container
  101825. */
  101826. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101827. }
  101828. /**
  101829. * Interface used to define an async SceneLoader plugin
  101830. */
  101831. export interface ISceneLoaderPluginAsync {
  101832. /**
  101833. * The friendly name of this plugin.
  101834. */
  101835. name: string;
  101836. /**
  101837. * The file extensions supported by this plugin.
  101838. */
  101839. extensions: string | ISceneLoaderPluginExtensions;
  101840. /**
  101841. * Import meshes into a scene.
  101842. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101843. * @param scene The scene to import into
  101844. * @param data The data to import
  101845. * @param rootUrl The root url for scene and resources
  101846. * @param onProgress The callback when the load progresses
  101847. * @param fileName Defines the name of the file to load
  101848. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101849. */
  101850. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101851. meshes: AbstractMesh[];
  101852. particleSystems: IParticleSystem[];
  101853. skeletons: Skeleton[];
  101854. animationGroups: AnimationGroup[];
  101855. }>;
  101856. /**
  101857. * Load into a scene.
  101858. * @param scene The scene to load into
  101859. * @param data The data to import
  101860. * @param rootUrl The root url for scene and resources
  101861. * @param onProgress The callback when the load progresses
  101862. * @param fileName Defines the name of the file to load
  101863. * @returns Nothing
  101864. */
  101865. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101866. /**
  101867. * The callback that returns true if the data can be directly loaded.
  101868. */
  101869. canDirectLoad?: (data: string) => boolean;
  101870. /**
  101871. * The callback that allows custom handling of the root url based on the response url.
  101872. */
  101873. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101874. /**
  101875. * Load into an asset container.
  101876. * @param scene The scene to load into
  101877. * @param data The data to import
  101878. * @param rootUrl The root url for scene and resources
  101879. * @param onProgress The callback when the load progresses
  101880. * @param fileName Defines the name of the file to load
  101881. * @returns The loaded asset container
  101882. */
  101883. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101884. }
  101885. /**
  101886. * Class used to load scene from various file formats using registered plugins
  101887. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101888. */
  101889. export class SceneLoader {
  101890. /**
  101891. * No logging while loading
  101892. */
  101893. static readonly NO_LOGGING: number;
  101894. /**
  101895. * Minimal logging while loading
  101896. */
  101897. static readonly MINIMAL_LOGGING: number;
  101898. /**
  101899. * Summary logging while loading
  101900. */
  101901. static readonly SUMMARY_LOGGING: number;
  101902. /**
  101903. * Detailled logging while loading
  101904. */
  101905. static readonly DETAILED_LOGGING: number;
  101906. /**
  101907. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101908. */
  101909. static ForceFullSceneLoadingForIncremental: boolean;
  101910. /**
  101911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101912. */
  101913. static ShowLoadingScreen: boolean;
  101914. /**
  101915. * Defines the current logging level (while loading the scene)
  101916. * @ignorenaming
  101917. */
  101918. static loggingLevel: number;
  101919. /**
  101920. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101921. */
  101922. static CleanBoneMatrixWeights: boolean;
  101923. /**
  101924. * Event raised when a plugin is used to load a scene
  101925. */
  101926. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101927. private static _registeredPlugins;
  101928. private static _getDefaultPlugin;
  101929. private static _getPluginForExtension;
  101930. private static _getPluginForDirectLoad;
  101931. private static _getPluginForFilename;
  101932. private static _getDirectLoad;
  101933. private static _loadData;
  101934. private static _getFileInfo;
  101935. /**
  101936. * Gets a plugin that can load the given extension
  101937. * @param extension defines the extension to load
  101938. * @returns a plugin or null if none works
  101939. */
  101940. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101941. /**
  101942. * Gets a boolean indicating that the given extension can be loaded
  101943. * @param extension defines the extension to load
  101944. * @returns true if the extension is supported
  101945. */
  101946. static IsPluginForExtensionAvailable(extension: string): boolean;
  101947. /**
  101948. * Adds a new plugin to the list of registered plugins
  101949. * @param plugin defines the plugin to add
  101950. */
  101951. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101952. /**
  101953. * Import meshes into a scene
  101954. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101955. * @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)
  101956. * @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)
  101957. * @param scene the instance of BABYLON.Scene to append to
  101958. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101959. * @param onProgress a callback with a progress event for each file being loaded
  101960. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101961. * @param pluginExtension the extension used to determine the plugin
  101962. * @returns The loaded plugin
  101963. */
  101964. 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>;
  101965. /**
  101966. * Import meshes into a scene
  101967. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101968. * @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)
  101969. * @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)
  101970. * @param scene the instance of BABYLON.Scene to append to
  101971. * @param onProgress a callback with a progress event for each file being loaded
  101972. * @param pluginExtension the extension used to determine the plugin
  101973. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101974. */
  101975. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101976. meshes: AbstractMesh[];
  101977. particleSystems: IParticleSystem[];
  101978. skeletons: Skeleton[];
  101979. animationGroups: AnimationGroup[];
  101980. }>;
  101981. /**
  101982. * Load a scene
  101983. * @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)
  101984. * @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)
  101985. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101986. * @param onSuccess a callback with the scene when import succeeds
  101987. * @param onProgress a callback with a progress event for each file being loaded
  101988. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101989. * @param pluginExtension the extension used to determine the plugin
  101990. * @returns The loaded plugin
  101991. */
  101992. 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>;
  101993. /**
  101994. * Load a scene
  101995. * @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)
  101996. * @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)
  101997. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101998. * @param onProgress a callback with a progress event for each file being loaded
  101999. * @param pluginExtension the extension used to determine the plugin
  102000. * @returns The loaded scene
  102001. */
  102002. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102003. /**
  102004. * Append a scene
  102005. * @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)
  102006. * @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)
  102007. * @param scene is the instance of BABYLON.Scene to append to
  102008. * @param onSuccess a callback with the scene when import succeeds
  102009. * @param onProgress a callback with a progress event for each file being loaded
  102010. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102011. * @param pluginExtension the extension used to determine the plugin
  102012. * @returns The loaded plugin
  102013. */
  102014. 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>;
  102015. /**
  102016. * Append a scene
  102017. * @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)
  102018. * @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)
  102019. * @param scene is the instance of BABYLON.Scene to append to
  102020. * @param onProgress a callback with a progress event for each file being loaded
  102021. * @param pluginExtension the extension used to determine the plugin
  102022. * @returns The given scene
  102023. */
  102024. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102025. /**
  102026. * Load a scene into an asset container
  102027. * @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)
  102028. * @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)
  102029. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102030. * @param onSuccess a callback with the scene when import succeeds
  102031. * @param onProgress a callback with a progress event for each file being loaded
  102032. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102033. * @param pluginExtension the extension used to determine the plugin
  102034. * @returns The loaded plugin
  102035. */
  102036. 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>;
  102037. /**
  102038. * Load a scene into an asset container
  102039. * @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)
  102040. * @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)
  102041. * @param scene is the instance of Scene to append to
  102042. * @param onProgress a callback with a progress event for each file being loaded
  102043. * @param pluginExtension the extension used to determine the plugin
  102044. * @returns The loaded asset container
  102045. */
  102046. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102047. }
  102048. }
  102049. declare module BABYLON {
  102050. /**
  102051. * Google Daydream controller
  102052. */
  102053. export class DaydreamController extends WebVRController {
  102054. /**
  102055. * Base Url for the controller model.
  102056. */
  102057. static MODEL_BASE_URL: string;
  102058. /**
  102059. * File name for the controller model.
  102060. */
  102061. static MODEL_FILENAME: string;
  102062. /**
  102063. * Gamepad Id prefix used to identify Daydream Controller.
  102064. */
  102065. static readonly GAMEPAD_ID_PREFIX: string;
  102066. /**
  102067. * Creates a new DaydreamController from a gamepad
  102068. * @param vrGamepad the gamepad that the controller should be created from
  102069. */
  102070. constructor(vrGamepad: any);
  102071. /**
  102072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102073. * @param scene scene in which to add meshes
  102074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102075. */
  102076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102077. /**
  102078. * Called once for each button that changed state since the last frame
  102079. * @param buttonIdx Which button index changed
  102080. * @param state New state of the button
  102081. * @param changes Which properties on the state changed since last frame
  102082. */
  102083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102084. }
  102085. }
  102086. declare module BABYLON {
  102087. /**
  102088. * Gear VR Controller
  102089. */
  102090. export class GearVRController extends WebVRController {
  102091. /**
  102092. * Base Url for the controller model.
  102093. */
  102094. static MODEL_BASE_URL: string;
  102095. /**
  102096. * File name for the controller model.
  102097. */
  102098. static MODEL_FILENAME: string;
  102099. /**
  102100. * Gamepad Id prefix used to identify this controller.
  102101. */
  102102. static readonly GAMEPAD_ID_PREFIX: string;
  102103. private readonly _buttonIndexToObservableNameMap;
  102104. /**
  102105. * Creates a new GearVRController from a gamepad
  102106. * @param vrGamepad the gamepad that the controller should be created from
  102107. */
  102108. constructor(vrGamepad: any);
  102109. /**
  102110. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102111. * @param scene scene in which to add meshes
  102112. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102113. */
  102114. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102115. /**
  102116. * Called once for each button that changed state since the last frame
  102117. * @param buttonIdx Which button index changed
  102118. * @param state New state of the button
  102119. * @param changes Which properties on the state changed since last frame
  102120. */
  102121. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102122. }
  102123. }
  102124. declare module BABYLON {
  102125. /**
  102126. * Generic Controller
  102127. */
  102128. export class GenericController extends WebVRController {
  102129. /**
  102130. * Base Url for the controller model.
  102131. */
  102132. static readonly MODEL_BASE_URL: string;
  102133. /**
  102134. * File name for the controller model.
  102135. */
  102136. static readonly MODEL_FILENAME: string;
  102137. /**
  102138. * Creates a new GenericController from a gamepad
  102139. * @param vrGamepad the gamepad that the controller should be created from
  102140. */
  102141. constructor(vrGamepad: any);
  102142. /**
  102143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102144. * @param scene scene in which to add meshes
  102145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102146. */
  102147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102148. /**
  102149. * Called once for each button that changed state since the last frame
  102150. * @param buttonIdx Which button index changed
  102151. * @param state New state of the button
  102152. * @param changes Which properties on the state changed since last frame
  102153. */
  102154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102155. }
  102156. }
  102157. declare module BABYLON {
  102158. /**
  102159. * Oculus Touch Controller
  102160. */
  102161. export class OculusTouchController extends WebVRController {
  102162. /**
  102163. * Base Url for the controller model.
  102164. */
  102165. static MODEL_BASE_URL: string;
  102166. /**
  102167. * File name for the left controller model.
  102168. */
  102169. static MODEL_LEFT_FILENAME: string;
  102170. /**
  102171. * File name for the right controller model.
  102172. */
  102173. static MODEL_RIGHT_FILENAME: string;
  102174. /**
  102175. * Fired when the secondary trigger on this controller is modified
  102176. */
  102177. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102178. /**
  102179. * Fired when the thumb rest on this controller is modified
  102180. */
  102181. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102182. /**
  102183. * Creates a new OculusTouchController from a gamepad
  102184. * @param vrGamepad the gamepad that the controller should be created from
  102185. */
  102186. constructor(vrGamepad: any);
  102187. /**
  102188. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102189. * @param scene scene in which to add meshes
  102190. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102191. */
  102192. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102193. /**
  102194. * Fired when the A button on this controller is modified
  102195. */
  102196. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102197. /**
  102198. * Fired when the B button on this controller is modified
  102199. */
  102200. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102201. /**
  102202. * Fired when the X button on this controller is modified
  102203. */
  102204. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102205. /**
  102206. * Fired when the Y button on this controller is modified
  102207. */
  102208. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102209. /**
  102210. * Called once for each button that changed state since the last frame
  102211. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102212. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102213. * 2) secondary trigger (same)
  102214. * 3) A (right) X (left), touch, pressed = value
  102215. * 4) B / Y
  102216. * 5) thumb rest
  102217. * @param buttonIdx Which button index changed
  102218. * @param state New state of the button
  102219. * @param changes Which properties on the state changed since last frame
  102220. */
  102221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102222. }
  102223. }
  102224. declare module BABYLON {
  102225. /**
  102226. * Vive Controller
  102227. */
  102228. export class ViveController extends WebVRController {
  102229. /**
  102230. * Base Url for the controller model.
  102231. */
  102232. static MODEL_BASE_URL: string;
  102233. /**
  102234. * File name for the controller model.
  102235. */
  102236. static MODEL_FILENAME: string;
  102237. /**
  102238. * Creates a new ViveController from a gamepad
  102239. * @param vrGamepad the gamepad that the controller should be created from
  102240. */
  102241. constructor(vrGamepad: any);
  102242. /**
  102243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102244. * @param scene scene in which to add meshes
  102245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102246. */
  102247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102248. /**
  102249. * Fired when the left button on this controller is modified
  102250. */
  102251. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102252. /**
  102253. * Fired when the right button on this controller is modified
  102254. */
  102255. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102256. /**
  102257. * Fired when the menu button on this controller is modified
  102258. */
  102259. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102260. /**
  102261. * Called once for each button that changed state since the last frame
  102262. * Vive mapping:
  102263. * 0: touchpad
  102264. * 1: trigger
  102265. * 2: left AND right buttons
  102266. * 3: menu button
  102267. * @param buttonIdx Which button index changed
  102268. * @param state New state of the button
  102269. * @param changes Which properties on the state changed since last frame
  102270. */
  102271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102272. }
  102273. }
  102274. declare module BABYLON {
  102275. /**
  102276. * Defines the WindowsMotionController object that the state of the windows motion controller
  102277. */
  102278. export class WindowsMotionController extends WebVRController {
  102279. /**
  102280. * The base url used to load the left and right controller models
  102281. */
  102282. static MODEL_BASE_URL: string;
  102283. /**
  102284. * The name of the left controller model file
  102285. */
  102286. static MODEL_LEFT_FILENAME: string;
  102287. /**
  102288. * The name of the right controller model file
  102289. */
  102290. static MODEL_RIGHT_FILENAME: string;
  102291. /**
  102292. * The controller name prefix for this controller type
  102293. */
  102294. static readonly GAMEPAD_ID_PREFIX: string;
  102295. /**
  102296. * The controller id pattern for this controller type
  102297. */
  102298. private static readonly GAMEPAD_ID_PATTERN;
  102299. private _loadedMeshInfo;
  102300. private readonly _mapping;
  102301. /**
  102302. * Fired when the trackpad on this controller is clicked
  102303. */
  102304. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102305. /**
  102306. * Fired when the trackpad on this controller is modified
  102307. */
  102308. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102309. /**
  102310. * The current x and y values of this controller's trackpad
  102311. */
  102312. trackpad: StickValues;
  102313. /**
  102314. * Creates a new WindowsMotionController from a gamepad
  102315. * @param vrGamepad the gamepad that the controller should be created from
  102316. */
  102317. constructor(vrGamepad: any);
  102318. /**
  102319. * Fired when the trigger on this controller is modified
  102320. */
  102321. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102322. /**
  102323. * Fired when the menu button on this controller is modified
  102324. */
  102325. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102326. /**
  102327. * Fired when the grip button on this controller is modified
  102328. */
  102329. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102330. /**
  102331. * Fired when the thumbstick button on this controller is modified
  102332. */
  102333. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102334. /**
  102335. * Fired when the touchpad button on this controller is modified
  102336. */
  102337. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102338. /**
  102339. * Fired when the touchpad values on this controller are modified
  102340. */
  102341. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102342. private _updateTrackpad;
  102343. /**
  102344. * Called once per frame by the engine.
  102345. */
  102346. update(): void;
  102347. /**
  102348. * Called once for each button that changed state since the last frame
  102349. * @param buttonIdx Which button index changed
  102350. * @param state New state of the button
  102351. * @param changes Which properties on the state changed since last frame
  102352. */
  102353. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102354. /**
  102355. * Moves the buttons on the controller mesh based on their current state
  102356. * @param buttonName the name of the button to move
  102357. * @param buttonValue the value of the button which determines the buttons new position
  102358. */
  102359. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102360. /**
  102361. * Moves the axis on the controller mesh based on its current state
  102362. * @param axis the index of the axis
  102363. * @param axisValue the value of the axis which determines the meshes new position
  102364. * @hidden
  102365. */
  102366. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102367. /**
  102368. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102369. * @param scene scene in which to add meshes
  102370. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102371. */
  102372. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102373. /**
  102374. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102375. * can be transformed by button presses and axes values, based on this._mapping.
  102376. *
  102377. * @param scene scene in which the meshes exist
  102378. * @param meshes list of meshes that make up the controller model to process
  102379. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102380. */
  102381. private processModel;
  102382. private createMeshInfo;
  102383. /**
  102384. * Gets the ray of the controller in the direction the controller is pointing
  102385. * @param length the length the resulting ray should be
  102386. * @returns a ray in the direction the controller is pointing
  102387. */
  102388. getForwardRay(length?: number): Ray;
  102389. /**
  102390. * Disposes of the controller
  102391. */
  102392. dispose(): void;
  102393. }
  102394. }
  102395. declare module BABYLON {
  102396. /**
  102397. * Single axis scale gizmo
  102398. */
  102399. export class AxisScaleGizmo extends Gizmo {
  102400. private _coloredMaterial;
  102401. /**
  102402. * Drag behavior responsible for the gizmos dragging interactions
  102403. */
  102404. dragBehavior: PointerDragBehavior;
  102405. private _pointerObserver;
  102406. /**
  102407. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102408. */
  102409. snapDistance: number;
  102410. /**
  102411. * Event that fires each time the gizmo snaps to a new location.
  102412. * * snapDistance is the the change in distance
  102413. */
  102414. onSnapObservable: Observable<{
  102415. snapDistance: number;
  102416. }>;
  102417. /**
  102418. * If the scaling operation should be done on all axis (default: false)
  102419. */
  102420. uniformScaling: boolean;
  102421. /**
  102422. * Creates an AxisScaleGizmo
  102423. * @param gizmoLayer The utility layer the gizmo will be added to
  102424. * @param dragAxis The axis which the gizmo will be able to scale on
  102425. * @param color The color of the gizmo
  102426. */
  102427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102428. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102429. /**
  102430. * Disposes of the gizmo
  102431. */
  102432. dispose(): void;
  102433. /**
  102434. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102435. * @param mesh The mesh to replace the default mesh of the gizmo
  102436. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102437. */
  102438. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102439. }
  102440. }
  102441. declare module BABYLON {
  102442. /**
  102443. * Bounding box gizmo
  102444. */
  102445. export class BoundingBoxGizmo extends Gizmo {
  102446. private _lineBoundingBox;
  102447. private _rotateSpheresParent;
  102448. private _scaleBoxesParent;
  102449. private _boundingDimensions;
  102450. private _renderObserver;
  102451. private _pointerObserver;
  102452. private _scaleDragSpeed;
  102453. private _tmpQuaternion;
  102454. private _tmpVector;
  102455. private _tmpRotationMatrix;
  102456. /**
  102457. * 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)
  102458. */
  102459. ignoreChildren: boolean;
  102460. /**
  102461. * 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)
  102462. */
  102463. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102464. /**
  102465. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102466. */
  102467. rotationSphereSize: number;
  102468. /**
  102469. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102470. */
  102471. scaleBoxSize: number;
  102472. /**
  102473. * 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)
  102474. */
  102475. fixedDragMeshScreenSize: boolean;
  102476. /**
  102477. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102478. */
  102479. fixedDragMeshScreenSizeDistanceFactor: number;
  102480. /**
  102481. * Fired when a rotation sphere or scale box is dragged
  102482. */
  102483. onDragStartObservable: Observable<{}>;
  102484. /**
  102485. * Fired when a scale box is dragged
  102486. */
  102487. onScaleBoxDragObservable: Observable<{}>;
  102488. /**
  102489. * Fired when a scale box drag is ended
  102490. */
  102491. onScaleBoxDragEndObservable: Observable<{}>;
  102492. /**
  102493. * Fired when a rotation sphere is dragged
  102494. */
  102495. onRotationSphereDragObservable: Observable<{}>;
  102496. /**
  102497. * Fired when a rotation sphere drag is ended
  102498. */
  102499. onRotationSphereDragEndObservable: Observable<{}>;
  102500. /**
  102501. * 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)
  102502. */
  102503. scalePivot: Nullable<Vector3>;
  102504. /**
  102505. * Mesh used as a pivot to rotate the attached mesh
  102506. */
  102507. private _anchorMesh;
  102508. private _existingMeshScale;
  102509. private _dragMesh;
  102510. private pointerDragBehavior;
  102511. private coloredMaterial;
  102512. private hoverColoredMaterial;
  102513. /**
  102514. * Sets the color of the bounding box gizmo
  102515. * @param color the color to set
  102516. */
  102517. setColor(color: Color3): void;
  102518. /**
  102519. * Creates an BoundingBoxGizmo
  102520. * @param gizmoLayer The utility layer the gizmo will be added to
  102521. * @param color The color of the gizmo
  102522. */
  102523. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102525. private _selectNode;
  102526. /**
  102527. * Updates the bounding box information for the Gizmo
  102528. */
  102529. updateBoundingBox(): void;
  102530. private _updateRotationSpheres;
  102531. private _updateScaleBoxes;
  102532. /**
  102533. * Enables rotation on the specified axis and disables rotation on the others
  102534. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102535. */
  102536. setEnabledRotationAxis(axis: string): void;
  102537. /**
  102538. * Enables/disables scaling
  102539. * @param enable if scaling should be enabled
  102540. */
  102541. setEnabledScaling(enable: boolean): void;
  102542. private _updateDummy;
  102543. /**
  102544. * Enables a pointer drag behavior on the bounding box of the gizmo
  102545. */
  102546. enableDragBehavior(): void;
  102547. /**
  102548. * Disposes of the gizmo
  102549. */
  102550. dispose(): void;
  102551. /**
  102552. * 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)
  102553. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102554. * @returns the bounding box mesh with the passed in mesh as a child
  102555. */
  102556. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102557. /**
  102558. * CustomMeshes are not supported by this gizmo
  102559. * @param mesh The mesh to replace the default mesh of the gizmo
  102560. */
  102561. setCustomMesh(mesh: Mesh): void;
  102562. }
  102563. }
  102564. declare module BABYLON {
  102565. /**
  102566. * Single plane rotation gizmo
  102567. */
  102568. export class PlaneRotationGizmo extends Gizmo {
  102569. /**
  102570. * Drag behavior responsible for the gizmos dragging interactions
  102571. */
  102572. dragBehavior: PointerDragBehavior;
  102573. private _pointerObserver;
  102574. /**
  102575. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102576. */
  102577. snapDistance: number;
  102578. /**
  102579. * Event that fires each time the gizmo snaps to a new location.
  102580. * * snapDistance is the the change in distance
  102581. */
  102582. onSnapObservable: Observable<{
  102583. snapDistance: number;
  102584. }>;
  102585. /**
  102586. * Creates a PlaneRotationGizmo
  102587. * @param gizmoLayer The utility layer the gizmo will be added to
  102588. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102589. * @param color The color of the gizmo
  102590. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102591. */
  102592. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102593. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102594. /**
  102595. * Disposes of the gizmo
  102596. */
  102597. dispose(): void;
  102598. }
  102599. }
  102600. declare module BABYLON {
  102601. /**
  102602. * Gizmo that enables rotating a mesh along 3 axis
  102603. */
  102604. export class RotationGizmo extends Gizmo {
  102605. /**
  102606. * Internal gizmo used for interactions on the x axis
  102607. */
  102608. xGizmo: PlaneRotationGizmo;
  102609. /**
  102610. * Internal gizmo used for interactions on the y axis
  102611. */
  102612. yGizmo: PlaneRotationGizmo;
  102613. /**
  102614. * Internal gizmo used for interactions on the z axis
  102615. */
  102616. zGizmo: PlaneRotationGizmo;
  102617. /** Fires an event when any of it's sub gizmos are dragged */
  102618. onDragStartObservable: Observable<{}>;
  102619. /** Fires an event when any of it's sub gizmos are released from dragging */
  102620. onDragEndObservable: Observable<{}>;
  102621. attachedMesh: Nullable<AbstractMesh>;
  102622. /**
  102623. * Creates a RotationGizmo
  102624. * @param gizmoLayer The utility layer the gizmo will be added to
  102625. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102626. */
  102627. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102628. updateGizmoRotationToMatchAttachedMesh: boolean;
  102629. /**
  102630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102631. */
  102632. snapDistance: number;
  102633. /**
  102634. * Ratio for the scale of the gizmo (Default: 1)
  102635. */
  102636. scaleRatio: number;
  102637. /**
  102638. * Disposes of the gizmo
  102639. */
  102640. dispose(): void;
  102641. /**
  102642. * CustomMeshes are not supported by this gizmo
  102643. * @param mesh The mesh to replace the default mesh of the gizmo
  102644. */
  102645. setCustomMesh(mesh: Mesh): void;
  102646. }
  102647. }
  102648. declare module BABYLON {
  102649. /**
  102650. * Gizmo that enables dragging a mesh along 3 axis
  102651. */
  102652. export class PositionGizmo extends Gizmo {
  102653. /**
  102654. * Internal gizmo used for interactions on the x axis
  102655. */
  102656. xGizmo: AxisDragGizmo;
  102657. /**
  102658. * Internal gizmo used for interactions on the y axis
  102659. */
  102660. yGizmo: AxisDragGizmo;
  102661. /**
  102662. * Internal gizmo used for interactions on the z axis
  102663. */
  102664. zGizmo: AxisDragGizmo;
  102665. /** Fires an event when any of it's sub gizmos are dragged */
  102666. onDragStartObservable: Observable<{}>;
  102667. /** Fires an event when any of it's sub gizmos are released from dragging */
  102668. onDragEndObservable: Observable<{}>;
  102669. attachedMesh: Nullable<AbstractMesh>;
  102670. /**
  102671. * Creates a PositionGizmo
  102672. * @param gizmoLayer The utility layer the gizmo will be added to
  102673. */
  102674. constructor(gizmoLayer?: UtilityLayerRenderer);
  102675. updateGizmoRotationToMatchAttachedMesh: boolean;
  102676. /**
  102677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102678. */
  102679. snapDistance: number;
  102680. /**
  102681. * Ratio for the scale of the gizmo (Default: 1)
  102682. */
  102683. scaleRatio: number;
  102684. /**
  102685. * Disposes of the gizmo
  102686. */
  102687. dispose(): void;
  102688. /**
  102689. * CustomMeshes are not supported by this gizmo
  102690. * @param mesh The mesh to replace the default mesh of the gizmo
  102691. */
  102692. setCustomMesh(mesh: Mesh): void;
  102693. }
  102694. }
  102695. declare module BABYLON {
  102696. /**
  102697. * Class containing static functions to help procedurally build meshes
  102698. */
  102699. export class PolyhedronBuilder {
  102700. /**
  102701. * Creates a polyhedron mesh
  102702. * * 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
  102703. * * The parameter `size` (positive float, default 1) sets the polygon size
  102704. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102705. * * 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`
  102706. * * 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
  102707. * * 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)`)
  102708. * * 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
  102709. * * 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
  102710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102713. * @param name defines the name of the mesh
  102714. * @param options defines the options used to create the mesh
  102715. * @param scene defines the hosting scene
  102716. * @returns the polyhedron mesh
  102717. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102718. */
  102719. static CreatePolyhedron(name: string, options: {
  102720. type?: number;
  102721. size?: number;
  102722. sizeX?: number;
  102723. sizeY?: number;
  102724. sizeZ?: number;
  102725. custom?: any;
  102726. faceUV?: Vector4[];
  102727. faceColors?: Color4[];
  102728. flat?: boolean;
  102729. updatable?: boolean;
  102730. sideOrientation?: number;
  102731. frontUVs?: Vector4;
  102732. backUVs?: Vector4;
  102733. }, scene?: Nullable<Scene>): Mesh;
  102734. }
  102735. }
  102736. declare module BABYLON {
  102737. /**
  102738. * Gizmo that enables scaling a mesh along 3 axis
  102739. */
  102740. export class ScaleGizmo extends Gizmo {
  102741. /**
  102742. * Internal gizmo used for interactions on the x axis
  102743. */
  102744. xGizmo: AxisScaleGizmo;
  102745. /**
  102746. * Internal gizmo used for interactions on the y axis
  102747. */
  102748. yGizmo: AxisScaleGizmo;
  102749. /**
  102750. * Internal gizmo used for interactions on the z axis
  102751. */
  102752. zGizmo: AxisScaleGizmo;
  102753. /**
  102754. * Internal gizmo used to scale all axis equally
  102755. */
  102756. uniformScaleGizmo: AxisScaleGizmo;
  102757. /** Fires an event when any of it's sub gizmos are dragged */
  102758. onDragStartObservable: Observable<{}>;
  102759. /** Fires an event when any of it's sub gizmos are released from dragging */
  102760. onDragEndObservable: Observable<{}>;
  102761. attachedMesh: Nullable<AbstractMesh>;
  102762. /**
  102763. * Creates a ScaleGizmo
  102764. * @param gizmoLayer The utility layer the gizmo will be added to
  102765. */
  102766. constructor(gizmoLayer?: UtilityLayerRenderer);
  102767. updateGizmoRotationToMatchAttachedMesh: boolean;
  102768. /**
  102769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102770. */
  102771. snapDistance: number;
  102772. /**
  102773. * Ratio for the scale of the gizmo (Default: 1)
  102774. */
  102775. scaleRatio: number;
  102776. /**
  102777. * Disposes of the gizmo
  102778. */
  102779. dispose(): void;
  102780. }
  102781. }
  102782. declare module BABYLON {
  102783. /**
  102784. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102785. */
  102786. export class GizmoManager implements IDisposable {
  102787. private scene;
  102788. /**
  102789. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102790. */
  102791. gizmos: {
  102792. positionGizmo: Nullable<PositionGizmo>;
  102793. rotationGizmo: Nullable<RotationGizmo>;
  102794. scaleGizmo: Nullable<ScaleGizmo>;
  102795. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102796. };
  102797. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102798. clearGizmoOnEmptyPointerEvent: boolean;
  102799. /** Fires an event when the manager is attached to a mesh */
  102800. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102801. private _gizmosEnabled;
  102802. private _pointerObserver;
  102803. private _attachedMesh;
  102804. private _boundingBoxColor;
  102805. private _defaultUtilityLayer;
  102806. private _defaultKeepDepthUtilityLayer;
  102807. /**
  102808. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102809. */
  102810. boundingBoxDragBehavior: SixDofDragBehavior;
  102811. /**
  102812. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102813. */
  102814. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102815. /**
  102816. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102817. */
  102818. usePointerToAttachGizmos: boolean;
  102819. /**
  102820. * Instatiates a gizmo manager
  102821. * @param scene the scene to overlay the gizmos on top of
  102822. */
  102823. constructor(scene: Scene);
  102824. /**
  102825. * Attaches a set of gizmos to the specified mesh
  102826. * @param mesh The mesh the gizmo's should be attached to
  102827. */
  102828. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102829. /**
  102830. * If the position gizmo is enabled
  102831. */
  102832. positionGizmoEnabled: boolean;
  102833. /**
  102834. * If the rotation gizmo is enabled
  102835. */
  102836. rotationGizmoEnabled: boolean;
  102837. /**
  102838. * If the scale gizmo is enabled
  102839. */
  102840. scaleGizmoEnabled: boolean;
  102841. /**
  102842. * If the boundingBox gizmo is enabled
  102843. */
  102844. boundingBoxGizmoEnabled: boolean;
  102845. /**
  102846. * Disposes of the gizmo manager
  102847. */
  102848. dispose(): void;
  102849. }
  102850. }
  102851. declare module BABYLON {
  102852. /**
  102853. * A directional light is defined by a direction (what a surprise!).
  102854. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102855. * 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.
  102856. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102857. */
  102858. export class DirectionalLight extends ShadowLight {
  102859. private _shadowFrustumSize;
  102860. /**
  102861. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102862. */
  102863. /**
  102864. * Specifies a fix frustum size for the shadow generation.
  102865. */
  102866. shadowFrustumSize: number;
  102867. private _shadowOrthoScale;
  102868. /**
  102869. * Gets the shadow projection scale against the optimal computed one.
  102870. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102871. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102872. */
  102873. /**
  102874. * Sets the shadow projection scale against the optimal computed one.
  102875. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102876. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102877. */
  102878. shadowOrthoScale: number;
  102879. /**
  102880. * Automatically compute the projection matrix to best fit (including all the casters)
  102881. * on each frame.
  102882. */
  102883. autoUpdateExtends: boolean;
  102884. private _orthoLeft;
  102885. private _orthoRight;
  102886. private _orthoTop;
  102887. private _orthoBottom;
  102888. /**
  102889. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102890. * The directional light is emitted from everywhere in the given direction.
  102891. * It can cast shadows.
  102892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102893. * @param name The friendly name of the light
  102894. * @param direction The direction of the light
  102895. * @param scene The scene the light belongs to
  102896. */
  102897. constructor(name: string, direction: Vector3, scene: Scene);
  102898. /**
  102899. * Returns the string "DirectionalLight".
  102900. * @return The class name
  102901. */
  102902. getClassName(): string;
  102903. /**
  102904. * Returns the integer 1.
  102905. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102906. */
  102907. getTypeID(): number;
  102908. /**
  102909. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102910. * Returns the DirectionalLight Shadow projection matrix.
  102911. */
  102912. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102913. /**
  102914. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102915. * Returns the DirectionalLight Shadow projection matrix.
  102916. */
  102917. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102918. /**
  102919. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102920. * Returns the DirectionalLight Shadow projection matrix.
  102921. */
  102922. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102923. protected _buildUniformLayout(): void;
  102924. /**
  102925. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102926. * @param effect The effect to update
  102927. * @param lightIndex The index of the light in the effect to update
  102928. * @returns The directional light
  102929. */
  102930. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102931. /**
  102932. * Gets the minZ used for shadow according to both the scene and the light.
  102933. *
  102934. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102935. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102936. * @param activeCamera The camera we are returning the min for
  102937. * @returns the depth min z
  102938. */
  102939. getDepthMinZ(activeCamera: Camera): number;
  102940. /**
  102941. * Gets the maxZ used for shadow according to both the scene and the light.
  102942. *
  102943. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102944. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102945. * @param activeCamera The camera we are returning the max for
  102946. * @returns the depth max z
  102947. */
  102948. getDepthMaxZ(activeCamera: Camera): number;
  102949. /**
  102950. * Prepares the list of defines specific to the light type.
  102951. * @param defines the list of defines
  102952. * @param lightIndex defines the index of the light for the effect
  102953. */
  102954. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102955. }
  102956. }
  102957. declare module BABYLON {
  102958. /**
  102959. * Class containing static functions to help procedurally build meshes
  102960. */
  102961. export class HemisphereBuilder {
  102962. /**
  102963. * Creates a hemisphere mesh
  102964. * @param name defines the name of the mesh
  102965. * @param options defines the options used to create the mesh
  102966. * @param scene defines the hosting scene
  102967. * @returns the hemisphere mesh
  102968. */
  102969. static CreateHemisphere(name: string, options: {
  102970. segments?: number;
  102971. diameter?: number;
  102972. sideOrientation?: number;
  102973. }, scene: any): Mesh;
  102974. }
  102975. }
  102976. declare module BABYLON {
  102977. /**
  102978. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102979. * These values define a cone of light starting from the position, emitting toward the direction.
  102980. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102981. * and the exponent defines the speed of the decay of the light with distance (reach).
  102982. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102983. */
  102984. export class SpotLight extends ShadowLight {
  102985. private _angle;
  102986. private _innerAngle;
  102987. private _cosHalfAngle;
  102988. private _lightAngleScale;
  102989. private _lightAngleOffset;
  102990. /**
  102991. * Gets the cone angle of the spot light in Radians.
  102992. */
  102993. /**
  102994. * Sets the cone angle of the spot light in Radians.
  102995. */
  102996. angle: number;
  102997. /**
  102998. * Only used in gltf falloff mode, this defines the angle where
  102999. * the directional falloff will start before cutting at angle which could be seen
  103000. * as outer angle.
  103001. */
  103002. /**
  103003. * Only used in gltf falloff mode, this defines the angle where
  103004. * the directional falloff will start before cutting at angle which could be seen
  103005. * as outer angle.
  103006. */
  103007. innerAngle: number;
  103008. private _shadowAngleScale;
  103009. /**
  103010. * Allows scaling the angle of the light for shadow generation only.
  103011. */
  103012. /**
  103013. * Allows scaling the angle of the light for shadow generation only.
  103014. */
  103015. shadowAngleScale: number;
  103016. /**
  103017. * The light decay speed with the distance from the emission spot.
  103018. */
  103019. exponent: number;
  103020. private _projectionTextureMatrix;
  103021. /**
  103022. * Allows reading the projecton texture
  103023. */
  103024. readonly projectionTextureMatrix: Matrix;
  103025. protected _projectionTextureLightNear: number;
  103026. /**
  103027. * Gets the near clip of the Spotlight for texture projection.
  103028. */
  103029. /**
  103030. * Sets the near clip of the Spotlight for texture projection.
  103031. */
  103032. projectionTextureLightNear: number;
  103033. protected _projectionTextureLightFar: number;
  103034. /**
  103035. * Gets the far clip of the Spotlight for texture projection.
  103036. */
  103037. /**
  103038. * Sets the far clip of the Spotlight for texture projection.
  103039. */
  103040. projectionTextureLightFar: number;
  103041. protected _projectionTextureUpDirection: Vector3;
  103042. /**
  103043. * Gets the Up vector of the Spotlight for texture projection.
  103044. */
  103045. /**
  103046. * Sets the Up vector of the Spotlight for texture projection.
  103047. */
  103048. projectionTextureUpDirection: Vector3;
  103049. private _projectionTexture;
  103050. /**
  103051. * Gets the projection texture of the light.
  103052. */
  103053. /**
  103054. * Sets the projection texture of the light.
  103055. */
  103056. projectionTexture: Nullable<BaseTexture>;
  103057. private _projectionTextureViewLightDirty;
  103058. private _projectionTextureProjectionLightDirty;
  103059. private _projectionTextureDirty;
  103060. private _projectionTextureViewTargetVector;
  103061. private _projectionTextureViewLightMatrix;
  103062. private _projectionTextureProjectionLightMatrix;
  103063. private _projectionTextureScalingMatrix;
  103064. /**
  103065. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103066. * It can cast shadows.
  103067. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103068. * @param name The light friendly name
  103069. * @param position The position of the spot light in the scene
  103070. * @param direction The direction of the light in the scene
  103071. * @param angle The cone angle of the light in Radians
  103072. * @param exponent The light decay speed with the distance from the emission spot
  103073. * @param scene The scene the lights belongs to
  103074. */
  103075. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103076. /**
  103077. * Returns the string "SpotLight".
  103078. * @returns the class name
  103079. */
  103080. getClassName(): string;
  103081. /**
  103082. * Returns the integer 2.
  103083. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103084. */
  103085. getTypeID(): number;
  103086. /**
  103087. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103088. */
  103089. protected _setDirection(value: Vector3): void;
  103090. /**
  103091. * Overrides the position setter to recompute the projection texture view light Matrix.
  103092. */
  103093. protected _setPosition(value: Vector3): void;
  103094. /**
  103095. * 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.
  103096. * Returns the SpotLight.
  103097. */
  103098. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103099. protected _computeProjectionTextureViewLightMatrix(): void;
  103100. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103101. /**
  103102. * Main function for light texture projection matrix computing.
  103103. */
  103104. protected _computeProjectionTextureMatrix(): void;
  103105. protected _buildUniformLayout(): void;
  103106. private _computeAngleValues;
  103107. /**
  103108. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103109. * @param effect The effect to update
  103110. * @param lightIndex The index of the light in the effect to update
  103111. * @returns The spot light
  103112. */
  103113. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103114. /**
  103115. * Disposes the light and the associated resources.
  103116. */
  103117. dispose(): void;
  103118. /**
  103119. * Prepares the list of defines specific to the light type.
  103120. * @param defines the list of defines
  103121. * @param lightIndex defines the index of the light for the effect
  103122. */
  103123. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103124. }
  103125. }
  103126. declare module BABYLON {
  103127. /**
  103128. * Gizmo that enables viewing a light
  103129. */
  103130. export class LightGizmo extends Gizmo {
  103131. private _lightMesh;
  103132. private _material;
  103133. /**
  103134. * Creates a LightGizmo
  103135. * @param gizmoLayer The utility layer the gizmo will be added to
  103136. */
  103137. constructor(gizmoLayer?: UtilityLayerRenderer);
  103138. private _light;
  103139. /**
  103140. * The light that the gizmo is attached to
  103141. */
  103142. light: Nullable<Light>;
  103143. /**
  103144. * @hidden
  103145. * Updates the gizmo to match the attached mesh's position/rotation
  103146. */
  103147. protected _update(): void;
  103148. private static _Scale;
  103149. /**
  103150. * Creates the lines for a light mesh
  103151. */
  103152. private static _createLightLines;
  103153. private static _CreateHemisphericLightMesh;
  103154. private static _CreatePointLightMesh;
  103155. private static _CreateSpotLightMesh;
  103156. private static _CreateDirectionalLightMesh;
  103157. }
  103158. }
  103159. declare module BABYLON {
  103160. /** @hidden */
  103161. export var backgroundFragmentDeclaration: {
  103162. name: string;
  103163. shader: string;
  103164. };
  103165. }
  103166. declare module BABYLON {
  103167. /** @hidden */
  103168. export var backgroundUboDeclaration: {
  103169. name: string;
  103170. shader: string;
  103171. };
  103172. }
  103173. declare module BABYLON {
  103174. /** @hidden */
  103175. export var backgroundPixelShader: {
  103176. name: string;
  103177. shader: string;
  103178. };
  103179. }
  103180. declare module BABYLON {
  103181. /** @hidden */
  103182. export var backgroundVertexDeclaration: {
  103183. name: string;
  103184. shader: string;
  103185. };
  103186. }
  103187. declare module BABYLON {
  103188. /** @hidden */
  103189. export var backgroundVertexShader: {
  103190. name: string;
  103191. shader: string;
  103192. };
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * Background material used to create an efficient environement around your scene.
  103197. */
  103198. export class BackgroundMaterial extends PushMaterial {
  103199. /**
  103200. * Standard reflectance value at parallel view angle.
  103201. */
  103202. static StandardReflectance0: number;
  103203. /**
  103204. * Standard reflectance value at grazing angle.
  103205. */
  103206. static StandardReflectance90: number;
  103207. protected _primaryColor: Color3;
  103208. /**
  103209. * Key light Color (multiply against the environement texture)
  103210. */
  103211. primaryColor: Color3;
  103212. protected __perceptualColor: Nullable<Color3>;
  103213. /**
  103214. * Experimental Internal Use Only.
  103215. *
  103216. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103217. * This acts as a helper to set the primary color to a more "human friendly" value.
  103218. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103219. * output color as close as possible from the chosen value.
  103220. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103221. * part of lighting setup.)
  103222. */
  103223. _perceptualColor: Nullable<Color3>;
  103224. protected _primaryColorShadowLevel: float;
  103225. /**
  103226. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103227. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103228. */
  103229. primaryColorShadowLevel: float;
  103230. protected _primaryColorHighlightLevel: float;
  103231. /**
  103232. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103233. * The primary color is used at the level chosen to define what the white area would look.
  103234. */
  103235. primaryColorHighlightLevel: float;
  103236. protected _reflectionTexture: Nullable<BaseTexture>;
  103237. /**
  103238. * Reflection Texture used in the material.
  103239. * Should be author in a specific way for the best result (refer to the documentation).
  103240. */
  103241. reflectionTexture: Nullable<BaseTexture>;
  103242. protected _reflectionBlur: float;
  103243. /**
  103244. * Reflection Texture level of blur.
  103245. *
  103246. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103247. * texture twice.
  103248. */
  103249. reflectionBlur: float;
  103250. protected _diffuseTexture: Nullable<BaseTexture>;
  103251. /**
  103252. * Diffuse Texture used in the material.
  103253. * Should be author in a specific way for the best result (refer to the documentation).
  103254. */
  103255. diffuseTexture: Nullable<BaseTexture>;
  103256. protected _shadowLights: Nullable<IShadowLight[]>;
  103257. /**
  103258. * Specify the list of lights casting shadow on the material.
  103259. * All scene shadow lights will be included if null.
  103260. */
  103261. shadowLights: Nullable<IShadowLight[]>;
  103262. protected _shadowLevel: float;
  103263. /**
  103264. * Helps adjusting the shadow to a softer level if required.
  103265. * 0 means black shadows and 1 means no shadows.
  103266. */
  103267. shadowLevel: float;
  103268. protected _sceneCenter: Vector3;
  103269. /**
  103270. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103271. * It is usually zero but might be interesting to modify according to your setup.
  103272. */
  103273. sceneCenter: Vector3;
  103274. protected _opacityFresnel: boolean;
  103275. /**
  103276. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103277. * This helps ensuring a nice transition when the camera goes under the ground.
  103278. */
  103279. opacityFresnel: boolean;
  103280. protected _reflectionFresnel: boolean;
  103281. /**
  103282. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103283. * This helps adding a mirror texture on the ground.
  103284. */
  103285. reflectionFresnel: boolean;
  103286. protected _reflectionFalloffDistance: number;
  103287. /**
  103288. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103289. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103290. */
  103291. reflectionFalloffDistance: number;
  103292. protected _reflectionAmount: number;
  103293. /**
  103294. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103295. */
  103296. reflectionAmount: number;
  103297. protected _reflectionReflectance0: number;
  103298. /**
  103299. * This specifies the weight of the reflection at grazing angle.
  103300. */
  103301. reflectionReflectance0: number;
  103302. protected _reflectionReflectance90: number;
  103303. /**
  103304. * This specifies the weight of the reflection at a perpendicular point of view.
  103305. */
  103306. reflectionReflectance90: number;
  103307. /**
  103308. * Sets the reflection reflectance fresnel values according to the default standard
  103309. * empirically know to work well :-)
  103310. */
  103311. reflectionStandardFresnelWeight: number;
  103312. protected _useRGBColor: boolean;
  103313. /**
  103314. * Helps to directly use the maps channels instead of their level.
  103315. */
  103316. useRGBColor: boolean;
  103317. protected _enableNoise: boolean;
  103318. /**
  103319. * This helps reducing the banding effect that could occur on the background.
  103320. */
  103321. enableNoise: boolean;
  103322. /**
  103323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103324. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103325. * Recommended to be keep at 1.0 except for special cases.
  103326. */
  103327. fovMultiplier: number;
  103328. private _fovMultiplier;
  103329. /**
  103330. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103331. */
  103332. useEquirectangularFOV: boolean;
  103333. private _maxSimultaneousLights;
  103334. /**
  103335. * Number of Simultaneous lights allowed on the material.
  103336. */
  103337. maxSimultaneousLights: int;
  103338. /**
  103339. * Default configuration related to image processing available in the Background Material.
  103340. */
  103341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103342. /**
  103343. * Keep track of the image processing observer to allow dispose and replace.
  103344. */
  103345. private _imageProcessingObserver;
  103346. /**
  103347. * Attaches a new image processing configuration to the PBR Material.
  103348. * @param configuration (if null the scene configuration will be use)
  103349. */
  103350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103351. /**
  103352. * Gets the image processing configuration used either in this material.
  103353. */
  103354. /**
  103355. * Sets the Default image processing configuration used either in the this material.
  103356. *
  103357. * If sets to null, the scene one is in use.
  103358. */
  103359. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103360. /**
  103361. * Gets wether the color curves effect is enabled.
  103362. */
  103363. /**
  103364. * Sets wether the color curves effect is enabled.
  103365. */
  103366. cameraColorCurvesEnabled: boolean;
  103367. /**
  103368. * Gets wether the color grading effect is enabled.
  103369. */
  103370. /**
  103371. * Gets wether the color grading effect is enabled.
  103372. */
  103373. cameraColorGradingEnabled: boolean;
  103374. /**
  103375. * Gets wether tonemapping is enabled or not.
  103376. */
  103377. /**
  103378. * Sets wether tonemapping is enabled or not
  103379. */
  103380. cameraToneMappingEnabled: boolean;
  103381. /**
  103382. * The camera exposure used on this material.
  103383. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103384. * This corresponds to a photographic exposure.
  103385. */
  103386. /**
  103387. * The camera exposure used on this material.
  103388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103389. * This corresponds to a photographic exposure.
  103390. */
  103391. cameraExposure: float;
  103392. /**
  103393. * Gets The camera contrast used on this material.
  103394. */
  103395. /**
  103396. * Sets The camera contrast used on this material.
  103397. */
  103398. cameraContrast: float;
  103399. /**
  103400. * Gets the Color Grading 2D Lookup Texture.
  103401. */
  103402. /**
  103403. * Sets the Color Grading 2D Lookup Texture.
  103404. */
  103405. cameraColorGradingTexture: Nullable<BaseTexture>;
  103406. /**
  103407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103409. * 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;
  103410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103411. */
  103412. /**
  103413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103415. * 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;
  103416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103417. */
  103418. cameraColorCurves: Nullable<ColorCurves>;
  103419. /**
  103420. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103421. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103422. */
  103423. switchToBGR: boolean;
  103424. private _renderTargets;
  103425. private _reflectionControls;
  103426. private _white;
  103427. private _primaryShadowColor;
  103428. private _primaryHighlightColor;
  103429. /**
  103430. * Instantiates a Background Material in the given scene
  103431. * @param name The friendly name of the material
  103432. * @param scene The scene to add the material to
  103433. */
  103434. constructor(name: string, scene: Scene);
  103435. /**
  103436. * Gets a boolean indicating that current material needs to register RTT
  103437. */
  103438. readonly hasRenderTargetTextures: boolean;
  103439. /**
  103440. * The entire material has been created in order to prevent overdraw.
  103441. * @returns false
  103442. */
  103443. needAlphaTesting(): boolean;
  103444. /**
  103445. * The entire material has been created in order to prevent overdraw.
  103446. * @returns true if blending is enable
  103447. */
  103448. needAlphaBlending(): boolean;
  103449. /**
  103450. * Checks wether the material is ready to be rendered for a given mesh.
  103451. * @param mesh The mesh to render
  103452. * @param subMesh The submesh to check against
  103453. * @param useInstances Specify wether or not the material is used with instances
  103454. * @returns true if all the dependencies are ready (Textures, Effects...)
  103455. */
  103456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103457. /**
  103458. * Compute the primary color according to the chosen perceptual color.
  103459. */
  103460. private _computePrimaryColorFromPerceptualColor;
  103461. /**
  103462. * Compute the highlights and shadow colors according to their chosen levels.
  103463. */
  103464. private _computePrimaryColors;
  103465. /**
  103466. * Build the uniform buffer used in the material.
  103467. */
  103468. buildUniformLayout(): void;
  103469. /**
  103470. * Unbind the material.
  103471. */
  103472. unbind(): void;
  103473. /**
  103474. * Bind only the world matrix to the material.
  103475. * @param world The world matrix to bind.
  103476. */
  103477. bindOnlyWorldMatrix(world: Matrix): void;
  103478. /**
  103479. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103480. * @param world The world matrix to bind.
  103481. * @param subMesh The submesh to bind for.
  103482. */
  103483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103484. /**
  103485. * Dispose the material.
  103486. * @param forceDisposeEffect Force disposal of the associated effect.
  103487. * @param forceDisposeTextures Force disposal of the associated textures.
  103488. */
  103489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103490. /**
  103491. * Clones the material.
  103492. * @param name The cloned name.
  103493. * @returns The cloned material.
  103494. */
  103495. clone(name: string): BackgroundMaterial;
  103496. /**
  103497. * Serializes the current material to its JSON representation.
  103498. * @returns The JSON representation.
  103499. */
  103500. serialize(): any;
  103501. /**
  103502. * Gets the class name of the material
  103503. * @returns "BackgroundMaterial"
  103504. */
  103505. getClassName(): string;
  103506. /**
  103507. * Parse a JSON input to create back a background material.
  103508. * @param source The JSON data to parse
  103509. * @param scene The scene to create the parsed material in
  103510. * @param rootUrl The root url of the assets the material depends upon
  103511. * @returns the instantiated BackgroundMaterial.
  103512. */
  103513. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103514. }
  103515. }
  103516. declare module BABYLON {
  103517. /**
  103518. * Represents the different options available during the creation of
  103519. * a Environment helper.
  103520. *
  103521. * This can control the default ground, skybox and image processing setup of your scene.
  103522. */
  103523. export interface IEnvironmentHelperOptions {
  103524. /**
  103525. * Specifies wether or not to create a ground.
  103526. * True by default.
  103527. */
  103528. createGround: boolean;
  103529. /**
  103530. * Specifies the ground size.
  103531. * 15 by default.
  103532. */
  103533. groundSize: number;
  103534. /**
  103535. * The texture used on the ground for the main color.
  103536. * Comes from the BabylonJS CDN by default.
  103537. *
  103538. * Remarks: Can be either a texture or a url.
  103539. */
  103540. groundTexture: string | BaseTexture;
  103541. /**
  103542. * The color mixed in the ground texture by default.
  103543. * BabylonJS clearColor by default.
  103544. */
  103545. groundColor: Color3;
  103546. /**
  103547. * Specifies the ground opacity.
  103548. * 1 by default.
  103549. */
  103550. groundOpacity: number;
  103551. /**
  103552. * Enables the ground to receive shadows.
  103553. * True by default.
  103554. */
  103555. enableGroundShadow: boolean;
  103556. /**
  103557. * Helps preventing the shadow to be fully black on the ground.
  103558. * 0.5 by default.
  103559. */
  103560. groundShadowLevel: number;
  103561. /**
  103562. * Creates a mirror texture attach to the ground.
  103563. * false by default.
  103564. */
  103565. enableGroundMirror: boolean;
  103566. /**
  103567. * Specifies the ground mirror size ratio.
  103568. * 0.3 by default as the default kernel is 64.
  103569. */
  103570. groundMirrorSizeRatio: number;
  103571. /**
  103572. * Specifies the ground mirror blur kernel size.
  103573. * 64 by default.
  103574. */
  103575. groundMirrorBlurKernel: number;
  103576. /**
  103577. * Specifies the ground mirror visibility amount.
  103578. * 1 by default
  103579. */
  103580. groundMirrorAmount: number;
  103581. /**
  103582. * Specifies the ground mirror reflectance weight.
  103583. * This uses the standard weight of the background material to setup the fresnel effect
  103584. * of the mirror.
  103585. * 1 by default.
  103586. */
  103587. groundMirrorFresnelWeight: number;
  103588. /**
  103589. * Specifies the ground mirror Falloff distance.
  103590. * This can helps reducing the size of the reflection.
  103591. * 0 by Default.
  103592. */
  103593. groundMirrorFallOffDistance: number;
  103594. /**
  103595. * Specifies the ground mirror texture type.
  103596. * Unsigned Int by Default.
  103597. */
  103598. groundMirrorTextureType: number;
  103599. /**
  103600. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103601. * the shown objects.
  103602. */
  103603. groundYBias: number;
  103604. /**
  103605. * Specifies wether or not to create a skybox.
  103606. * True by default.
  103607. */
  103608. createSkybox: boolean;
  103609. /**
  103610. * Specifies the skybox size.
  103611. * 20 by default.
  103612. */
  103613. skyboxSize: number;
  103614. /**
  103615. * The texture used on the skybox for the main color.
  103616. * Comes from the BabylonJS CDN by default.
  103617. *
  103618. * Remarks: Can be either a texture or a url.
  103619. */
  103620. skyboxTexture: string | BaseTexture;
  103621. /**
  103622. * The color mixed in the skybox texture by default.
  103623. * BabylonJS clearColor by default.
  103624. */
  103625. skyboxColor: Color3;
  103626. /**
  103627. * The background rotation around the Y axis of the scene.
  103628. * This helps aligning the key lights of your scene with the background.
  103629. * 0 by default.
  103630. */
  103631. backgroundYRotation: number;
  103632. /**
  103633. * Compute automatically the size of the elements to best fit with the scene.
  103634. */
  103635. sizeAuto: boolean;
  103636. /**
  103637. * Default position of the rootMesh if autoSize is not true.
  103638. */
  103639. rootPosition: Vector3;
  103640. /**
  103641. * Sets up the image processing in the scene.
  103642. * true by default.
  103643. */
  103644. setupImageProcessing: boolean;
  103645. /**
  103646. * The texture used as your environment texture in the scene.
  103647. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103648. *
  103649. * Remarks: Can be either a texture or a url.
  103650. */
  103651. environmentTexture: string | BaseTexture;
  103652. /**
  103653. * The value of the exposure to apply to the scene.
  103654. * 0.6 by default if setupImageProcessing is true.
  103655. */
  103656. cameraExposure: number;
  103657. /**
  103658. * The value of the contrast to apply to the scene.
  103659. * 1.6 by default if setupImageProcessing is true.
  103660. */
  103661. cameraContrast: number;
  103662. /**
  103663. * Specifies wether or not tonemapping should be enabled in the scene.
  103664. * true by default if setupImageProcessing is true.
  103665. */
  103666. toneMappingEnabled: boolean;
  103667. }
  103668. /**
  103669. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103670. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103671. * It also helps with the default setup of your imageProcessing configuration.
  103672. */
  103673. export class EnvironmentHelper {
  103674. /**
  103675. * Default ground texture URL.
  103676. */
  103677. private static _groundTextureCDNUrl;
  103678. /**
  103679. * Default skybox texture URL.
  103680. */
  103681. private static _skyboxTextureCDNUrl;
  103682. /**
  103683. * Default environment texture URL.
  103684. */
  103685. private static _environmentTextureCDNUrl;
  103686. /**
  103687. * Creates the default options for the helper.
  103688. */
  103689. private static _getDefaultOptions;
  103690. private _rootMesh;
  103691. /**
  103692. * Gets the root mesh created by the helper.
  103693. */
  103694. readonly rootMesh: Mesh;
  103695. private _skybox;
  103696. /**
  103697. * Gets the skybox created by the helper.
  103698. */
  103699. readonly skybox: Nullable<Mesh>;
  103700. private _skyboxTexture;
  103701. /**
  103702. * Gets the skybox texture created by the helper.
  103703. */
  103704. readonly skyboxTexture: Nullable<BaseTexture>;
  103705. private _skyboxMaterial;
  103706. /**
  103707. * Gets the skybox material created by the helper.
  103708. */
  103709. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103710. private _ground;
  103711. /**
  103712. * Gets the ground mesh created by the helper.
  103713. */
  103714. readonly ground: Nullable<Mesh>;
  103715. private _groundTexture;
  103716. /**
  103717. * Gets the ground texture created by the helper.
  103718. */
  103719. readonly groundTexture: Nullable<BaseTexture>;
  103720. private _groundMirror;
  103721. /**
  103722. * Gets the ground mirror created by the helper.
  103723. */
  103724. readonly groundMirror: Nullable<MirrorTexture>;
  103725. /**
  103726. * Gets the ground mirror render list to helps pushing the meshes
  103727. * you wish in the ground reflection.
  103728. */
  103729. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103730. private _groundMaterial;
  103731. /**
  103732. * Gets the ground material created by the helper.
  103733. */
  103734. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103735. /**
  103736. * Stores the creation options.
  103737. */
  103738. private readonly _scene;
  103739. private _options;
  103740. /**
  103741. * This observable will be notified with any error during the creation of the environment,
  103742. * mainly texture creation errors.
  103743. */
  103744. onErrorObservable: Observable<{
  103745. message?: string;
  103746. exception?: any;
  103747. }>;
  103748. /**
  103749. * constructor
  103750. * @param options Defines the options we want to customize the helper
  103751. * @param scene The scene to add the material to
  103752. */
  103753. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103754. /**
  103755. * Updates the background according to the new options
  103756. * @param options
  103757. */
  103758. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103759. /**
  103760. * Sets the primary color of all the available elements.
  103761. * @param color the main color to affect to the ground and the background
  103762. */
  103763. setMainColor(color: Color3): void;
  103764. /**
  103765. * Setup the image processing according to the specified options.
  103766. */
  103767. private _setupImageProcessing;
  103768. /**
  103769. * Setup the environment texture according to the specified options.
  103770. */
  103771. private _setupEnvironmentTexture;
  103772. /**
  103773. * Setup the background according to the specified options.
  103774. */
  103775. private _setupBackground;
  103776. /**
  103777. * Get the scene sizes according to the setup.
  103778. */
  103779. private _getSceneSize;
  103780. /**
  103781. * Setup the ground according to the specified options.
  103782. */
  103783. private _setupGround;
  103784. /**
  103785. * Setup the ground material according to the specified options.
  103786. */
  103787. private _setupGroundMaterial;
  103788. /**
  103789. * Setup the ground diffuse texture according to the specified options.
  103790. */
  103791. private _setupGroundDiffuseTexture;
  103792. /**
  103793. * Setup the ground mirror texture according to the specified options.
  103794. */
  103795. private _setupGroundMirrorTexture;
  103796. /**
  103797. * Setup the ground to receive the mirror texture.
  103798. */
  103799. private _setupMirrorInGroundMaterial;
  103800. /**
  103801. * Setup the skybox according to the specified options.
  103802. */
  103803. private _setupSkybox;
  103804. /**
  103805. * Setup the skybox material according to the specified options.
  103806. */
  103807. private _setupSkyboxMaterial;
  103808. /**
  103809. * Setup the skybox reflection texture according to the specified options.
  103810. */
  103811. private _setupSkyboxReflectionTexture;
  103812. private _errorHandler;
  103813. /**
  103814. * Dispose all the elements created by the Helper.
  103815. */
  103816. dispose(): void;
  103817. }
  103818. }
  103819. declare module BABYLON {
  103820. /**
  103821. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103822. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103823. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103824. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103825. */
  103826. export class PhotoDome extends TransformNode {
  103827. private _useDirectMapping;
  103828. /**
  103829. * The texture being displayed on the sphere
  103830. */
  103831. protected _photoTexture: Texture;
  103832. /**
  103833. * Gets or sets the texture being displayed on the sphere
  103834. */
  103835. photoTexture: Texture;
  103836. /**
  103837. * Observable raised when an error occured while loading the 360 image
  103838. */
  103839. onLoadErrorObservable: Observable<string>;
  103840. /**
  103841. * The skybox material
  103842. */
  103843. protected _material: BackgroundMaterial;
  103844. /**
  103845. * The surface used for the skybox
  103846. */
  103847. protected _mesh: Mesh;
  103848. /**
  103849. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103850. * Also see the options.resolution property.
  103851. */
  103852. fovMultiplier: number;
  103853. /**
  103854. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103855. * @param name Element's name, child elements will append suffixes for their own names.
  103856. * @param urlsOfPhoto defines the url of the photo to display
  103857. * @param options defines an object containing optional or exposed sub element properties
  103858. * @param onError defines a callback called when an error occured while loading the texture
  103859. */
  103860. constructor(name: string, urlOfPhoto: string, options: {
  103861. resolution?: number;
  103862. size?: number;
  103863. useDirectMapping?: boolean;
  103864. faceForward?: boolean;
  103865. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103866. /**
  103867. * Releases resources associated with this node.
  103868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103870. */
  103871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103872. }
  103873. }
  103874. declare module BABYLON {
  103875. /** @hidden */
  103876. export var rgbdDecodePixelShader: {
  103877. name: string;
  103878. shader: string;
  103879. };
  103880. }
  103881. declare module BABYLON {
  103882. /**
  103883. * Class used to host texture specific utilities
  103884. */
  103885. export class BRDFTextureTools {
  103886. /**
  103887. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103888. * @param texture the texture to expand.
  103889. */
  103890. private static _ExpandDefaultBRDFTexture;
  103891. /**
  103892. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103893. * @param scene defines the hosting scene
  103894. * @returns the environment BRDF texture
  103895. */
  103896. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103897. private static _environmentBRDFBase64Texture;
  103898. }
  103899. }
  103900. declare module BABYLON {
  103901. /**
  103902. * @hidden
  103903. */
  103904. export interface IMaterialClearCoatDefines {
  103905. CLEARCOAT: boolean;
  103906. CLEARCOAT_DEFAULTIOR: boolean;
  103907. CLEARCOAT_TEXTURE: boolean;
  103908. CLEARCOAT_TEXTUREDIRECTUV: number;
  103909. CLEARCOAT_BUMP: boolean;
  103910. CLEARCOAT_BUMPDIRECTUV: number;
  103911. CLEARCOAT_TINT: boolean;
  103912. CLEARCOAT_TINT_TEXTURE: boolean;
  103913. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103914. /** @hidden */
  103915. _areTexturesDirty: boolean;
  103916. }
  103917. /**
  103918. * Define the code related to the clear coat parameters of the pbr material.
  103919. */
  103920. export class PBRClearCoatConfiguration {
  103921. /**
  103922. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103923. * The default fits with a polyurethane material.
  103924. */
  103925. private static readonly _DefaultIndiceOfRefraction;
  103926. private _isEnabled;
  103927. /**
  103928. * Defines if the clear coat is enabled in the material.
  103929. */
  103930. isEnabled: boolean;
  103931. /**
  103932. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103933. */
  103934. intensity: number;
  103935. /**
  103936. * Defines the clear coat layer roughness.
  103937. */
  103938. roughness: number;
  103939. private _indiceOfRefraction;
  103940. /**
  103941. * Defines the indice of refraction of the clear coat.
  103942. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103943. * The default fits with a polyurethane material.
  103944. * Changing the default value is more performance intensive.
  103945. */
  103946. indiceOfRefraction: number;
  103947. private _texture;
  103948. /**
  103949. * Stores the clear coat values in a texture.
  103950. */
  103951. texture: Nullable<BaseTexture>;
  103952. private _bumpTexture;
  103953. /**
  103954. * Define the clear coat specific bump texture.
  103955. */
  103956. bumpTexture: Nullable<BaseTexture>;
  103957. private _isTintEnabled;
  103958. /**
  103959. * Defines if the clear coat tint is enabled in the material.
  103960. */
  103961. isTintEnabled: boolean;
  103962. /**
  103963. * Defines the clear coat tint of the material.
  103964. * This is only use if tint is enabled
  103965. */
  103966. tintColor: Color3;
  103967. /**
  103968. * Defines the distance at which the tint color should be found in the
  103969. * clear coat media.
  103970. * This is only use if tint is enabled
  103971. */
  103972. tintColorAtDistance: number;
  103973. /**
  103974. * Defines the clear coat layer thickness.
  103975. * This is only use if tint is enabled
  103976. */
  103977. tintThickness: number;
  103978. private _tintTexture;
  103979. /**
  103980. * Stores the clear tint values in a texture.
  103981. * rgb is tint
  103982. * a is a thickness factor
  103983. */
  103984. tintTexture: Nullable<BaseTexture>;
  103985. /** @hidden */
  103986. private _internalMarkAllSubMeshesAsTexturesDirty;
  103987. /** @hidden */
  103988. _markAllSubMeshesAsTexturesDirty(): void;
  103989. /**
  103990. * Instantiate a new istance of clear coat configuration.
  103991. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103992. */
  103993. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103994. /**
  103995. * Gets wehter the submesh is ready to be used or not.
  103996. * @param defines the list of "defines" to update.
  103997. * @param scene defines the scene the material belongs to.
  103998. * @param engine defines the engine the material belongs to.
  103999. * @param disableBumpMap defines wether the material disables bump or not.
  104000. * @returns - boolean indicating that the submesh is ready or not.
  104001. */
  104002. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104003. /**
  104004. * Checks to see if a texture is used in the material.
  104005. * @param defines the list of "defines" to update.
  104006. * @param scene defines the scene to the material belongs to.
  104007. */
  104008. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104009. /**
  104010. * Binds the material data.
  104011. * @param uniformBuffer defines the Uniform buffer to fill in.
  104012. * @param scene defines the scene the material belongs to.
  104013. * @param engine defines the engine the material belongs to.
  104014. * @param disableBumpMap defines wether the material disables bump or not.
  104015. * @param isFrozen defines wether the material is frozen or not.
  104016. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104017. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104018. */
  104019. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104020. /**
  104021. * Checks to see if a texture is used in the material.
  104022. * @param texture - Base texture to use.
  104023. * @returns - Boolean specifying if a texture is used in the material.
  104024. */
  104025. hasTexture(texture: BaseTexture): boolean;
  104026. /**
  104027. * Returns an array of the actively used textures.
  104028. * @param activeTextures Array of BaseTextures
  104029. */
  104030. getActiveTextures(activeTextures: BaseTexture[]): void;
  104031. /**
  104032. * Returns the animatable textures.
  104033. * @param animatables Array of animatable textures.
  104034. */
  104035. getAnimatables(animatables: IAnimatable[]): void;
  104036. /**
  104037. * Disposes the resources of the material.
  104038. * @param forceDisposeTextures - Forces the disposal of all textures.
  104039. */
  104040. dispose(forceDisposeTextures?: boolean): void;
  104041. /**
  104042. * Get the current class name of the texture useful for serialization or dynamic coding.
  104043. * @returns "PBRClearCoatConfiguration"
  104044. */
  104045. getClassName(): string;
  104046. /**
  104047. * Add fallbacks to the effect fallbacks list.
  104048. * @param defines defines the Base texture to use.
  104049. * @param fallbacks defines the current fallback list.
  104050. * @param currentRank defines the current fallback rank.
  104051. * @returns the new fallback rank.
  104052. */
  104053. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104054. /**
  104055. * Add the required uniforms to the current list.
  104056. * @param uniforms defines the current uniform list.
  104057. */
  104058. static AddUniforms(uniforms: string[]): void;
  104059. /**
  104060. * Add the required samplers to the current list.
  104061. * @param samplers defines the current sampler list.
  104062. */
  104063. static AddSamplers(samplers: string[]): void;
  104064. /**
  104065. * Add the required uniforms to the current buffer.
  104066. * @param uniformBuffer defines the current uniform buffer.
  104067. */
  104068. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104069. /**
  104070. * Makes a duplicate of the current configuration into another one.
  104071. * @param clearCoatConfiguration define the config where to copy the info
  104072. */
  104073. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104074. /**
  104075. * Serializes this clear coat configuration.
  104076. * @returns - An object with the serialized config.
  104077. */
  104078. serialize(): any;
  104079. /**
  104080. * Parses a Clear Coat Configuration from a serialized object.
  104081. * @param source - Serialized object.
  104082. */
  104083. parse(source: any): void;
  104084. }
  104085. }
  104086. declare module BABYLON {
  104087. /**
  104088. * @hidden
  104089. */
  104090. export interface IMaterialAnisotropicDefines {
  104091. ANISOTROPIC: boolean;
  104092. ANISOTROPIC_TEXTURE: boolean;
  104093. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104094. MAINUV1: boolean;
  104095. _areTexturesDirty: boolean;
  104096. _needUVs: boolean;
  104097. }
  104098. /**
  104099. * Define the code related to the anisotropic parameters of the pbr material.
  104100. */
  104101. export class PBRAnisotropicConfiguration {
  104102. private _isEnabled;
  104103. /**
  104104. * Defines if the anisotropy is enabled in the material.
  104105. */
  104106. isEnabled: boolean;
  104107. /**
  104108. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104109. */
  104110. intensity: number;
  104111. /**
  104112. * Defines if the effect is along the tangents, bitangents or in between.
  104113. * By default, the effect is "strectching" the highlights along the tangents.
  104114. */
  104115. direction: Vector2;
  104116. private _texture;
  104117. /**
  104118. * Stores the anisotropy values in a texture.
  104119. * rg is direction (like normal from -1 to 1)
  104120. * b is a intensity
  104121. */
  104122. texture: Nullable<BaseTexture>;
  104123. /** @hidden */
  104124. private _internalMarkAllSubMeshesAsTexturesDirty;
  104125. /** @hidden */
  104126. _markAllSubMeshesAsTexturesDirty(): void;
  104127. /**
  104128. * Instantiate a new istance of anisotropy configuration.
  104129. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104130. */
  104131. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104132. /**
  104133. * Specifies that the submesh is ready to be used.
  104134. * @param defines the list of "defines" to update.
  104135. * @param scene defines the scene the material belongs to.
  104136. * @returns - boolean indicating that the submesh is ready or not.
  104137. */
  104138. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104139. /**
  104140. * Checks to see if a texture is used in the material.
  104141. * @param defines the list of "defines" to update.
  104142. * @param mesh the mesh we are preparing the defines for.
  104143. * @param scene defines the scene the material belongs to.
  104144. */
  104145. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104146. /**
  104147. * Binds the material data.
  104148. * @param uniformBuffer defines the Uniform buffer to fill in.
  104149. * @param scene defines the scene the material belongs to.
  104150. * @param isFrozen defines wether the material is frozen or not.
  104151. */
  104152. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104153. /**
  104154. * Checks to see if a texture is used in the material.
  104155. * @param texture - Base texture to use.
  104156. * @returns - Boolean specifying if a texture is used in the material.
  104157. */
  104158. hasTexture(texture: BaseTexture): boolean;
  104159. /**
  104160. * Returns an array of the actively used textures.
  104161. * @param activeTextures Array of BaseTextures
  104162. */
  104163. getActiveTextures(activeTextures: BaseTexture[]): void;
  104164. /**
  104165. * Returns the animatable textures.
  104166. * @param animatables Array of animatable textures.
  104167. */
  104168. getAnimatables(animatables: IAnimatable[]): void;
  104169. /**
  104170. * Disposes the resources of the material.
  104171. * @param forceDisposeTextures - Forces the disposal of all textures.
  104172. */
  104173. dispose(forceDisposeTextures?: boolean): void;
  104174. /**
  104175. * Get the current class name of the texture useful for serialization or dynamic coding.
  104176. * @returns "PBRAnisotropicConfiguration"
  104177. */
  104178. getClassName(): string;
  104179. /**
  104180. * Add fallbacks to the effect fallbacks list.
  104181. * @param defines defines the Base texture to use.
  104182. * @param fallbacks defines the current fallback list.
  104183. * @param currentRank defines the current fallback rank.
  104184. * @returns the new fallback rank.
  104185. */
  104186. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104187. /**
  104188. * Add the required uniforms to the current list.
  104189. * @param uniforms defines the current uniform list.
  104190. */
  104191. static AddUniforms(uniforms: string[]): void;
  104192. /**
  104193. * Add the required uniforms to the current buffer.
  104194. * @param uniformBuffer defines the current uniform buffer.
  104195. */
  104196. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104197. /**
  104198. * Add the required samplers to the current list.
  104199. * @param samplers defines the current sampler list.
  104200. */
  104201. static AddSamplers(samplers: string[]): void;
  104202. /**
  104203. * Makes a duplicate of the current configuration into another one.
  104204. * @param anisotropicConfiguration define the config where to copy the info
  104205. */
  104206. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104207. /**
  104208. * Serializes this anisotropy configuration.
  104209. * @returns - An object with the serialized config.
  104210. */
  104211. serialize(): any;
  104212. /**
  104213. * Parses a anisotropy Configuration from a serialized object.
  104214. * @param source - Serialized object.
  104215. */
  104216. parse(source: any): void;
  104217. }
  104218. }
  104219. declare module BABYLON {
  104220. /**
  104221. * @hidden
  104222. */
  104223. export interface IMaterialBRDFDefines {
  104224. BRDF_V_HEIGHT_CORRELATED: boolean;
  104225. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104226. SPHERICAL_HARMONICS: boolean;
  104227. /** @hidden */
  104228. _areMiscDirty: boolean;
  104229. }
  104230. /**
  104231. * Define the code related to the BRDF parameters of the pbr material.
  104232. */
  104233. export class PBRBRDFConfiguration {
  104234. /**
  104235. * Default value used for the energy conservation.
  104236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104237. */
  104238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104239. /**
  104240. * Default value used for the Smith Visibility Height Correlated mode.
  104241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104242. */
  104243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104244. /**
  104245. * Default value used for the IBL diffuse part.
  104246. * This can help switching back to the polynomials mode globally which is a tiny bit
  104247. * less GPU intensive at the drawback of a lower quality.
  104248. */
  104249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104250. private _useEnergyConservation;
  104251. /**
  104252. * Defines if the material uses energy conservation.
  104253. */
  104254. useEnergyConservation: boolean;
  104255. private _useSmithVisibilityHeightCorrelated;
  104256. /**
  104257. * LEGACY Mode set to false
  104258. * Defines if the material uses height smith correlated visibility term.
  104259. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104260. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104261. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104262. * Not relying on height correlated will also disable energy conservation.
  104263. */
  104264. useSmithVisibilityHeightCorrelated: boolean;
  104265. private _useSphericalHarmonics;
  104266. /**
  104267. * LEGACY Mode set to false
  104268. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104269. * diffuse part of the IBL.
  104270. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104271. * to the ground truth.
  104272. */
  104273. useSphericalHarmonics: boolean;
  104274. /** @hidden */
  104275. private _internalMarkAllSubMeshesAsMiscDirty;
  104276. /** @hidden */
  104277. _markAllSubMeshesAsMiscDirty(): void;
  104278. /**
  104279. * Instantiate a new istance of clear coat configuration.
  104280. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104281. */
  104282. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104283. /**
  104284. * Checks to see if a texture is used in the material.
  104285. * @param defines the list of "defines" to update.
  104286. */
  104287. prepareDefines(defines: IMaterialBRDFDefines): void;
  104288. /**
  104289. * Get the current class name of the texture useful for serialization or dynamic coding.
  104290. * @returns "PBRClearCoatConfiguration"
  104291. */
  104292. getClassName(): string;
  104293. /**
  104294. * Makes a duplicate of the current configuration into another one.
  104295. * @param brdfConfiguration define the config where to copy the info
  104296. */
  104297. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104298. /**
  104299. * Serializes this BRDF configuration.
  104300. * @returns - An object with the serialized config.
  104301. */
  104302. serialize(): any;
  104303. /**
  104304. * Parses a BRDF Configuration from a serialized object.
  104305. * @param source - Serialized object.
  104306. */
  104307. parse(source: any): void;
  104308. }
  104309. }
  104310. declare module BABYLON {
  104311. /**
  104312. * @hidden
  104313. */
  104314. export interface IMaterialSheenDefines {
  104315. SHEEN: boolean;
  104316. SHEEN_TEXTURE: boolean;
  104317. SHEEN_TEXTUREDIRECTUV: number;
  104318. SHEEN_LINKWITHALBEDO: boolean;
  104319. /** @hidden */
  104320. _areTexturesDirty: boolean;
  104321. }
  104322. /**
  104323. * Define the code related to the Sheen parameters of the pbr material.
  104324. */
  104325. export class PBRSheenConfiguration {
  104326. private _isEnabled;
  104327. /**
  104328. * Defines if the material uses sheen.
  104329. */
  104330. isEnabled: boolean;
  104331. private _linkSheenWithAlbedo;
  104332. /**
  104333. * Defines if the sheen is linked to the sheen color.
  104334. */
  104335. linkSheenWithAlbedo: boolean;
  104336. /**
  104337. * Defines the sheen intensity.
  104338. */
  104339. intensity: number;
  104340. /**
  104341. * Defines the sheen color.
  104342. */
  104343. color: Color3;
  104344. private _texture;
  104345. /**
  104346. * Stores the sheen tint values in a texture.
  104347. * rgb is tint
  104348. * a is a intensity
  104349. */
  104350. texture: Nullable<BaseTexture>;
  104351. /** @hidden */
  104352. private _internalMarkAllSubMeshesAsTexturesDirty;
  104353. /** @hidden */
  104354. _markAllSubMeshesAsTexturesDirty(): void;
  104355. /**
  104356. * Instantiate a new istance of clear coat configuration.
  104357. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104358. */
  104359. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104360. /**
  104361. * Specifies that the submesh is ready to be used.
  104362. * @param defines the list of "defines" to update.
  104363. * @param scene defines the scene the material belongs to.
  104364. * @returns - boolean indicating that the submesh is ready or not.
  104365. */
  104366. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104367. /**
  104368. * Checks to see if a texture is used in the material.
  104369. * @param defines the list of "defines" to update.
  104370. * @param scene defines the scene the material belongs to.
  104371. */
  104372. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104373. /**
  104374. * Binds the material data.
  104375. * @param uniformBuffer defines the Uniform buffer to fill in.
  104376. * @param scene defines the scene the material belongs to.
  104377. * @param isFrozen defines wether the material is frozen or not.
  104378. */
  104379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104380. /**
  104381. * Checks to see if a texture is used in the material.
  104382. * @param texture - Base texture to use.
  104383. * @returns - Boolean specifying if a texture is used in the material.
  104384. */
  104385. hasTexture(texture: BaseTexture): boolean;
  104386. /**
  104387. * Returns an array of the actively used textures.
  104388. * @param activeTextures Array of BaseTextures
  104389. */
  104390. getActiveTextures(activeTextures: BaseTexture[]): void;
  104391. /**
  104392. * Returns the animatable textures.
  104393. * @param animatables Array of animatable textures.
  104394. */
  104395. getAnimatables(animatables: IAnimatable[]): void;
  104396. /**
  104397. * Disposes the resources of the material.
  104398. * @param forceDisposeTextures - Forces the disposal of all textures.
  104399. */
  104400. dispose(forceDisposeTextures?: boolean): void;
  104401. /**
  104402. * Get the current class name of the texture useful for serialization or dynamic coding.
  104403. * @returns "PBRSheenConfiguration"
  104404. */
  104405. getClassName(): string;
  104406. /**
  104407. * Add fallbacks to the effect fallbacks list.
  104408. * @param defines defines the Base texture to use.
  104409. * @param fallbacks defines the current fallback list.
  104410. * @param currentRank defines the current fallback rank.
  104411. * @returns the new fallback rank.
  104412. */
  104413. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104414. /**
  104415. * Add the required uniforms to the current list.
  104416. * @param uniforms defines the current uniform list.
  104417. */
  104418. static AddUniforms(uniforms: string[]): void;
  104419. /**
  104420. * Add the required uniforms to the current buffer.
  104421. * @param uniformBuffer defines the current uniform buffer.
  104422. */
  104423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104424. /**
  104425. * Add the required samplers to the current list.
  104426. * @param samplers defines the current sampler list.
  104427. */
  104428. static AddSamplers(samplers: string[]): void;
  104429. /**
  104430. * Makes a duplicate of the current configuration into another one.
  104431. * @param sheenConfiguration define the config where to copy the info
  104432. */
  104433. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104434. /**
  104435. * Serializes this BRDF configuration.
  104436. * @returns - An object with the serialized config.
  104437. */
  104438. serialize(): any;
  104439. /**
  104440. * Parses a Sheen Configuration from a serialized object.
  104441. * @param source - Serialized object.
  104442. */
  104443. parse(source: any): void;
  104444. }
  104445. }
  104446. declare module BABYLON {
  104447. /**
  104448. * @hidden
  104449. */
  104450. export interface IMaterialSubSurfaceDefines {
  104451. SUBSURFACE: boolean;
  104452. SS_REFRACTION: boolean;
  104453. SS_TRANSLUCENCY: boolean;
  104454. SS_SCATERRING: boolean;
  104455. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104456. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104457. SS_REFRACTIONMAP_3D: boolean;
  104458. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104459. SS_LODINREFRACTIONALPHA: boolean;
  104460. SS_GAMMAREFRACTION: boolean;
  104461. SS_RGBDREFRACTION: boolean;
  104462. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104463. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104464. /** @hidden */
  104465. _areTexturesDirty: boolean;
  104466. }
  104467. /**
  104468. * Define the code related to the sub surface parameters of the pbr material.
  104469. */
  104470. export class PBRSubSurfaceConfiguration {
  104471. private _isRefractionEnabled;
  104472. /**
  104473. * Defines if the refraction is enabled in the material.
  104474. */
  104475. isRefractionEnabled: boolean;
  104476. private _isTranslucencyEnabled;
  104477. /**
  104478. * Defines if the translucency is enabled in the material.
  104479. */
  104480. isTranslucencyEnabled: boolean;
  104481. private _isScatteringEnabled;
  104482. /**
  104483. * Defines the refraction intensity of the material.
  104484. * The refraction when enabled replaces the Diffuse part of the material.
  104485. * The intensity helps transitionning between diffuse and refraction.
  104486. */
  104487. refractionIntensity: number;
  104488. /**
  104489. * Defines the translucency intensity of the material.
  104490. * When translucency has been enabled, this defines how much of the "translucency"
  104491. * is addded to the diffuse part of the material.
  104492. */
  104493. translucencyIntensity: number;
  104494. /**
  104495. * Defines the scattering intensity of the material.
  104496. * When scattering has been enabled, this defines how much of the "scattered light"
  104497. * is addded to the diffuse part of the material.
  104498. */
  104499. scatteringIntensity: number;
  104500. private _thicknessTexture;
  104501. /**
  104502. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104503. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104504. * 0 would mean minimumThickness
  104505. * 1 would mean maximumThickness
  104506. * The other channels might be use as a mask to vary the different effects intensity.
  104507. */
  104508. thicknessTexture: Nullable<BaseTexture>;
  104509. private _refractionTexture;
  104510. /**
  104511. * Defines the texture to use for refraction.
  104512. */
  104513. refractionTexture: Nullable<BaseTexture>;
  104514. private _indexOfRefraction;
  104515. /**
  104516. * Defines the indice of refraction used in the material.
  104517. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104518. */
  104519. indexOfRefraction: number;
  104520. private _invertRefractionY;
  104521. /**
  104522. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104523. */
  104524. invertRefractionY: boolean;
  104525. private _linkRefractionWithTransparency;
  104526. /**
  104527. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104528. * Materials half opaque for instance using refraction could benefit from this control.
  104529. */
  104530. linkRefractionWithTransparency: boolean;
  104531. /**
  104532. * Defines the minimum thickness stored in the thickness map.
  104533. * If no thickness map is defined, this value will be used to simulate thickness.
  104534. */
  104535. minimumThickness: number;
  104536. /**
  104537. * Defines the maximum thickness stored in the thickness map.
  104538. */
  104539. maximumThickness: number;
  104540. /**
  104541. * Defines the volume tint of the material.
  104542. * This is used for both translucency and scattering.
  104543. */
  104544. tintColor: Color3;
  104545. /**
  104546. * Defines the distance at which the tint color should be found in the media.
  104547. * This is used for refraction only.
  104548. */
  104549. tintColorAtDistance: number;
  104550. /**
  104551. * Defines how far each channel transmit through the media.
  104552. * It is defined as a color to simplify it selection.
  104553. */
  104554. diffusionDistance: Color3;
  104555. private _useMaskFromThicknessTexture;
  104556. /**
  104557. * Stores the intensity of the different subsurface effects in the thickness texture.
  104558. * * the green channel is the translucency intensity.
  104559. * * the blue channel is the scattering intensity.
  104560. * * the alpha channel is the refraction intensity.
  104561. */
  104562. useMaskFromThicknessTexture: boolean;
  104563. /** @hidden */
  104564. private _internalMarkAllSubMeshesAsTexturesDirty;
  104565. /** @hidden */
  104566. _markAllSubMeshesAsTexturesDirty(): void;
  104567. /**
  104568. * Instantiate a new istance of sub surface configuration.
  104569. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104570. */
  104571. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104572. /**
  104573. * Gets wehter the submesh is ready to be used or not.
  104574. * @param defines the list of "defines" to update.
  104575. * @param scene defines the scene the material belongs to.
  104576. * @returns - boolean indicating that the submesh is ready or not.
  104577. */
  104578. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104579. /**
  104580. * Checks to see if a texture is used in the material.
  104581. * @param defines the list of "defines" to update.
  104582. * @param scene defines the scene to the material belongs to.
  104583. */
  104584. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104585. /**
  104586. * Binds the material data.
  104587. * @param uniformBuffer defines the Uniform buffer to fill in.
  104588. * @param scene defines the scene the material belongs to.
  104589. * @param engine defines the engine the material belongs to.
  104590. * @param isFrozen defines wether the material is frozen or not.
  104591. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104592. */
  104593. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104594. /**
  104595. * Unbinds the material from the mesh.
  104596. * @param activeEffect defines the effect that should be unbound from.
  104597. * @returns true if unbound, otherwise false
  104598. */
  104599. unbind(activeEffect: Effect): boolean;
  104600. /**
  104601. * Returns the texture used for refraction or null if none is used.
  104602. * @param scene defines the scene the material belongs to.
  104603. * @returns - Refraction texture if present. If no refraction texture and refraction
  104604. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104605. */
  104606. private _getRefractionTexture;
  104607. /**
  104608. * Returns true if alpha blending should be disabled.
  104609. */
  104610. readonly disableAlphaBlending: boolean;
  104611. /**
  104612. * Fills the list of render target textures.
  104613. * @param renderTargets the list of render targets to update
  104614. */
  104615. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104616. /**
  104617. * Checks to see if a texture is used in the material.
  104618. * @param texture - Base texture to use.
  104619. * @returns - Boolean specifying if a texture is used in the material.
  104620. */
  104621. hasTexture(texture: BaseTexture): boolean;
  104622. /**
  104623. * Gets a boolean indicating that current material needs to register RTT
  104624. * @returns true if this uses a render target otherwise false.
  104625. */
  104626. hasRenderTargetTextures(): boolean;
  104627. /**
  104628. * Returns an array of the actively used textures.
  104629. * @param activeTextures Array of BaseTextures
  104630. */
  104631. getActiveTextures(activeTextures: BaseTexture[]): void;
  104632. /**
  104633. * Returns the animatable textures.
  104634. * @param animatables Array of animatable textures.
  104635. */
  104636. getAnimatables(animatables: IAnimatable[]): void;
  104637. /**
  104638. * Disposes the resources of the material.
  104639. * @param forceDisposeTextures - Forces the disposal of all textures.
  104640. */
  104641. dispose(forceDisposeTextures?: boolean): void;
  104642. /**
  104643. * Get the current class name of the texture useful for serialization or dynamic coding.
  104644. * @returns "PBRSubSurfaceConfiguration"
  104645. */
  104646. getClassName(): string;
  104647. /**
  104648. * Add fallbacks to the effect fallbacks list.
  104649. * @param defines defines the Base texture to use.
  104650. * @param fallbacks defines the current fallback list.
  104651. * @param currentRank defines the current fallback rank.
  104652. * @returns the new fallback rank.
  104653. */
  104654. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104655. /**
  104656. * Add the required uniforms to the current list.
  104657. * @param uniforms defines the current uniform list.
  104658. */
  104659. static AddUniforms(uniforms: string[]): void;
  104660. /**
  104661. * Add the required samplers to the current list.
  104662. * @param samplers defines the current sampler list.
  104663. */
  104664. static AddSamplers(samplers: string[]): void;
  104665. /**
  104666. * Add the required uniforms to the current buffer.
  104667. * @param uniformBuffer defines the current uniform buffer.
  104668. */
  104669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104670. /**
  104671. * Makes a duplicate of the current configuration into another one.
  104672. * @param configuration define the config where to copy the info
  104673. */
  104674. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104675. /**
  104676. * Serializes this Sub Surface configuration.
  104677. * @returns - An object with the serialized config.
  104678. */
  104679. serialize(): any;
  104680. /**
  104681. * Parses a Sub Surface Configuration from a serialized object.
  104682. * @param source - Serialized object.
  104683. */
  104684. parse(source: any): void;
  104685. }
  104686. }
  104687. declare module BABYLON {
  104688. /** @hidden */
  104689. export var pbrFragmentDeclaration: {
  104690. name: string;
  104691. shader: string;
  104692. };
  104693. }
  104694. declare module BABYLON {
  104695. /** @hidden */
  104696. export var pbrUboDeclaration: {
  104697. name: string;
  104698. shader: string;
  104699. };
  104700. }
  104701. declare module BABYLON {
  104702. /** @hidden */
  104703. export var pbrFragmentExtraDeclaration: {
  104704. name: string;
  104705. shader: string;
  104706. };
  104707. }
  104708. declare module BABYLON {
  104709. /** @hidden */
  104710. export var pbrFragmentSamplersDeclaration: {
  104711. name: string;
  104712. shader: string;
  104713. };
  104714. }
  104715. declare module BABYLON {
  104716. /** @hidden */
  104717. export var pbrHelperFunctions: {
  104718. name: string;
  104719. shader: string;
  104720. };
  104721. }
  104722. declare module BABYLON {
  104723. /** @hidden */
  104724. export var harmonicsFunctions: {
  104725. name: string;
  104726. shader: string;
  104727. };
  104728. }
  104729. declare module BABYLON {
  104730. /** @hidden */
  104731. export var pbrDirectLightingSetupFunctions: {
  104732. name: string;
  104733. shader: string;
  104734. };
  104735. }
  104736. declare module BABYLON {
  104737. /** @hidden */
  104738. export var pbrDirectLightingFalloffFunctions: {
  104739. name: string;
  104740. shader: string;
  104741. };
  104742. }
  104743. declare module BABYLON {
  104744. /** @hidden */
  104745. export var pbrBRDFFunctions: {
  104746. name: string;
  104747. shader: string;
  104748. };
  104749. }
  104750. declare module BABYLON {
  104751. /** @hidden */
  104752. export var pbrDirectLightingFunctions: {
  104753. name: string;
  104754. shader: string;
  104755. };
  104756. }
  104757. declare module BABYLON {
  104758. /** @hidden */
  104759. export var pbrIBLFunctions: {
  104760. name: string;
  104761. shader: string;
  104762. };
  104763. }
  104764. declare module BABYLON {
  104765. /** @hidden */
  104766. export var pbrDebug: {
  104767. name: string;
  104768. shader: string;
  104769. };
  104770. }
  104771. declare module BABYLON {
  104772. /** @hidden */
  104773. export var pbrPixelShader: {
  104774. name: string;
  104775. shader: string;
  104776. };
  104777. }
  104778. declare module BABYLON {
  104779. /** @hidden */
  104780. export var pbrVertexDeclaration: {
  104781. name: string;
  104782. shader: string;
  104783. };
  104784. }
  104785. declare module BABYLON {
  104786. /** @hidden */
  104787. export var pbrVertexShader: {
  104788. name: string;
  104789. shader: string;
  104790. };
  104791. }
  104792. declare module BABYLON {
  104793. /**
  104794. * Manages the defines for the PBR Material.
  104795. * @hidden
  104796. */
  104797. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104798. PBR: boolean;
  104799. MAINUV1: boolean;
  104800. MAINUV2: boolean;
  104801. UV1: boolean;
  104802. UV2: boolean;
  104803. ALBEDO: boolean;
  104804. ALBEDODIRECTUV: number;
  104805. VERTEXCOLOR: boolean;
  104806. AMBIENT: boolean;
  104807. AMBIENTDIRECTUV: number;
  104808. AMBIENTINGRAYSCALE: boolean;
  104809. OPACITY: boolean;
  104810. VERTEXALPHA: boolean;
  104811. OPACITYDIRECTUV: number;
  104812. OPACITYRGB: boolean;
  104813. ALPHATEST: boolean;
  104814. DEPTHPREPASS: boolean;
  104815. ALPHABLEND: boolean;
  104816. ALPHAFROMALBEDO: boolean;
  104817. ALPHATESTVALUE: string;
  104818. SPECULAROVERALPHA: boolean;
  104819. RADIANCEOVERALPHA: boolean;
  104820. ALPHAFRESNEL: boolean;
  104821. LINEARALPHAFRESNEL: boolean;
  104822. PREMULTIPLYALPHA: boolean;
  104823. EMISSIVE: boolean;
  104824. EMISSIVEDIRECTUV: number;
  104825. REFLECTIVITY: boolean;
  104826. REFLECTIVITYDIRECTUV: number;
  104827. SPECULARTERM: boolean;
  104828. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104829. MICROSURFACEAUTOMATIC: boolean;
  104830. LODBASEDMICROSFURACE: boolean;
  104831. MICROSURFACEMAP: boolean;
  104832. MICROSURFACEMAPDIRECTUV: number;
  104833. METALLICWORKFLOW: boolean;
  104834. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104835. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104836. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104837. AOSTOREINMETALMAPRED: boolean;
  104838. ENVIRONMENTBRDF: boolean;
  104839. ENVIRONMENTBRDF_RGBD: boolean;
  104840. NORMAL: boolean;
  104841. TANGENT: boolean;
  104842. BUMP: boolean;
  104843. BUMPDIRECTUV: number;
  104844. OBJECTSPACE_NORMALMAP: boolean;
  104845. PARALLAX: boolean;
  104846. PARALLAXOCCLUSION: boolean;
  104847. NORMALXYSCALE: boolean;
  104848. LIGHTMAP: boolean;
  104849. LIGHTMAPDIRECTUV: number;
  104850. USELIGHTMAPASSHADOWMAP: boolean;
  104851. GAMMALIGHTMAP: boolean;
  104852. REFLECTION: boolean;
  104853. REFLECTIONMAP_3D: boolean;
  104854. REFLECTIONMAP_SPHERICAL: boolean;
  104855. REFLECTIONMAP_PLANAR: boolean;
  104856. REFLECTIONMAP_CUBIC: boolean;
  104857. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104858. REFLECTIONMAP_PROJECTION: boolean;
  104859. REFLECTIONMAP_SKYBOX: boolean;
  104860. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104861. REFLECTIONMAP_EXPLICIT: boolean;
  104862. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104863. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104864. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104865. INVERTCUBICMAP: boolean;
  104866. USESPHERICALFROMREFLECTIONMAP: boolean;
  104867. SPHERICAL_HARMONICS: boolean;
  104868. USESPHERICALINVERTEX: boolean;
  104869. REFLECTIONMAP_OPPOSITEZ: boolean;
  104870. LODINREFLECTIONALPHA: boolean;
  104871. GAMMAREFLECTION: boolean;
  104872. RGBDREFLECTION: boolean;
  104873. RADIANCEOCCLUSION: boolean;
  104874. HORIZONOCCLUSION: boolean;
  104875. INSTANCES: boolean;
  104876. NUM_BONE_INFLUENCERS: number;
  104877. BonesPerMesh: number;
  104878. BONETEXTURE: boolean;
  104879. NONUNIFORMSCALING: boolean;
  104880. MORPHTARGETS: boolean;
  104881. MORPHTARGETS_NORMAL: boolean;
  104882. MORPHTARGETS_TANGENT: boolean;
  104883. NUM_MORPH_INFLUENCERS: number;
  104884. IMAGEPROCESSING: boolean;
  104885. VIGNETTE: boolean;
  104886. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104887. VIGNETTEBLENDMODEOPAQUE: boolean;
  104888. TONEMAPPING: boolean;
  104889. TONEMAPPING_ACES: boolean;
  104890. CONTRAST: boolean;
  104891. COLORCURVES: boolean;
  104892. COLORGRADING: boolean;
  104893. COLORGRADING3D: boolean;
  104894. SAMPLER3DGREENDEPTH: boolean;
  104895. SAMPLER3DBGRMAP: boolean;
  104896. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104897. EXPOSURE: boolean;
  104898. MULTIVIEW: boolean;
  104899. USEPHYSICALLIGHTFALLOFF: boolean;
  104900. USEGLTFLIGHTFALLOFF: boolean;
  104901. TWOSIDEDLIGHTING: boolean;
  104902. SHADOWFLOAT: boolean;
  104903. CLIPPLANE: boolean;
  104904. CLIPPLANE2: boolean;
  104905. CLIPPLANE3: boolean;
  104906. CLIPPLANE4: boolean;
  104907. POINTSIZE: boolean;
  104908. FOG: boolean;
  104909. LOGARITHMICDEPTH: boolean;
  104910. FORCENORMALFORWARD: boolean;
  104911. SPECULARAA: boolean;
  104912. CLEARCOAT: boolean;
  104913. CLEARCOAT_DEFAULTIOR: boolean;
  104914. CLEARCOAT_TEXTURE: boolean;
  104915. CLEARCOAT_TEXTUREDIRECTUV: number;
  104916. CLEARCOAT_BUMP: boolean;
  104917. CLEARCOAT_BUMPDIRECTUV: number;
  104918. CLEARCOAT_TINT: boolean;
  104919. CLEARCOAT_TINT_TEXTURE: boolean;
  104920. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104921. ANISOTROPIC: boolean;
  104922. ANISOTROPIC_TEXTURE: boolean;
  104923. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104924. BRDF_V_HEIGHT_CORRELATED: boolean;
  104925. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104926. SHEEN: boolean;
  104927. SHEEN_TEXTURE: boolean;
  104928. SHEEN_TEXTUREDIRECTUV: number;
  104929. SHEEN_LINKWITHALBEDO: boolean;
  104930. SUBSURFACE: boolean;
  104931. SS_REFRACTION: boolean;
  104932. SS_TRANSLUCENCY: boolean;
  104933. SS_SCATERRING: boolean;
  104934. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104935. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104936. SS_REFRACTIONMAP_3D: boolean;
  104937. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104938. SS_LODINREFRACTIONALPHA: boolean;
  104939. SS_GAMMAREFRACTION: boolean;
  104940. SS_RGBDREFRACTION: boolean;
  104941. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104942. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104943. UNLIT: boolean;
  104944. DEBUGMODE: number;
  104945. /**
  104946. * Initializes the PBR Material defines.
  104947. */
  104948. constructor();
  104949. /**
  104950. * Resets the PBR Material defines.
  104951. */
  104952. reset(): void;
  104953. }
  104954. /**
  104955. * The Physically based material base class of BJS.
  104956. *
  104957. * This offers the main features of a standard PBR material.
  104958. * For more information, please refer to the documentation :
  104959. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104960. */
  104961. export abstract class PBRBaseMaterial extends PushMaterial {
  104962. /**
  104963. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104964. */
  104965. static readonly PBRMATERIAL_OPAQUE: number;
  104966. /**
  104967. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104968. */
  104969. static readonly PBRMATERIAL_ALPHATEST: number;
  104970. /**
  104971. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104972. */
  104973. static readonly PBRMATERIAL_ALPHABLEND: number;
  104974. /**
  104975. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104976. * They are also discarded below the alpha cutoff threshold to improve performances.
  104977. */
  104978. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104979. /**
  104980. * Defines the default value of how much AO map is occluding the analytical lights
  104981. * (point spot...).
  104982. */
  104983. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104984. /**
  104985. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104986. */
  104987. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104988. /**
  104989. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104990. * to enhance interoperability with other engines.
  104991. */
  104992. static readonly LIGHTFALLOFF_GLTF: number;
  104993. /**
  104994. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104995. * to enhance interoperability with other materials.
  104996. */
  104997. static readonly LIGHTFALLOFF_STANDARD: number;
  104998. /**
  104999. * Intensity of the direct lights e.g. the four lights available in your scene.
  105000. * This impacts both the direct diffuse and specular highlights.
  105001. */
  105002. protected _directIntensity: number;
  105003. /**
  105004. * Intensity of the emissive part of the material.
  105005. * This helps controlling the emissive effect without modifying the emissive color.
  105006. */
  105007. protected _emissiveIntensity: number;
  105008. /**
  105009. * Intensity of the environment e.g. how much the environment will light the object
  105010. * either through harmonics for rough material or through the refelction for shiny ones.
  105011. */
  105012. protected _environmentIntensity: number;
  105013. /**
  105014. * This is a special control allowing the reduction of the specular highlights coming from the
  105015. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105016. */
  105017. protected _specularIntensity: number;
  105018. /**
  105019. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105020. */
  105021. private _lightingInfos;
  105022. /**
  105023. * Debug Control allowing disabling the bump map on this material.
  105024. */
  105025. protected _disableBumpMap: boolean;
  105026. /**
  105027. * AKA Diffuse Texture in standard nomenclature.
  105028. */
  105029. protected _albedoTexture: Nullable<BaseTexture>;
  105030. /**
  105031. * AKA Occlusion Texture in other nomenclature.
  105032. */
  105033. protected _ambientTexture: Nullable<BaseTexture>;
  105034. /**
  105035. * AKA Occlusion Texture Intensity in other nomenclature.
  105036. */
  105037. protected _ambientTextureStrength: number;
  105038. /**
  105039. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105040. * 1 means it completely occludes it
  105041. * 0 mean it has no impact
  105042. */
  105043. protected _ambientTextureImpactOnAnalyticalLights: number;
  105044. /**
  105045. * Stores the alpha values in a texture.
  105046. */
  105047. protected _opacityTexture: Nullable<BaseTexture>;
  105048. /**
  105049. * Stores the reflection values in a texture.
  105050. */
  105051. protected _reflectionTexture: Nullable<BaseTexture>;
  105052. /**
  105053. * Stores the emissive values in a texture.
  105054. */
  105055. protected _emissiveTexture: Nullable<BaseTexture>;
  105056. /**
  105057. * AKA Specular texture in other nomenclature.
  105058. */
  105059. protected _reflectivityTexture: Nullable<BaseTexture>;
  105060. /**
  105061. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105062. */
  105063. protected _metallicTexture: Nullable<BaseTexture>;
  105064. /**
  105065. * Specifies the metallic scalar of the metallic/roughness workflow.
  105066. * Can also be used to scale the metalness values of the metallic texture.
  105067. */
  105068. protected _metallic: Nullable<number>;
  105069. /**
  105070. * Specifies the roughness scalar of the metallic/roughness workflow.
  105071. * Can also be used to scale the roughness values of the metallic texture.
  105072. */
  105073. protected _roughness: Nullable<number>;
  105074. /**
  105075. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105076. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105077. */
  105078. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105079. /**
  105080. * Stores surface normal data used to displace a mesh in a texture.
  105081. */
  105082. protected _bumpTexture: Nullable<BaseTexture>;
  105083. /**
  105084. * Stores the pre-calculated light information of a mesh in a texture.
  105085. */
  105086. protected _lightmapTexture: Nullable<BaseTexture>;
  105087. /**
  105088. * The color of a material in ambient lighting.
  105089. */
  105090. protected _ambientColor: Color3;
  105091. /**
  105092. * AKA Diffuse Color in other nomenclature.
  105093. */
  105094. protected _albedoColor: Color3;
  105095. /**
  105096. * AKA Specular Color in other nomenclature.
  105097. */
  105098. protected _reflectivityColor: Color3;
  105099. /**
  105100. * The color applied when light is reflected from a material.
  105101. */
  105102. protected _reflectionColor: Color3;
  105103. /**
  105104. * The color applied when light is emitted from a material.
  105105. */
  105106. protected _emissiveColor: Color3;
  105107. /**
  105108. * AKA Glossiness in other nomenclature.
  105109. */
  105110. protected _microSurface: number;
  105111. /**
  105112. * Specifies that the material will use the light map as a show map.
  105113. */
  105114. protected _useLightmapAsShadowmap: boolean;
  105115. /**
  105116. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105117. * makes the reflect vector face the model (under horizon).
  105118. */
  105119. protected _useHorizonOcclusion: boolean;
  105120. /**
  105121. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105122. * too much the area relying on ambient texture to define their ambient occlusion.
  105123. */
  105124. protected _useRadianceOcclusion: boolean;
  105125. /**
  105126. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105127. */
  105128. protected _useAlphaFromAlbedoTexture: boolean;
  105129. /**
  105130. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105131. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105132. */
  105133. protected _useSpecularOverAlpha: boolean;
  105134. /**
  105135. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105136. */
  105137. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105138. /**
  105139. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105140. */
  105141. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105142. /**
  105143. * Specifies if the metallic texture contains the roughness information in its green channel.
  105144. */
  105145. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105146. /**
  105147. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105148. */
  105149. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105150. /**
  105151. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105152. */
  105153. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105154. /**
  105155. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105156. */
  105157. protected _useAmbientInGrayScale: boolean;
  105158. /**
  105159. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105160. * The material will try to infer what glossiness each pixel should be.
  105161. */
  105162. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105163. /**
  105164. * Defines the falloff type used in this material.
  105165. * It by default is Physical.
  105166. */
  105167. protected _lightFalloff: number;
  105168. /**
  105169. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105170. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105171. */
  105172. protected _useRadianceOverAlpha: boolean;
  105173. /**
  105174. * Allows using an object space normal map (instead of tangent space).
  105175. */
  105176. protected _useObjectSpaceNormalMap: boolean;
  105177. /**
  105178. * Allows using the bump map in parallax mode.
  105179. */
  105180. protected _useParallax: boolean;
  105181. /**
  105182. * Allows using the bump map in parallax occlusion mode.
  105183. */
  105184. protected _useParallaxOcclusion: boolean;
  105185. /**
  105186. * Controls the scale bias of the parallax mode.
  105187. */
  105188. protected _parallaxScaleBias: number;
  105189. /**
  105190. * If sets to true, disables all the lights affecting the material.
  105191. */
  105192. protected _disableLighting: boolean;
  105193. /**
  105194. * Number of Simultaneous lights allowed on the material.
  105195. */
  105196. protected _maxSimultaneousLights: number;
  105197. /**
  105198. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105199. */
  105200. protected _invertNormalMapX: boolean;
  105201. /**
  105202. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105203. */
  105204. protected _invertNormalMapY: boolean;
  105205. /**
  105206. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105207. */
  105208. protected _twoSidedLighting: boolean;
  105209. /**
  105210. * Defines the alpha limits in alpha test mode.
  105211. */
  105212. protected _alphaCutOff: number;
  105213. /**
  105214. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105215. */
  105216. protected _forceAlphaTest: boolean;
  105217. /**
  105218. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105219. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105220. */
  105221. protected _useAlphaFresnel: boolean;
  105222. /**
  105223. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105224. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105225. */
  105226. protected _useLinearAlphaFresnel: boolean;
  105227. /**
  105228. * The transparency mode of the material.
  105229. */
  105230. protected _transparencyMode: Nullable<number>;
  105231. /**
  105232. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105233. * from cos thetav and roughness:
  105234. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105235. */
  105236. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105237. /**
  105238. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105239. */
  105240. protected _forceIrradianceInFragment: boolean;
  105241. /**
  105242. * Force normal to face away from face.
  105243. */
  105244. protected _forceNormalForward: boolean;
  105245. /**
  105246. * Enables specular anti aliasing in the PBR shader.
  105247. * It will both interacts on the Geometry for analytical and IBL lighting.
  105248. * It also prefilter the roughness map based on the bump values.
  105249. */
  105250. protected _enableSpecularAntiAliasing: boolean;
  105251. /**
  105252. * Default configuration related to image processing available in the PBR Material.
  105253. */
  105254. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105255. /**
  105256. * Keep track of the image processing observer to allow dispose and replace.
  105257. */
  105258. private _imageProcessingObserver;
  105259. /**
  105260. * Attaches a new image processing configuration to the PBR Material.
  105261. * @param configuration
  105262. */
  105263. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105264. /**
  105265. * Stores the available render targets.
  105266. */
  105267. private _renderTargets;
  105268. /**
  105269. * Sets the global ambient color for the material used in lighting calculations.
  105270. */
  105271. private _globalAmbientColor;
  105272. /**
  105273. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105274. */
  105275. private _useLogarithmicDepth;
  105276. /**
  105277. * If set to true, no lighting calculations will be applied.
  105278. */
  105279. private _unlit;
  105280. private _debugMode;
  105281. /**
  105282. * @hidden
  105283. * This is reserved for the inspector.
  105284. * Defines the material debug mode.
  105285. * It helps seeing only some components of the material while troubleshooting.
  105286. */
  105287. debugMode: number;
  105288. /**
  105289. * @hidden
  105290. * This is reserved for the inspector.
  105291. * Specify from where on screen the debug mode should start.
  105292. * The value goes from -1 (full screen) to 1 (not visible)
  105293. * It helps with side by side comparison against the final render
  105294. * This defaults to -1
  105295. */
  105296. private debugLimit;
  105297. /**
  105298. * @hidden
  105299. * This is reserved for the inspector.
  105300. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105301. * You can use the factor to better multiply the final value.
  105302. */
  105303. private debugFactor;
  105304. /**
  105305. * Defines the clear coat layer parameters for the material.
  105306. */
  105307. readonly clearCoat: PBRClearCoatConfiguration;
  105308. /**
  105309. * Defines the anisotropic parameters for the material.
  105310. */
  105311. readonly anisotropy: PBRAnisotropicConfiguration;
  105312. /**
  105313. * Defines the BRDF parameters for the material.
  105314. */
  105315. readonly brdf: PBRBRDFConfiguration;
  105316. /**
  105317. * Defines the Sheen parameters for the material.
  105318. */
  105319. readonly sheen: PBRSheenConfiguration;
  105320. /**
  105321. * Defines the SubSurface parameters for the material.
  105322. */
  105323. readonly subSurface: PBRSubSurfaceConfiguration;
  105324. /**
  105325. * Custom callback helping to override the default shader used in the material.
  105326. */
  105327. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105328. /**
  105329. * Instantiates a new PBRMaterial instance.
  105330. *
  105331. * @param name The material name
  105332. * @param scene The scene the material will be use in.
  105333. */
  105334. constructor(name: string, scene: Scene);
  105335. /**
  105336. * Gets a boolean indicating that current material needs to register RTT
  105337. */
  105338. readonly hasRenderTargetTextures: boolean;
  105339. /**
  105340. * Gets the name of the material class.
  105341. */
  105342. getClassName(): string;
  105343. /**
  105344. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105345. */
  105346. /**
  105347. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105348. */
  105349. useLogarithmicDepth: boolean;
  105350. /**
  105351. * Gets the current transparency mode.
  105352. */
  105353. /**
  105354. * Sets the transparency mode of the material.
  105355. *
  105356. * | Value | Type | Description |
  105357. * | ----- | ----------------------------------- | ----------- |
  105358. * | 0 | OPAQUE | |
  105359. * | 1 | ALPHATEST | |
  105360. * | 2 | ALPHABLEND | |
  105361. * | 3 | ALPHATESTANDBLEND | |
  105362. *
  105363. */
  105364. transparencyMode: Nullable<number>;
  105365. /**
  105366. * Returns true if alpha blending should be disabled.
  105367. */
  105368. private readonly _disableAlphaBlending;
  105369. /**
  105370. * Specifies whether or not this material should be rendered in alpha blend mode.
  105371. */
  105372. needAlphaBlending(): boolean;
  105373. /**
  105374. * Specifies if the mesh will require alpha blending.
  105375. * @param mesh - BJS mesh.
  105376. */
  105377. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105378. /**
  105379. * Specifies whether or not this material should be rendered in alpha test mode.
  105380. */
  105381. needAlphaTesting(): boolean;
  105382. /**
  105383. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105384. */
  105385. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105386. /**
  105387. * Gets the texture used for the alpha test.
  105388. */
  105389. getAlphaTestTexture(): Nullable<BaseTexture>;
  105390. /**
  105391. * Specifies that the submesh is ready to be used.
  105392. * @param mesh - BJS mesh.
  105393. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105394. * @param useInstances - Specifies that instances should be used.
  105395. * @returns - boolean indicating that the submesh is ready or not.
  105396. */
  105397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105398. /**
  105399. * Specifies if the material uses metallic roughness workflow.
  105400. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105401. */
  105402. isMetallicWorkflow(): boolean;
  105403. private _prepareEffect;
  105404. private _prepareDefines;
  105405. /**
  105406. * Force shader compilation
  105407. */
  105408. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105409. clipPlane: boolean;
  105410. }>): void;
  105411. /**
  105412. * Initializes the uniform buffer layout for the shader.
  105413. */
  105414. buildUniformLayout(): void;
  105415. /**
  105416. * Unbinds the material from the mesh
  105417. */
  105418. unbind(): void;
  105419. /**
  105420. * Binds the submesh data.
  105421. * @param world - The world matrix.
  105422. * @param mesh - The BJS mesh.
  105423. * @param subMesh - A submesh of the BJS mesh.
  105424. */
  105425. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105426. /**
  105427. * Returns the animatable textures.
  105428. * @returns - Array of animatable textures.
  105429. */
  105430. getAnimatables(): IAnimatable[];
  105431. /**
  105432. * Returns the texture used for reflections.
  105433. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105434. */
  105435. private _getReflectionTexture;
  105436. /**
  105437. * Returns an array of the actively used textures.
  105438. * @returns - Array of BaseTextures
  105439. */
  105440. getActiveTextures(): BaseTexture[];
  105441. /**
  105442. * Checks to see if a texture is used in the material.
  105443. * @param texture - Base texture to use.
  105444. * @returns - Boolean specifying if a texture is used in the material.
  105445. */
  105446. hasTexture(texture: BaseTexture): boolean;
  105447. /**
  105448. * Disposes the resources of the material.
  105449. * @param forceDisposeEffect - Forces the disposal of effects.
  105450. * @param forceDisposeTextures - Forces the disposal of all textures.
  105451. */
  105452. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105453. }
  105454. }
  105455. declare module BABYLON {
  105456. /**
  105457. * The Physically based material of BJS.
  105458. *
  105459. * This offers the main features of a standard PBR material.
  105460. * For more information, please refer to the documentation :
  105461. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105462. */
  105463. export class PBRMaterial extends PBRBaseMaterial {
  105464. /**
  105465. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105466. */
  105467. static readonly PBRMATERIAL_OPAQUE: number;
  105468. /**
  105469. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105470. */
  105471. static readonly PBRMATERIAL_ALPHATEST: number;
  105472. /**
  105473. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105474. */
  105475. static readonly PBRMATERIAL_ALPHABLEND: number;
  105476. /**
  105477. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105478. * They are also discarded below the alpha cutoff threshold to improve performances.
  105479. */
  105480. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105481. /**
  105482. * Defines the default value of how much AO map is occluding the analytical lights
  105483. * (point spot...).
  105484. */
  105485. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105486. /**
  105487. * Intensity of the direct lights e.g. the four lights available in your scene.
  105488. * This impacts both the direct diffuse and specular highlights.
  105489. */
  105490. directIntensity: number;
  105491. /**
  105492. * Intensity of the emissive part of the material.
  105493. * This helps controlling the emissive effect without modifying the emissive color.
  105494. */
  105495. emissiveIntensity: number;
  105496. /**
  105497. * Intensity of the environment e.g. how much the environment will light the object
  105498. * either through harmonics for rough material or through the refelction for shiny ones.
  105499. */
  105500. environmentIntensity: number;
  105501. /**
  105502. * This is a special control allowing the reduction of the specular highlights coming from the
  105503. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105504. */
  105505. specularIntensity: number;
  105506. /**
  105507. * Debug Control allowing disabling the bump map on this material.
  105508. */
  105509. disableBumpMap: boolean;
  105510. /**
  105511. * AKA Diffuse Texture in standard nomenclature.
  105512. */
  105513. albedoTexture: BaseTexture;
  105514. /**
  105515. * AKA Occlusion Texture in other nomenclature.
  105516. */
  105517. ambientTexture: BaseTexture;
  105518. /**
  105519. * AKA Occlusion Texture Intensity in other nomenclature.
  105520. */
  105521. ambientTextureStrength: number;
  105522. /**
  105523. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105524. * 1 means it completely occludes it
  105525. * 0 mean it has no impact
  105526. */
  105527. ambientTextureImpactOnAnalyticalLights: number;
  105528. /**
  105529. * Stores the alpha values in a texture.
  105530. */
  105531. opacityTexture: BaseTexture;
  105532. /**
  105533. * Stores the reflection values in a texture.
  105534. */
  105535. reflectionTexture: Nullable<BaseTexture>;
  105536. /**
  105537. * Stores the emissive values in a texture.
  105538. */
  105539. emissiveTexture: BaseTexture;
  105540. /**
  105541. * AKA Specular texture in other nomenclature.
  105542. */
  105543. reflectivityTexture: BaseTexture;
  105544. /**
  105545. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105546. */
  105547. metallicTexture: BaseTexture;
  105548. /**
  105549. * Specifies the metallic scalar of the metallic/roughness workflow.
  105550. * Can also be used to scale the metalness values of the metallic texture.
  105551. */
  105552. metallic: Nullable<number>;
  105553. /**
  105554. * Specifies the roughness scalar of the metallic/roughness workflow.
  105555. * Can also be used to scale the roughness values of the metallic texture.
  105556. */
  105557. roughness: Nullable<number>;
  105558. /**
  105559. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105560. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105561. */
  105562. microSurfaceTexture: BaseTexture;
  105563. /**
  105564. * Stores surface normal data used to displace a mesh in a texture.
  105565. */
  105566. bumpTexture: BaseTexture;
  105567. /**
  105568. * Stores the pre-calculated light information of a mesh in a texture.
  105569. */
  105570. lightmapTexture: BaseTexture;
  105571. /**
  105572. * Stores the refracted light information in a texture.
  105573. */
  105574. refractionTexture: Nullable<BaseTexture>;
  105575. /**
  105576. * The color of a material in ambient lighting.
  105577. */
  105578. ambientColor: Color3;
  105579. /**
  105580. * AKA Diffuse Color in other nomenclature.
  105581. */
  105582. albedoColor: Color3;
  105583. /**
  105584. * AKA Specular Color in other nomenclature.
  105585. */
  105586. reflectivityColor: Color3;
  105587. /**
  105588. * The color reflected from the material.
  105589. */
  105590. reflectionColor: Color3;
  105591. /**
  105592. * The color emitted from the material.
  105593. */
  105594. emissiveColor: Color3;
  105595. /**
  105596. * AKA Glossiness in other nomenclature.
  105597. */
  105598. microSurface: number;
  105599. /**
  105600. * source material index of refraction (IOR)' / 'destination material IOR.
  105601. */
  105602. indexOfRefraction: number;
  105603. /**
  105604. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105605. */
  105606. invertRefractionY: boolean;
  105607. /**
  105608. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105609. * Materials half opaque for instance using refraction could benefit from this control.
  105610. */
  105611. linkRefractionWithTransparency: boolean;
  105612. /**
  105613. * If true, the light map contains occlusion information instead of lighting info.
  105614. */
  105615. useLightmapAsShadowmap: boolean;
  105616. /**
  105617. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105618. */
  105619. useAlphaFromAlbedoTexture: boolean;
  105620. /**
  105621. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105622. */
  105623. forceAlphaTest: boolean;
  105624. /**
  105625. * Defines the alpha limits in alpha test mode.
  105626. */
  105627. alphaCutOff: number;
  105628. /**
  105629. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105630. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105631. */
  105632. useSpecularOverAlpha: boolean;
  105633. /**
  105634. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105635. */
  105636. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105637. /**
  105638. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105639. */
  105640. useRoughnessFromMetallicTextureAlpha: boolean;
  105641. /**
  105642. * Specifies if the metallic texture contains the roughness information in its green channel.
  105643. */
  105644. useRoughnessFromMetallicTextureGreen: boolean;
  105645. /**
  105646. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105647. */
  105648. useMetallnessFromMetallicTextureBlue: boolean;
  105649. /**
  105650. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105651. */
  105652. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105653. /**
  105654. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105655. */
  105656. useAmbientInGrayScale: boolean;
  105657. /**
  105658. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105659. * The material will try to infer what glossiness each pixel should be.
  105660. */
  105661. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105662. /**
  105663. * BJS is using an harcoded light falloff based on a manually sets up range.
  105664. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105665. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105666. */
  105667. /**
  105668. * BJS is using an harcoded light falloff based on a manually sets up range.
  105669. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105670. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105671. */
  105672. usePhysicalLightFalloff: boolean;
  105673. /**
  105674. * In order to support the falloff compatibility with gltf, a special mode has been added
  105675. * to reproduce the gltf light falloff.
  105676. */
  105677. /**
  105678. * In order to support the falloff compatibility with gltf, a special mode has been added
  105679. * to reproduce the gltf light falloff.
  105680. */
  105681. useGLTFLightFalloff: boolean;
  105682. /**
  105683. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105684. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105685. */
  105686. useRadianceOverAlpha: boolean;
  105687. /**
  105688. * Allows using an object space normal map (instead of tangent space).
  105689. */
  105690. useObjectSpaceNormalMap: boolean;
  105691. /**
  105692. * Allows using the bump map in parallax mode.
  105693. */
  105694. useParallax: boolean;
  105695. /**
  105696. * Allows using the bump map in parallax occlusion mode.
  105697. */
  105698. useParallaxOcclusion: boolean;
  105699. /**
  105700. * Controls the scale bias of the parallax mode.
  105701. */
  105702. parallaxScaleBias: number;
  105703. /**
  105704. * If sets to true, disables all the lights affecting the material.
  105705. */
  105706. disableLighting: boolean;
  105707. /**
  105708. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105709. */
  105710. forceIrradianceInFragment: boolean;
  105711. /**
  105712. * Number of Simultaneous lights allowed on the material.
  105713. */
  105714. maxSimultaneousLights: number;
  105715. /**
  105716. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105717. */
  105718. invertNormalMapX: boolean;
  105719. /**
  105720. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105721. */
  105722. invertNormalMapY: boolean;
  105723. /**
  105724. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105725. */
  105726. twoSidedLighting: boolean;
  105727. /**
  105728. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105729. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105730. */
  105731. useAlphaFresnel: boolean;
  105732. /**
  105733. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105734. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105735. */
  105736. useLinearAlphaFresnel: boolean;
  105737. /**
  105738. * Let user defines the brdf lookup texture used for IBL.
  105739. * A default 8bit version is embedded but you could point at :
  105740. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105741. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105742. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105743. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105744. */
  105745. environmentBRDFTexture: Nullable<BaseTexture>;
  105746. /**
  105747. * Force normal to face away from face.
  105748. */
  105749. forceNormalForward: boolean;
  105750. /**
  105751. * Enables specular anti aliasing in the PBR shader.
  105752. * It will both interacts on the Geometry for analytical and IBL lighting.
  105753. * It also prefilter the roughness map based on the bump values.
  105754. */
  105755. enableSpecularAntiAliasing: boolean;
  105756. /**
  105757. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105758. * makes the reflect vector face the model (under horizon).
  105759. */
  105760. useHorizonOcclusion: boolean;
  105761. /**
  105762. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105763. * too much the area relying on ambient texture to define their ambient occlusion.
  105764. */
  105765. useRadianceOcclusion: boolean;
  105766. /**
  105767. * If set to true, no lighting calculations will be applied.
  105768. */
  105769. unlit: boolean;
  105770. /**
  105771. * Gets the image processing configuration used either in this material.
  105772. */
  105773. /**
  105774. * Sets the Default image processing configuration used either in the this material.
  105775. *
  105776. * If sets to null, the scene one is in use.
  105777. */
  105778. imageProcessingConfiguration: ImageProcessingConfiguration;
  105779. /**
  105780. * Gets wether the color curves effect is enabled.
  105781. */
  105782. /**
  105783. * Sets wether the color curves effect is enabled.
  105784. */
  105785. cameraColorCurvesEnabled: boolean;
  105786. /**
  105787. * Gets wether the color grading effect is enabled.
  105788. */
  105789. /**
  105790. * Gets wether the color grading effect is enabled.
  105791. */
  105792. cameraColorGradingEnabled: boolean;
  105793. /**
  105794. * Gets wether tonemapping is enabled or not.
  105795. */
  105796. /**
  105797. * Sets wether tonemapping is enabled or not
  105798. */
  105799. cameraToneMappingEnabled: boolean;
  105800. /**
  105801. * The camera exposure used on this material.
  105802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105803. * This corresponds to a photographic exposure.
  105804. */
  105805. /**
  105806. * The camera exposure used on this material.
  105807. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105808. * This corresponds to a photographic exposure.
  105809. */
  105810. cameraExposure: number;
  105811. /**
  105812. * Gets The camera contrast used on this material.
  105813. */
  105814. /**
  105815. * Sets The camera contrast used on this material.
  105816. */
  105817. cameraContrast: number;
  105818. /**
  105819. * Gets the Color Grading 2D Lookup Texture.
  105820. */
  105821. /**
  105822. * Sets the Color Grading 2D Lookup Texture.
  105823. */
  105824. cameraColorGradingTexture: Nullable<BaseTexture>;
  105825. /**
  105826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105828. * 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;
  105829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105830. */
  105831. /**
  105832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105834. * 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;
  105835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105836. */
  105837. cameraColorCurves: Nullable<ColorCurves>;
  105838. /**
  105839. * Instantiates a new PBRMaterial instance.
  105840. *
  105841. * @param name The material name
  105842. * @param scene The scene the material will be use in.
  105843. */
  105844. constructor(name: string, scene: Scene);
  105845. /**
  105846. * Returns the name of this material class.
  105847. */
  105848. getClassName(): string;
  105849. /**
  105850. * Makes a duplicate of the current material.
  105851. * @param name - name to use for the new material.
  105852. */
  105853. clone(name: string): PBRMaterial;
  105854. /**
  105855. * Serializes this PBR Material.
  105856. * @returns - An object with the serialized material.
  105857. */
  105858. serialize(): any;
  105859. /**
  105860. * Parses a PBR Material from a serialized object.
  105861. * @param source - Serialized object.
  105862. * @param scene - BJS scene instance.
  105863. * @param rootUrl - url for the scene object
  105864. * @returns - PBRMaterial
  105865. */
  105866. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /**
  105871. * Direct draw surface info
  105872. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105873. */
  105874. export interface DDSInfo {
  105875. /**
  105876. * Width of the texture
  105877. */
  105878. width: number;
  105879. /**
  105880. * Width of the texture
  105881. */
  105882. height: number;
  105883. /**
  105884. * Number of Mipmaps for the texture
  105885. * @see https://en.wikipedia.org/wiki/Mipmap
  105886. */
  105887. mipmapCount: number;
  105888. /**
  105889. * If the textures format is a known fourCC format
  105890. * @see https://www.fourcc.org/
  105891. */
  105892. isFourCC: boolean;
  105893. /**
  105894. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105895. */
  105896. isRGB: boolean;
  105897. /**
  105898. * If the texture is a lumincance format
  105899. */
  105900. isLuminance: boolean;
  105901. /**
  105902. * If this is a cube texture
  105903. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105904. */
  105905. isCube: boolean;
  105906. /**
  105907. * If the texture is a compressed format eg. FOURCC_DXT1
  105908. */
  105909. isCompressed: boolean;
  105910. /**
  105911. * The dxgiFormat of the texture
  105912. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105913. */
  105914. dxgiFormat: number;
  105915. /**
  105916. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105917. */
  105918. textureType: number;
  105919. /**
  105920. * Sphericle polynomial created for the dds texture
  105921. */
  105922. sphericalPolynomial?: SphericalPolynomial;
  105923. }
  105924. /**
  105925. * Class used to provide DDS decompression tools
  105926. */
  105927. export class DDSTools {
  105928. /**
  105929. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105930. */
  105931. static StoreLODInAlphaChannel: boolean;
  105932. /**
  105933. * Gets DDS information from an array buffer
  105934. * @param arrayBuffer defines the array buffer to read data from
  105935. * @returns the DDS information
  105936. */
  105937. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105938. private static _FloatView;
  105939. private static _Int32View;
  105940. private static _ToHalfFloat;
  105941. private static _FromHalfFloat;
  105942. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105943. private static _GetHalfFloatRGBAArrayBuffer;
  105944. private static _GetFloatRGBAArrayBuffer;
  105945. private static _GetFloatAsUIntRGBAArrayBuffer;
  105946. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105947. private static _GetRGBAArrayBuffer;
  105948. private static _ExtractLongWordOrder;
  105949. private static _GetRGBArrayBuffer;
  105950. private static _GetLuminanceArrayBuffer;
  105951. /**
  105952. * Uploads DDS Levels to a Babylon Texture
  105953. * @hidden
  105954. */
  105955. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105956. }
  105957. interface Engine {
  105958. /**
  105959. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105960. * @param rootUrl defines the url where the file to load is located
  105961. * @param scene defines the current scene
  105962. * @param lodScale defines scale to apply to the mip map selection
  105963. * @param lodOffset defines offset to apply to the mip map selection
  105964. * @param onLoad defines an optional callback raised when the texture is loaded
  105965. * @param onError defines an optional callback raised if there is an issue to load the texture
  105966. * @param format defines the format of the data
  105967. * @param forcedExtension defines the extension to use to pick the right loader
  105968. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105969. * @returns the cube texture as an InternalTexture
  105970. */
  105971. 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;
  105972. }
  105973. }
  105974. declare module BABYLON {
  105975. /**
  105976. * Implementation of the DDS Texture Loader.
  105977. * @hidden
  105978. */
  105979. export class _DDSTextureLoader implements IInternalTextureLoader {
  105980. /**
  105981. * Defines wether the loader supports cascade loading the different faces.
  105982. */
  105983. readonly supportCascades: boolean;
  105984. /**
  105985. * This returns if the loader support the current file information.
  105986. * @param extension defines the file extension of the file being loaded
  105987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105988. * @param fallback defines the fallback internal texture if any
  105989. * @param isBase64 defines whether the texture is encoded as a base64
  105990. * @param isBuffer defines whether the texture data are stored as a buffer
  105991. * @returns true if the loader can load the specified file
  105992. */
  105993. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105994. /**
  105995. * Transform the url before loading if required.
  105996. * @param rootUrl the url of the texture
  105997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105998. * @returns the transformed texture
  105999. */
  106000. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106001. /**
  106002. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106003. * @param rootUrl the url of the texture
  106004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106005. * @returns the fallback texture
  106006. */
  106007. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106008. /**
  106009. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106010. * @param data contains the texture data
  106011. * @param texture defines the BabylonJS internal texture
  106012. * @param createPolynomials will be true if polynomials have been requested
  106013. * @param onLoad defines the callback to trigger once the texture is ready
  106014. * @param onError defines the callback to trigger in case of error
  106015. */
  106016. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106017. /**
  106018. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106019. * @param data contains the texture data
  106020. * @param texture defines the BabylonJS internal texture
  106021. * @param callback defines the method to call once ready to upload
  106022. */
  106023. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106024. }
  106025. }
  106026. declare module BABYLON {
  106027. /** @hidden */
  106028. export var rgbdEncodePixelShader: {
  106029. name: string;
  106030. shader: string;
  106031. };
  106032. }
  106033. declare module BABYLON {
  106034. /**
  106035. * Raw texture data and descriptor sufficient for WebGL texture upload
  106036. */
  106037. export interface EnvironmentTextureInfo {
  106038. /**
  106039. * Version of the environment map
  106040. */
  106041. version: number;
  106042. /**
  106043. * Width of image
  106044. */
  106045. width: number;
  106046. /**
  106047. * Irradiance information stored in the file.
  106048. */
  106049. irradiance: any;
  106050. /**
  106051. * Specular information stored in the file.
  106052. */
  106053. specular: any;
  106054. }
  106055. /**
  106056. * Sets of helpers addressing the serialization and deserialization of environment texture
  106057. * stored in a BabylonJS env file.
  106058. * Those files are usually stored as .env files.
  106059. */
  106060. export class EnvironmentTextureTools {
  106061. /**
  106062. * Magic number identifying the env file.
  106063. */
  106064. private static _MagicBytes;
  106065. /**
  106066. * Gets the environment info from an env file.
  106067. * @param data The array buffer containing the .env bytes.
  106068. * @returns the environment file info (the json header) if successfully parsed.
  106069. */
  106070. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106071. /**
  106072. * Creates an environment texture from a loaded cube texture.
  106073. * @param texture defines the cube texture to convert in env file
  106074. * @return a promise containing the environment data if succesfull.
  106075. */
  106076. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106077. /**
  106078. * Creates a JSON representation of the spherical data.
  106079. * @param texture defines the texture containing the polynomials
  106080. * @return the JSON representation of the spherical info
  106081. */
  106082. private static _CreateEnvTextureIrradiance;
  106083. /**
  106084. * Uploads the texture info contained in the env file to the GPU.
  106085. * @param texture defines the internal texture to upload to
  106086. * @param arrayBuffer defines the buffer cotaining the data to load
  106087. * @param info defines the texture info retrieved through the GetEnvInfo method
  106088. * @returns a promise
  106089. */
  106090. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106091. /**
  106092. * Uploads the levels of image data to the GPU.
  106093. * @param texture defines the internal texture to upload to
  106094. * @param imageData defines the array buffer views of image data [mipmap][face]
  106095. * @returns a promise
  106096. */
  106097. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106098. /**
  106099. * Uploads spherical polynomials information to the texture.
  106100. * @param texture defines the texture we are trying to upload the information to
  106101. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106102. */
  106103. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106104. /** @hidden */
  106105. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106106. }
  106107. }
  106108. declare module BABYLON {
  106109. /**
  106110. * Implementation of the ENV Texture Loader.
  106111. * @hidden
  106112. */
  106113. export class _ENVTextureLoader implements IInternalTextureLoader {
  106114. /**
  106115. * Defines wether the loader supports cascade loading the different faces.
  106116. */
  106117. readonly supportCascades: boolean;
  106118. /**
  106119. * This returns if the loader support the current file information.
  106120. * @param extension defines the file extension of the file being loaded
  106121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106122. * @param fallback defines the fallback internal texture if any
  106123. * @param isBase64 defines whether the texture is encoded as a base64
  106124. * @param isBuffer defines whether the texture data are stored as a buffer
  106125. * @returns true if the loader can load the specified file
  106126. */
  106127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106128. /**
  106129. * Transform the url before loading if required.
  106130. * @param rootUrl the url of the texture
  106131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106132. * @returns the transformed texture
  106133. */
  106134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106135. /**
  106136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106137. * @param rootUrl the url of the texture
  106138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106139. * @returns the fallback texture
  106140. */
  106141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106142. /**
  106143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106144. * @param data contains the texture data
  106145. * @param texture defines the BabylonJS internal texture
  106146. * @param createPolynomials will be true if polynomials have been requested
  106147. * @param onLoad defines the callback to trigger once the texture is ready
  106148. * @param onError defines the callback to trigger in case of error
  106149. */
  106150. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106151. /**
  106152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106153. * @param data contains the texture data
  106154. * @param texture defines the BabylonJS internal texture
  106155. * @param callback defines the method to call once ready to upload
  106156. */
  106157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106158. }
  106159. }
  106160. declare module BABYLON {
  106161. /**
  106162. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106163. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106164. */
  106165. export class KhronosTextureContainer {
  106166. /** contents of the KTX container file */
  106167. arrayBuffer: any;
  106168. private static HEADER_LEN;
  106169. private static COMPRESSED_2D;
  106170. private static COMPRESSED_3D;
  106171. private static TEX_2D;
  106172. private static TEX_3D;
  106173. /**
  106174. * Gets the openGL type
  106175. */
  106176. glType: number;
  106177. /**
  106178. * Gets the openGL type size
  106179. */
  106180. glTypeSize: number;
  106181. /**
  106182. * Gets the openGL format
  106183. */
  106184. glFormat: number;
  106185. /**
  106186. * Gets the openGL internal format
  106187. */
  106188. glInternalFormat: number;
  106189. /**
  106190. * Gets the base internal format
  106191. */
  106192. glBaseInternalFormat: number;
  106193. /**
  106194. * Gets image width in pixel
  106195. */
  106196. pixelWidth: number;
  106197. /**
  106198. * Gets image height in pixel
  106199. */
  106200. pixelHeight: number;
  106201. /**
  106202. * Gets image depth in pixels
  106203. */
  106204. pixelDepth: number;
  106205. /**
  106206. * Gets the number of array elements
  106207. */
  106208. numberOfArrayElements: number;
  106209. /**
  106210. * Gets the number of faces
  106211. */
  106212. numberOfFaces: number;
  106213. /**
  106214. * Gets the number of mipmap levels
  106215. */
  106216. numberOfMipmapLevels: number;
  106217. /**
  106218. * Gets the bytes of key value data
  106219. */
  106220. bytesOfKeyValueData: number;
  106221. /**
  106222. * Gets the load type
  106223. */
  106224. loadType: number;
  106225. /**
  106226. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106227. */
  106228. isInvalid: boolean;
  106229. /**
  106230. * Creates a new KhronosTextureContainer
  106231. * @param arrayBuffer contents of the KTX container file
  106232. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106233. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106234. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106235. */
  106236. constructor(
  106237. /** contents of the KTX container file */
  106238. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106239. /**
  106240. * Uploads KTX content to a Babylon Texture.
  106241. * It is assumed that the texture has already been created & is currently bound
  106242. * @hidden
  106243. */
  106244. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106245. private _upload2DCompressedLevels;
  106246. }
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * Implementation of the KTX Texture Loader.
  106251. * @hidden
  106252. */
  106253. export class _KTXTextureLoader implements IInternalTextureLoader {
  106254. /**
  106255. * Defines wether the loader supports cascade loading the different faces.
  106256. */
  106257. readonly supportCascades: boolean;
  106258. /**
  106259. * This returns if the loader support the current file information.
  106260. * @param extension defines the file extension of the file being loaded
  106261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106262. * @param fallback defines the fallback internal texture if any
  106263. * @param isBase64 defines whether the texture is encoded as a base64
  106264. * @param isBuffer defines whether the texture data are stored as a buffer
  106265. * @returns true if the loader can load the specified file
  106266. */
  106267. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106268. /**
  106269. * Transform the url before loading if required.
  106270. * @param rootUrl the url of the texture
  106271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106272. * @returns the transformed texture
  106273. */
  106274. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106275. /**
  106276. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106277. * @param rootUrl the url of the texture
  106278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106279. * @returns the fallback texture
  106280. */
  106281. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106282. /**
  106283. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106284. * @param data contains the texture data
  106285. * @param texture defines the BabylonJS internal texture
  106286. * @param createPolynomials will be true if polynomials have been requested
  106287. * @param onLoad defines the callback to trigger once the texture is ready
  106288. * @param onError defines the callback to trigger in case of error
  106289. */
  106290. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106291. /**
  106292. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106293. * @param data contains the texture data
  106294. * @param texture defines the BabylonJS internal texture
  106295. * @param callback defines the method to call once ready to upload
  106296. */
  106297. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106298. }
  106299. }
  106300. declare module BABYLON {
  106301. /** @hidden */
  106302. export var _forceSceneHelpersToBundle: boolean;
  106303. interface Scene {
  106304. /**
  106305. * Creates a default light for the scene.
  106306. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106307. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106308. */
  106309. createDefaultLight(replace?: boolean): void;
  106310. /**
  106311. * Creates a default camera for the scene.
  106312. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106313. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106314. * @param replace has default false, when true replaces the active camera in the scene
  106315. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106316. */
  106317. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106318. /**
  106319. * Creates a default camera and a default light.
  106320. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106321. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106322. * @param replace has the default false, when true replaces the active camera/light in the scene
  106323. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106324. */
  106325. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106326. /**
  106327. * Creates a new sky box
  106328. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106329. * @param environmentTexture defines the texture to use as environment texture
  106330. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106331. * @param scale defines the overall scale of the skybox
  106332. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106333. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106334. * @returns a new mesh holding the sky box
  106335. */
  106336. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106337. /**
  106338. * Creates a new environment
  106339. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106340. * @param options defines the options you can use to configure the environment
  106341. * @returns the new EnvironmentHelper
  106342. */
  106343. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106344. /**
  106345. * Creates a new VREXperienceHelper
  106346. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106347. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106348. * @returns a new VREXperienceHelper
  106349. */
  106350. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106351. /**
  106352. * Creates a new XREXperienceHelper
  106353. * @see http://doc.babylonjs.com/how_to/webxr
  106354. * @returns a promise for a new XREXperienceHelper
  106355. */
  106356. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106357. }
  106358. }
  106359. declare module BABYLON {
  106360. /**
  106361. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106362. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106363. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106364. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106365. */
  106366. export class VideoDome extends TransformNode {
  106367. /**
  106368. * Define the video source as a Monoscopic panoramic 360 video.
  106369. */
  106370. static readonly MODE_MONOSCOPIC: number;
  106371. /**
  106372. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106373. */
  106374. static readonly MODE_TOPBOTTOM: number;
  106375. /**
  106376. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106377. */
  106378. static readonly MODE_SIDEBYSIDE: number;
  106379. private _useDirectMapping;
  106380. /**
  106381. * The video texture being displayed on the sphere
  106382. */
  106383. protected _videoTexture: VideoTexture;
  106384. /**
  106385. * Gets the video texture being displayed on the sphere
  106386. */
  106387. readonly videoTexture: VideoTexture;
  106388. /**
  106389. * The skybox material
  106390. */
  106391. protected _material: BackgroundMaterial;
  106392. /**
  106393. * The surface used for the skybox
  106394. */
  106395. protected _mesh: Mesh;
  106396. /**
  106397. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106398. * Also see the options.resolution property.
  106399. */
  106400. fovMultiplier: number;
  106401. private _videoMode;
  106402. /**
  106403. * Gets or set the current video mode for the video. It can be:
  106404. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106405. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106406. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106407. */
  106408. videoMode: number;
  106409. /**
  106410. * Oberserver used in Stereoscopic VR Mode.
  106411. */
  106412. private _onBeforeCameraRenderObserver;
  106413. /**
  106414. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106415. * @param name Element's name, child elements will append suffixes for their own names.
  106416. * @param urlsOrVideo defines the url(s) or the video element to use
  106417. * @param options An object containing optional or exposed sub element properties
  106418. */
  106419. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106420. resolution?: number;
  106421. clickToPlay?: boolean;
  106422. autoPlay?: boolean;
  106423. loop?: boolean;
  106424. size?: number;
  106425. poster?: string;
  106426. faceForward?: boolean;
  106427. useDirectMapping?: boolean;
  106428. }, scene: Scene);
  106429. private _changeVideoMode;
  106430. /**
  106431. * Releases resources associated with this node.
  106432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106434. */
  106435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106436. }
  106437. }
  106438. declare module BABYLON {
  106439. /**
  106440. * This class can be used to get instrumentation data from a Babylon engine
  106441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106442. */
  106443. export class EngineInstrumentation implements IDisposable {
  106444. /**
  106445. * Define the instrumented engine.
  106446. */
  106447. engine: Engine;
  106448. private _captureGPUFrameTime;
  106449. private _gpuFrameTimeToken;
  106450. private _gpuFrameTime;
  106451. private _captureShaderCompilationTime;
  106452. private _shaderCompilationTime;
  106453. private _onBeginFrameObserver;
  106454. private _onEndFrameObserver;
  106455. private _onBeforeShaderCompilationObserver;
  106456. private _onAfterShaderCompilationObserver;
  106457. /**
  106458. * Gets the perf counter used for GPU frame time
  106459. */
  106460. readonly gpuFrameTimeCounter: PerfCounter;
  106461. /**
  106462. * Gets the GPU frame time capture status
  106463. */
  106464. /**
  106465. * Enable or disable the GPU frame time capture
  106466. */
  106467. captureGPUFrameTime: boolean;
  106468. /**
  106469. * Gets the perf counter used for shader compilation time
  106470. */
  106471. readonly shaderCompilationTimeCounter: PerfCounter;
  106472. /**
  106473. * Gets the shader compilation time capture status
  106474. */
  106475. /**
  106476. * Enable or disable the shader compilation time capture
  106477. */
  106478. captureShaderCompilationTime: boolean;
  106479. /**
  106480. * Instantiates a new engine instrumentation.
  106481. * This class can be used to get instrumentation data from a Babylon engine
  106482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106483. * @param engine Defines the engine to instrument
  106484. */
  106485. constructor(
  106486. /**
  106487. * Define the instrumented engine.
  106488. */
  106489. engine: Engine);
  106490. /**
  106491. * Dispose and release associated resources.
  106492. */
  106493. dispose(): void;
  106494. }
  106495. }
  106496. declare module BABYLON {
  106497. /**
  106498. * This class can be used to get instrumentation data from a Babylon engine
  106499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106500. */
  106501. export class SceneInstrumentation implements IDisposable {
  106502. /**
  106503. * Defines the scene to instrument
  106504. */
  106505. scene: Scene;
  106506. private _captureActiveMeshesEvaluationTime;
  106507. private _activeMeshesEvaluationTime;
  106508. private _captureRenderTargetsRenderTime;
  106509. private _renderTargetsRenderTime;
  106510. private _captureFrameTime;
  106511. private _frameTime;
  106512. private _captureRenderTime;
  106513. private _renderTime;
  106514. private _captureInterFrameTime;
  106515. private _interFrameTime;
  106516. private _captureParticlesRenderTime;
  106517. private _particlesRenderTime;
  106518. private _captureSpritesRenderTime;
  106519. private _spritesRenderTime;
  106520. private _capturePhysicsTime;
  106521. private _physicsTime;
  106522. private _captureAnimationsTime;
  106523. private _animationsTime;
  106524. private _captureCameraRenderTime;
  106525. private _cameraRenderTime;
  106526. private _onBeforeActiveMeshesEvaluationObserver;
  106527. private _onAfterActiveMeshesEvaluationObserver;
  106528. private _onBeforeRenderTargetsRenderObserver;
  106529. private _onAfterRenderTargetsRenderObserver;
  106530. private _onAfterRenderObserver;
  106531. private _onBeforeDrawPhaseObserver;
  106532. private _onAfterDrawPhaseObserver;
  106533. private _onBeforeAnimationsObserver;
  106534. private _onBeforeParticlesRenderingObserver;
  106535. private _onAfterParticlesRenderingObserver;
  106536. private _onBeforeSpritesRenderingObserver;
  106537. private _onAfterSpritesRenderingObserver;
  106538. private _onBeforePhysicsObserver;
  106539. private _onAfterPhysicsObserver;
  106540. private _onAfterAnimationsObserver;
  106541. private _onBeforeCameraRenderObserver;
  106542. private _onAfterCameraRenderObserver;
  106543. /**
  106544. * Gets the perf counter used for active meshes evaluation time
  106545. */
  106546. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106547. /**
  106548. * Gets the active meshes evaluation time capture status
  106549. */
  106550. /**
  106551. * Enable or disable the active meshes evaluation time capture
  106552. */
  106553. captureActiveMeshesEvaluationTime: boolean;
  106554. /**
  106555. * Gets the perf counter used for render targets render time
  106556. */
  106557. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106558. /**
  106559. * Gets the render targets render time capture status
  106560. */
  106561. /**
  106562. * Enable or disable the render targets render time capture
  106563. */
  106564. captureRenderTargetsRenderTime: boolean;
  106565. /**
  106566. * Gets the perf counter used for particles render time
  106567. */
  106568. readonly particlesRenderTimeCounter: PerfCounter;
  106569. /**
  106570. * Gets the particles render time capture status
  106571. */
  106572. /**
  106573. * Enable or disable the particles render time capture
  106574. */
  106575. captureParticlesRenderTime: boolean;
  106576. /**
  106577. * Gets the perf counter used for sprites render time
  106578. */
  106579. readonly spritesRenderTimeCounter: PerfCounter;
  106580. /**
  106581. * Gets the sprites render time capture status
  106582. */
  106583. /**
  106584. * Enable or disable the sprites render time capture
  106585. */
  106586. captureSpritesRenderTime: boolean;
  106587. /**
  106588. * Gets the perf counter used for physics time
  106589. */
  106590. readonly physicsTimeCounter: PerfCounter;
  106591. /**
  106592. * Gets the physics time capture status
  106593. */
  106594. /**
  106595. * Enable or disable the physics time capture
  106596. */
  106597. capturePhysicsTime: boolean;
  106598. /**
  106599. * Gets the perf counter used for animations time
  106600. */
  106601. readonly animationsTimeCounter: PerfCounter;
  106602. /**
  106603. * Gets the animations time capture status
  106604. */
  106605. /**
  106606. * Enable or disable the animations time capture
  106607. */
  106608. captureAnimationsTime: boolean;
  106609. /**
  106610. * Gets the perf counter used for frame time capture
  106611. */
  106612. readonly frameTimeCounter: PerfCounter;
  106613. /**
  106614. * Gets the frame time capture status
  106615. */
  106616. /**
  106617. * Enable or disable the frame time capture
  106618. */
  106619. captureFrameTime: boolean;
  106620. /**
  106621. * Gets the perf counter used for inter-frames time capture
  106622. */
  106623. readonly interFrameTimeCounter: PerfCounter;
  106624. /**
  106625. * Gets the inter-frames time capture status
  106626. */
  106627. /**
  106628. * Enable or disable the inter-frames time capture
  106629. */
  106630. captureInterFrameTime: boolean;
  106631. /**
  106632. * Gets the perf counter used for render time capture
  106633. */
  106634. readonly renderTimeCounter: PerfCounter;
  106635. /**
  106636. * Gets the render time capture status
  106637. */
  106638. /**
  106639. * Enable or disable the render time capture
  106640. */
  106641. captureRenderTime: boolean;
  106642. /**
  106643. * Gets the perf counter used for camera render time capture
  106644. */
  106645. readonly cameraRenderTimeCounter: PerfCounter;
  106646. /**
  106647. * Gets the camera render time capture status
  106648. */
  106649. /**
  106650. * Enable or disable the camera render time capture
  106651. */
  106652. captureCameraRenderTime: boolean;
  106653. /**
  106654. * Gets the perf counter used for draw calls
  106655. */
  106656. readonly drawCallsCounter: PerfCounter;
  106657. /**
  106658. * Instantiates a new scene instrumentation.
  106659. * This class can be used to get instrumentation data from a Babylon engine
  106660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106661. * @param scene Defines the scene to instrument
  106662. */
  106663. constructor(
  106664. /**
  106665. * Defines the scene to instrument
  106666. */
  106667. scene: Scene);
  106668. /**
  106669. * Dispose and release associated resources.
  106670. */
  106671. dispose(): void;
  106672. }
  106673. }
  106674. declare module BABYLON {
  106675. /** @hidden */
  106676. export var glowMapGenerationPixelShader: {
  106677. name: string;
  106678. shader: string;
  106679. };
  106680. }
  106681. declare module BABYLON {
  106682. /** @hidden */
  106683. export var glowMapGenerationVertexShader: {
  106684. name: string;
  106685. shader: string;
  106686. };
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * Effect layer options. This helps customizing the behaviour
  106691. * of the effect layer.
  106692. */
  106693. export interface IEffectLayerOptions {
  106694. /**
  106695. * Multiplication factor apply to the canvas size to compute the render target size
  106696. * used to generated the objects (the smaller the faster).
  106697. */
  106698. mainTextureRatio: number;
  106699. /**
  106700. * Enforces a fixed size texture to ensure effect stability across devices.
  106701. */
  106702. mainTextureFixedSize?: number;
  106703. /**
  106704. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106705. */
  106706. alphaBlendingMode: number;
  106707. /**
  106708. * The camera attached to the layer.
  106709. */
  106710. camera: Nullable<Camera>;
  106711. /**
  106712. * The rendering group to draw the layer in.
  106713. */
  106714. renderingGroupId: number;
  106715. }
  106716. /**
  106717. * The effect layer Helps adding post process effect blended with the main pass.
  106718. *
  106719. * This can be for instance use to generate glow or higlight effects on the scene.
  106720. *
  106721. * The effect layer class can not be used directly and is intented to inherited from to be
  106722. * customized per effects.
  106723. */
  106724. export abstract class EffectLayer {
  106725. private _vertexBuffers;
  106726. private _indexBuffer;
  106727. private _cachedDefines;
  106728. private _effectLayerMapGenerationEffect;
  106729. private _effectLayerOptions;
  106730. private _mergeEffect;
  106731. protected _scene: Scene;
  106732. protected _engine: Engine;
  106733. protected _maxSize: number;
  106734. protected _mainTextureDesiredSize: ISize;
  106735. protected _mainTexture: RenderTargetTexture;
  106736. protected _shouldRender: boolean;
  106737. protected _postProcesses: PostProcess[];
  106738. protected _textures: BaseTexture[];
  106739. protected _emissiveTextureAndColor: {
  106740. texture: Nullable<BaseTexture>;
  106741. color: Color4;
  106742. };
  106743. /**
  106744. * The name of the layer
  106745. */
  106746. name: string;
  106747. /**
  106748. * The clear color of the texture used to generate the glow map.
  106749. */
  106750. neutralColor: Color4;
  106751. /**
  106752. * Specifies wether the highlight layer is enabled or not.
  106753. */
  106754. isEnabled: boolean;
  106755. /**
  106756. * Gets the camera attached to the layer.
  106757. */
  106758. readonly camera: Nullable<Camera>;
  106759. /**
  106760. * Gets the rendering group id the layer should render in.
  106761. */
  106762. readonly renderingGroupId: number;
  106763. /**
  106764. * An event triggered when the effect layer has been disposed.
  106765. */
  106766. onDisposeObservable: Observable<EffectLayer>;
  106767. /**
  106768. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106769. */
  106770. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106771. /**
  106772. * An event triggered when the generated texture is being merged in the scene.
  106773. */
  106774. onBeforeComposeObservable: Observable<EffectLayer>;
  106775. /**
  106776. * An event triggered when the generated texture has been merged in the scene.
  106777. */
  106778. onAfterComposeObservable: Observable<EffectLayer>;
  106779. /**
  106780. * An event triggered when the efffect layer changes its size.
  106781. */
  106782. onSizeChangedObservable: Observable<EffectLayer>;
  106783. /** @hidden */
  106784. static _SceneComponentInitialization: (scene: Scene) => void;
  106785. /**
  106786. * Instantiates a new effect Layer and references it in the scene.
  106787. * @param name The name of the layer
  106788. * @param scene The scene to use the layer in
  106789. */
  106790. constructor(
  106791. /** The Friendly of the effect in the scene */
  106792. name: string, scene: Scene);
  106793. /**
  106794. * Get the effect name of the layer.
  106795. * @return The effect name
  106796. */
  106797. abstract getEffectName(): string;
  106798. /**
  106799. * Checks for the readiness of the element composing the layer.
  106800. * @param subMesh the mesh to check for
  106801. * @param useInstances specify wether or not to use instances to render the mesh
  106802. * @return true if ready otherwise, false
  106803. */
  106804. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106805. /**
  106806. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106807. * @returns true if the effect requires stencil during the main canvas render pass.
  106808. */
  106809. abstract needStencil(): boolean;
  106810. /**
  106811. * Create the merge effect. This is the shader use to blit the information back
  106812. * to the main canvas at the end of the scene rendering.
  106813. * @returns The effect containing the shader used to merge the effect on the main canvas
  106814. */
  106815. protected abstract _createMergeEffect(): Effect;
  106816. /**
  106817. * Creates the render target textures and post processes used in the effect layer.
  106818. */
  106819. protected abstract _createTextureAndPostProcesses(): void;
  106820. /**
  106821. * Implementation specific of rendering the generating effect on the main canvas.
  106822. * @param effect The effect used to render through
  106823. */
  106824. protected abstract _internalRender(effect: Effect): void;
  106825. /**
  106826. * Sets the required values for both the emissive texture and and the main color.
  106827. */
  106828. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106829. /**
  106830. * Free any resources and references associated to a mesh.
  106831. * Internal use
  106832. * @param mesh The mesh to free.
  106833. */
  106834. abstract _disposeMesh(mesh: Mesh): void;
  106835. /**
  106836. * Serializes this layer (Glow or Highlight for example)
  106837. * @returns a serialized layer object
  106838. */
  106839. abstract serialize?(): any;
  106840. /**
  106841. * Initializes the effect layer with the required options.
  106842. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106843. */
  106844. protected _init(options: Partial<IEffectLayerOptions>): void;
  106845. /**
  106846. * Generates the index buffer of the full screen quad blending to the main canvas.
  106847. */
  106848. private _generateIndexBuffer;
  106849. /**
  106850. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106851. */
  106852. private _generateVertexBuffer;
  106853. /**
  106854. * Sets the main texture desired size which is the closest power of two
  106855. * of the engine canvas size.
  106856. */
  106857. private _setMainTextureSize;
  106858. /**
  106859. * Creates the main texture for the effect layer.
  106860. */
  106861. protected _createMainTexture(): void;
  106862. /**
  106863. * Adds specific effects defines.
  106864. * @param defines The defines to add specifics to.
  106865. */
  106866. protected _addCustomEffectDefines(defines: string[]): void;
  106867. /**
  106868. * Checks for the readiness of the element composing the layer.
  106869. * @param subMesh the mesh to check for
  106870. * @param useInstances specify wether or not to use instances to render the mesh
  106871. * @param emissiveTexture the associated emissive texture used to generate the glow
  106872. * @return true if ready otherwise, false
  106873. */
  106874. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106875. /**
  106876. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106877. */
  106878. render(): void;
  106879. /**
  106880. * Determine if a given mesh will be used in the current effect.
  106881. * @param mesh mesh to test
  106882. * @returns true if the mesh will be used
  106883. */
  106884. hasMesh(mesh: AbstractMesh): boolean;
  106885. /**
  106886. * Returns true if the layer contains information to display, otherwise false.
  106887. * @returns true if the glow layer should be rendered
  106888. */
  106889. shouldRender(): boolean;
  106890. /**
  106891. * Returns true if the mesh should render, otherwise false.
  106892. * @param mesh The mesh to render
  106893. * @returns true if it should render otherwise false
  106894. */
  106895. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106896. /**
  106897. * Returns true if the mesh can be rendered, otherwise false.
  106898. * @param mesh The mesh to render
  106899. * @param material The material used on the mesh
  106900. * @returns true if it can be rendered otherwise false
  106901. */
  106902. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106903. /**
  106904. * Returns true if the mesh should render, otherwise false.
  106905. * @param mesh The mesh to render
  106906. * @returns true if it should render otherwise false
  106907. */
  106908. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106909. /**
  106910. * Renders the submesh passed in parameter to the generation map.
  106911. */
  106912. protected _renderSubMesh(subMesh: SubMesh): void;
  106913. /**
  106914. * Rebuild the required buffers.
  106915. * @hidden Internal use only.
  106916. */
  106917. _rebuild(): void;
  106918. /**
  106919. * Dispose only the render target textures and post process.
  106920. */
  106921. private _disposeTextureAndPostProcesses;
  106922. /**
  106923. * Dispose the highlight layer and free resources.
  106924. */
  106925. dispose(): void;
  106926. /**
  106927. * Gets the class name of the effect layer
  106928. * @returns the string with the class name of the effect layer
  106929. */
  106930. getClassName(): string;
  106931. /**
  106932. * Creates an effect layer from parsed effect layer data
  106933. * @param parsedEffectLayer defines effect layer data
  106934. * @param scene defines the current scene
  106935. * @param rootUrl defines the root URL containing the effect layer information
  106936. * @returns a parsed effect Layer
  106937. */
  106938. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106939. }
  106940. }
  106941. declare module BABYLON {
  106942. interface AbstractScene {
  106943. /**
  106944. * The list of effect layers (highlights/glow) added to the scene
  106945. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106946. * @see http://doc.babylonjs.com/how_to/glow_layer
  106947. */
  106948. effectLayers: Array<EffectLayer>;
  106949. /**
  106950. * Removes the given effect layer from this scene.
  106951. * @param toRemove defines the effect layer to remove
  106952. * @returns the index of the removed effect layer
  106953. */
  106954. removeEffectLayer(toRemove: EffectLayer): number;
  106955. /**
  106956. * Adds the given effect layer to this scene
  106957. * @param newEffectLayer defines the effect layer to add
  106958. */
  106959. addEffectLayer(newEffectLayer: EffectLayer): void;
  106960. }
  106961. /**
  106962. * Defines the layer scene component responsible to manage any effect layers
  106963. * in a given scene.
  106964. */
  106965. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106966. /**
  106967. * The component name helpfull to identify the component in the list of scene components.
  106968. */
  106969. readonly name: string;
  106970. /**
  106971. * The scene the component belongs to.
  106972. */
  106973. scene: Scene;
  106974. private _engine;
  106975. private _renderEffects;
  106976. private _needStencil;
  106977. private _previousStencilState;
  106978. /**
  106979. * Creates a new instance of the component for the given scene
  106980. * @param scene Defines the scene to register the component in
  106981. */
  106982. constructor(scene: Scene);
  106983. /**
  106984. * Registers the component in a given scene
  106985. */
  106986. register(): void;
  106987. /**
  106988. * Rebuilds the elements related to this component in case of
  106989. * context lost for instance.
  106990. */
  106991. rebuild(): void;
  106992. /**
  106993. * Serializes the component data to the specified json object
  106994. * @param serializationObject The object to serialize to
  106995. */
  106996. serialize(serializationObject: any): void;
  106997. /**
  106998. * Adds all the element from the container to the scene
  106999. * @param container the container holding the elements
  107000. */
  107001. addFromContainer(container: AbstractScene): void;
  107002. /**
  107003. * Removes all the elements in the container from the scene
  107004. * @param container contains the elements to remove
  107005. * @param dispose if the removed element should be disposed (default: false)
  107006. */
  107007. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107008. /**
  107009. * Disposes the component and the associated ressources.
  107010. */
  107011. dispose(): void;
  107012. private _isReadyForMesh;
  107013. private _renderMainTexture;
  107014. private _setStencil;
  107015. private _setStencilBack;
  107016. private _draw;
  107017. private _drawCamera;
  107018. private _drawRenderingGroup;
  107019. }
  107020. }
  107021. declare module BABYLON {
  107022. /** @hidden */
  107023. export var glowMapMergePixelShader: {
  107024. name: string;
  107025. shader: string;
  107026. };
  107027. }
  107028. declare module BABYLON {
  107029. /** @hidden */
  107030. export var glowMapMergeVertexShader: {
  107031. name: string;
  107032. shader: string;
  107033. };
  107034. }
  107035. declare module BABYLON {
  107036. interface AbstractScene {
  107037. /**
  107038. * Return a the first highlight layer of the scene with a given name.
  107039. * @param name The name of the highlight layer to look for.
  107040. * @return The highlight layer if found otherwise null.
  107041. */
  107042. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107043. }
  107044. /**
  107045. * Glow layer options. This helps customizing the behaviour
  107046. * of the glow layer.
  107047. */
  107048. export interface IGlowLayerOptions {
  107049. /**
  107050. * Multiplication factor apply to the canvas size to compute the render target size
  107051. * used to generated the glowing objects (the smaller the faster).
  107052. */
  107053. mainTextureRatio: number;
  107054. /**
  107055. * Enforces a fixed size texture to ensure resize independant blur.
  107056. */
  107057. mainTextureFixedSize?: number;
  107058. /**
  107059. * How big is the kernel of the blur texture.
  107060. */
  107061. blurKernelSize: number;
  107062. /**
  107063. * The camera attached to the layer.
  107064. */
  107065. camera: Nullable<Camera>;
  107066. /**
  107067. * Enable MSAA by chosing the number of samples.
  107068. */
  107069. mainTextureSamples?: number;
  107070. /**
  107071. * The rendering group to draw the layer in.
  107072. */
  107073. renderingGroupId: number;
  107074. }
  107075. /**
  107076. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107077. *
  107078. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107079. * glowy meshes to your scene.
  107080. *
  107081. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107082. */
  107083. export class GlowLayer extends EffectLayer {
  107084. /**
  107085. * Effect Name of the layer.
  107086. */
  107087. static readonly EffectName: string;
  107088. /**
  107089. * The default blur kernel size used for the glow.
  107090. */
  107091. static DefaultBlurKernelSize: number;
  107092. /**
  107093. * The default texture size ratio used for the glow.
  107094. */
  107095. static DefaultTextureRatio: number;
  107096. /**
  107097. * Sets the kernel size of the blur.
  107098. */
  107099. /**
  107100. * Gets the kernel size of the blur.
  107101. */
  107102. blurKernelSize: number;
  107103. /**
  107104. * Sets the glow intensity.
  107105. */
  107106. /**
  107107. * Gets the glow intensity.
  107108. */
  107109. intensity: number;
  107110. private _options;
  107111. private _intensity;
  107112. private _horizontalBlurPostprocess1;
  107113. private _verticalBlurPostprocess1;
  107114. private _horizontalBlurPostprocess2;
  107115. private _verticalBlurPostprocess2;
  107116. private _blurTexture1;
  107117. private _blurTexture2;
  107118. private _postProcesses1;
  107119. private _postProcesses2;
  107120. private _includedOnlyMeshes;
  107121. private _excludedMeshes;
  107122. /**
  107123. * Callback used to let the user override the color selection on a per mesh basis
  107124. */
  107125. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107126. /**
  107127. * Callback used to let the user override the texture selection on a per mesh basis
  107128. */
  107129. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107130. /**
  107131. * Instantiates a new glow Layer and references it to the scene.
  107132. * @param name The name of the layer
  107133. * @param scene The scene to use the layer in
  107134. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107135. */
  107136. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107137. /**
  107138. * Get the effect name of the layer.
  107139. * @return The effect name
  107140. */
  107141. getEffectName(): string;
  107142. /**
  107143. * Create the merge effect. This is the shader use to blit the information back
  107144. * to the main canvas at the end of the scene rendering.
  107145. */
  107146. protected _createMergeEffect(): Effect;
  107147. /**
  107148. * Creates the render target textures and post processes used in the glow layer.
  107149. */
  107150. protected _createTextureAndPostProcesses(): void;
  107151. /**
  107152. * Checks for the readiness of the element composing the layer.
  107153. * @param subMesh the mesh to check for
  107154. * @param useInstances specify wether or not to use instances to render the mesh
  107155. * @param emissiveTexture the associated emissive texture used to generate the glow
  107156. * @return true if ready otherwise, false
  107157. */
  107158. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107159. /**
  107160. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107161. */
  107162. needStencil(): boolean;
  107163. /**
  107164. * Returns true if the mesh can be rendered, otherwise false.
  107165. * @param mesh The mesh to render
  107166. * @param material The material used on the mesh
  107167. * @returns true if it can be rendered otherwise false
  107168. */
  107169. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107170. /**
  107171. * Implementation specific of rendering the generating effect on the main canvas.
  107172. * @param effect The effect used to render through
  107173. */
  107174. protected _internalRender(effect: Effect): void;
  107175. /**
  107176. * Sets the required values for both the emissive texture and and the main color.
  107177. */
  107178. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107179. /**
  107180. * Returns true if the mesh should render, otherwise false.
  107181. * @param mesh The mesh to render
  107182. * @returns true if it should render otherwise false
  107183. */
  107184. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107185. /**
  107186. * Adds specific effects defines.
  107187. * @param defines The defines to add specifics to.
  107188. */
  107189. protected _addCustomEffectDefines(defines: string[]): void;
  107190. /**
  107191. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107192. * @param mesh The mesh to exclude from the glow layer
  107193. */
  107194. addExcludedMesh(mesh: Mesh): void;
  107195. /**
  107196. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107197. * @param mesh The mesh to remove
  107198. */
  107199. removeExcludedMesh(mesh: Mesh): void;
  107200. /**
  107201. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107202. * @param mesh The mesh to include in the glow layer
  107203. */
  107204. addIncludedOnlyMesh(mesh: Mesh): void;
  107205. /**
  107206. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107207. * @param mesh The mesh to remove
  107208. */
  107209. removeIncludedOnlyMesh(mesh: Mesh): void;
  107210. /**
  107211. * Determine if a given mesh will be used in the glow layer
  107212. * @param mesh The mesh to test
  107213. * @returns true if the mesh will be highlighted by the current glow layer
  107214. */
  107215. hasMesh(mesh: AbstractMesh): boolean;
  107216. /**
  107217. * Free any resources and references associated to a mesh.
  107218. * Internal use
  107219. * @param mesh The mesh to free.
  107220. * @hidden
  107221. */
  107222. _disposeMesh(mesh: Mesh): void;
  107223. /**
  107224. * Gets the class name of the effect layer
  107225. * @returns the string with the class name of the effect layer
  107226. */
  107227. getClassName(): string;
  107228. /**
  107229. * Serializes this glow layer
  107230. * @returns a serialized glow layer object
  107231. */
  107232. serialize(): any;
  107233. /**
  107234. * Creates a Glow Layer from parsed glow layer data
  107235. * @param parsedGlowLayer defines glow layer data
  107236. * @param scene defines the current scene
  107237. * @param rootUrl defines the root URL containing the glow layer information
  107238. * @returns a parsed Glow Layer
  107239. */
  107240. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107241. }
  107242. }
  107243. declare module BABYLON {
  107244. /** @hidden */
  107245. export var glowBlurPostProcessPixelShader: {
  107246. name: string;
  107247. shader: string;
  107248. };
  107249. }
  107250. declare module BABYLON {
  107251. interface AbstractScene {
  107252. /**
  107253. * Return a the first highlight layer of the scene with a given name.
  107254. * @param name The name of the highlight layer to look for.
  107255. * @return The highlight layer if found otherwise null.
  107256. */
  107257. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107258. }
  107259. /**
  107260. * Highlight layer options. This helps customizing the behaviour
  107261. * of the highlight layer.
  107262. */
  107263. export interface IHighlightLayerOptions {
  107264. /**
  107265. * Multiplication factor apply to the canvas size to compute the render target size
  107266. * used to generated the glowing objects (the smaller the faster).
  107267. */
  107268. mainTextureRatio: number;
  107269. /**
  107270. * Enforces a fixed size texture to ensure resize independant blur.
  107271. */
  107272. mainTextureFixedSize?: number;
  107273. /**
  107274. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107275. * of the picture to blur (the smaller the faster).
  107276. */
  107277. blurTextureSizeRatio: number;
  107278. /**
  107279. * How big in texel of the blur texture is the vertical blur.
  107280. */
  107281. blurVerticalSize: number;
  107282. /**
  107283. * How big in texel of the blur texture is the horizontal blur.
  107284. */
  107285. blurHorizontalSize: number;
  107286. /**
  107287. * Alpha blending mode used to apply the blur. Default is combine.
  107288. */
  107289. alphaBlendingMode: number;
  107290. /**
  107291. * The camera attached to the layer.
  107292. */
  107293. camera: Nullable<Camera>;
  107294. /**
  107295. * Should we display highlight as a solid stroke?
  107296. */
  107297. isStroke?: boolean;
  107298. /**
  107299. * The rendering group to draw the layer in.
  107300. */
  107301. renderingGroupId: number;
  107302. }
  107303. /**
  107304. * The highlight layer Helps adding a glow effect around a mesh.
  107305. *
  107306. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107307. * glowy meshes to your scene.
  107308. *
  107309. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107310. */
  107311. export class HighlightLayer extends EffectLayer {
  107312. name: string;
  107313. /**
  107314. * Effect Name of the highlight layer.
  107315. */
  107316. static readonly EffectName: string;
  107317. /**
  107318. * The neutral color used during the preparation of the glow effect.
  107319. * This is black by default as the blend operation is a blend operation.
  107320. */
  107321. static NeutralColor: Color4;
  107322. /**
  107323. * Stencil value used for glowing meshes.
  107324. */
  107325. static GlowingMeshStencilReference: number;
  107326. /**
  107327. * Stencil value used for the other meshes in the scene.
  107328. */
  107329. static NormalMeshStencilReference: number;
  107330. /**
  107331. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107332. */
  107333. innerGlow: boolean;
  107334. /**
  107335. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107336. */
  107337. outerGlow: boolean;
  107338. /**
  107339. * Specifies the horizontal size of the blur.
  107340. */
  107341. /**
  107342. * Gets the horizontal size of the blur.
  107343. */
  107344. blurHorizontalSize: number;
  107345. /**
  107346. * Specifies the vertical size of the blur.
  107347. */
  107348. /**
  107349. * Gets the vertical size of the blur.
  107350. */
  107351. blurVerticalSize: number;
  107352. /**
  107353. * An event triggered when the highlight layer is being blurred.
  107354. */
  107355. onBeforeBlurObservable: Observable<HighlightLayer>;
  107356. /**
  107357. * An event triggered when the highlight layer has been blurred.
  107358. */
  107359. onAfterBlurObservable: Observable<HighlightLayer>;
  107360. private _instanceGlowingMeshStencilReference;
  107361. private _options;
  107362. private _downSamplePostprocess;
  107363. private _horizontalBlurPostprocess;
  107364. private _verticalBlurPostprocess;
  107365. private _blurTexture;
  107366. private _meshes;
  107367. private _excludedMeshes;
  107368. /**
  107369. * Instantiates a new highlight Layer and references it to the scene..
  107370. * @param name The name of the layer
  107371. * @param scene The scene to use the layer in
  107372. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107373. */
  107374. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107375. /**
  107376. * Get the effect name of the layer.
  107377. * @return The effect name
  107378. */
  107379. getEffectName(): string;
  107380. /**
  107381. * Create the merge effect. This is the shader use to blit the information back
  107382. * to the main canvas at the end of the scene rendering.
  107383. */
  107384. protected _createMergeEffect(): Effect;
  107385. /**
  107386. * Creates the render target textures and post processes used in the highlight layer.
  107387. */
  107388. protected _createTextureAndPostProcesses(): void;
  107389. /**
  107390. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107391. */
  107392. needStencil(): boolean;
  107393. /**
  107394. * Checks for the readiness of the element composing the layer.
  107395. * @param subMesh the mesh to check for
  107396. * @param useInstances specify wether or not to use instances to render the mesh
  107397. * @param emissiveTexture the associated emissive texture used to generate the glow
  107398. * @return true if ready otherwise, false
  107399. */
  107400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107401. /**
  107402. * Implementation specific of rendering the generating effect on the main canvas.
  107403. * @param effect The effect used to render through
  107404. */
  107405. protected _internalRender(effect: Effect): void;
  107406. /**
  107407. * Returns true if the layer contains information to display, otherwise false.
  107408. */
  107409. shouldRender(): boolean;
  107410. /**
  107411. * Returns true if the mesh should render, otherwise false.
  107412. * @param mesh The mesh to render
  107413. * @returns true if it should render otherwise false
  107414. */
  107415. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107416. /**
  107417. * Sets the required values for both the emissive texture and and the main color.
  107418. */
  107419. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107420. /**
  107421. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107422. * @param mesh The mesh to exclude from the highlight layer
  107423. */
  107424. addExcludedMesh(mesh: Mesh): void;
  107425. /**
  107426. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107427. * @param mesh The mesh to highlight
  107428. */
  107429. removeExcludedMesh(mesh: Mesh): void;
  107430. /**
  107431. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107432. * @param mesh mesh to test
  107433. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107434. */
  107435. hasMesh(mesh: AbstractMesh): boolean;
  107436. /**
  107437. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107438. * @param mesh The mesh to highlight
  107439. * @param color The color of the highlight
  107440. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107441. */
  107442. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107443. /**
  107444. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107445. * @param mesh The mesh to highlight
  107446. */
  107447. removeMesh(mesh: Mesh): void;
  107448. /**
  107449. * Force the stencil to the normal expected value for none glowing parts
  107450. */
  107451. private _defaultStencilReference;
  107452. /**
  107453. * Free any resources and references associated to a mesh.
  107454. * Internal use
  107455. * @param mesh The mesh to free.
  107456. * @hidden
  107457. */
  107458. _disposeMesh(mesh: Mesh): void;
  107459. /**
  107460. * Dispose the highlight layer and free resources.
  107461. */
  107462. dispose(): void;
  107463. /**
  107464. * Gets the class name of the effect layer
  107465. * @returns the string with the class name of the effect layer
  107466. */
  107467. getClassName(): string;
  107468. /**
  107469. * Serializes this Highlight layer
  107470. * @returns a serialized Highlight layer object
  107471. */
  107472. serialize(): any;
  107473. /**
  107474. * Creates a Highlight layer from parsed Highlight layer data
  107475. * @param parsedHightlightLayer defines the Highlight layer data
  107476. * @param scene defines the current scene
  107477. * @param rootUrl defines the root URL containing the Highlight layer information
  107478. * @returns a parsed Highlight layer
  107479. */
  107480. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107481. }
  107482. }
  107483. declare module BABYLON {
  107484. /** @hidden */
  107485. export var lensFlarePixelShader: {
  107486. name: string;
  107487. shader: string;
  107488. };
  107489. }
  107490. declare module BABYLON {
  107491. /** @hidden */
  107492. export var lensFlareVertexShader: {
  107493. name: string;
  107494. shader: string;
  107495. };
  107496. }
  107497. declare module BABYLON {
  107498. /**
  107499. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107500. * It is usually composed of several `lensFlare`.
  107501. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107502. */
  107503. export class LensFlareSystem {
  107504. /**
  107505. * Define the name of the lens flare system
  107506. */
  107507. name: string;
  107508. /**
  107509. * List of lens flares used in this system.
  107510. */
  107511. lensFlares: LensFlare[];
  107512. /**
  107513. * Define a limit from the border the lens flare can be visible.
  107514. */
  107515. borderLimit: number;
  107516. /**
  107517. * Define a viewport border we do not want to see the lens flare in.
  107518. */
  107519. viewportBorder: number;
  107520. /**
  107521. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107522. */
  107523. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107524. /**
  107525. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107526. */
  107527. layerMask: number;
  107528. /**
  107529. * Define the id of the lens flare system in the scene.
  107530. * (equal to name by default)
  107531. */
  107532. id: string;
  107533. private _scene;
  107534. private _emitter;
  107535. private _vertexBuffers;
  107536. private _indexBuffer;
  107537. private _effect;
  107538. private _positionX;
  107539. private _positionY;
  107540. private _isEnabled;
  107541. /** @hidden */
  107542. static _SceneComponentInitialization: (scene: Scene) => void;
  107543. /**
  107544. * Instantiates a lens flare system.
  107545. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107546. * It is usually composed of several `lensFlare`.
  107547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107548. * @param name Define the name of the lens flare system in the scene
  107549. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107550. * @param scene Define the scene the lens flare system belongs to
  107551. */
  107552. constructor(
  107553. /**
  107554. * Define the name of the lens flare system
  107555. */
  107556. name: string, emitter: any, scene: Scene);
  107557. /**
  107558. * Define if the lens flare system is enabled.
  107559. */
  107560. isEnabled: boolean;
  107561. /**
  107562. * Get the scene the effects belongs to.
  107563. * @returns the scene holding the lens flare system
  107564. */
  107565. getScene(): Scene;
  107566. /**
  107567. * Get the emitter of the lens flare system.
  107568. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107569. * @returns the emitter of the lens flare system
  107570. */
  107571. getEmitter(): any;
  107572. /**
  107573. * Set the emitter of the lens flare system.
  107574. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107575. * @param newEmitter Define the new emitter of the system
  107576. */
  107577. setEmitter(newEmitter: any): void;
  107578. /**
  107579. * Get the lens flare system emitter position.
  107580. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107581. * @returns the position
  107582. */
  107583. getEmitterPosition(): Vector3;
  107584. /**
  107585. * @hidden
  107586. */
  107587. computeEffectivePosition(globalViewport: Viewport): boolean;
  107588. /** @hidden */
  107589. _isVisible(): boolean;
  107590. /**
  107591. * @hidden
  107592. */
  107593. render(): boolean;
  107594. /**
  107595. * Dispose and release the lens flare with its associated resources.
  107596. */
  107597. dispose(): void;
  107598. /**
  107599. * Parse a lens flare system from a JSON repressentation
  107600. * @param parsedLensFlareSystem Define the JSON to parse
  107601. * @param scene Define the scene the parsed system should be instantiated in
  107602. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107603. * @returns the parsed system
  107604. */
  107605. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107606. /**
  107607. * Serialize the current Lens Flare System into a JSON representation.
  107608. * @returns the serialized JSON
  107609. */
  107610. serialize(): any;
  107611. }
  107612. }
  107613. declare module BABYLON {
  107614. /**
  107615. * This represents one of the lens effect in a `lensFlareSystem`.
  107616. * It controls one of the indiviual texture used in the effect.
  107617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107618. */
  107619. export class LensFlare {
  107620. /**
  107621. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107622. */
  107623. size: number;
  107624. /**
  107625. * 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.
  107626. */
  107627. position: number;
  107628. /**
  107629. * Define the lens color.
  107630. */
  107631. color: Color3;
  107632. /**
  107633. * Define the lens texture.
  107634. */
  107635. texture: Nullable<Texture>;
  107636. /**
  107637. * Define the alpha mode to render this particular lens.
  107638. */
  107639. alphaMode: number;
  107640. private _system;
  107641. /**
  107642. * Creates a new Lens Flare.
  107643. * This represents one of the lens effect in a `lensFlareSystem`.
  107644. * It controls one of the indiviual texture used in the effect.
  107645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107646. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107647. * @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.
  107648. * @param color Define the lens color
  107649. * @param imgUrl Define the lens texture url
  107650. * @param system Define the `lensFlareSystem` this flare is part of
  107651. * @returns The newly created Lens Flare
  107652. */
  107653. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107654. /**
  107655. * Instantiates a new Lens Flare.
  107656. * This represents one of the lens effect in a `lensFlareSystem`.
  107657. * It controls one of the indiviual texture used in the effect.
  107658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107659. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107660. * @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.
  107661. * @param color Define the lens color
  107662. * @param imgUrl Define the lens texture url
  107663. * @param system Define the `lensFlareSystem` this flare is part of
  107664. */
  107665. constructor(
  107666. /**
  107667. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107668. */
  107669. size: number,
  107670. /**
  107671. * 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.
  107672. */
  107673. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107674. /**
  107675. * Dispose and release the lens flare with its associated resources.
  107676. */
  107677. dispose(): void;
  107678. }
  107679. }
  107680. declare module BABYLON {
  107681. interface AbstractScene {
  107682. /**
  107683. * The list of lens flare system added to the scene
  107684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107685. */
  107686. lensFlareSystems: Array<LensFlareSystem>;
  107687. /**
  107688. * Removes the given lens flare system from this scene.
  107689. * @param toRemove The lens flare system to remove
  107690. * @returns The index of the removed lens flare system
  107691. */
  107692. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107693. /**
  107694. * Adds the given lens flare system to this scene
  107695. * @param newLensFlareSystem The lens flare system to add
  107696. */
  107697. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107698. /**
  107699. * Gets a lens flare system using its name
  107700. * @param name defines the name to look for
  107701. * @returns the lens flare system or null if not found
  107702. */
  107703. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107704. /**
  107705. * Gets a lens flare system using its id
  107706. * @param id defines the id to look for
  107707. * @returns the lens flare system or null if not found
  107708. */
  107709. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107710. }
  107711. /**
  107712. * Defines the lens flare scene component responsible to manage any lens flares
  107713. * in a given scene.
  107714. */
  107715. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107716. /**
  107717. * The component name helpfull to identify the component in the list of scene components.
  107718. */
  107719. readonly name: string;
  107720. /**
  107721. * The scene the component belongs to.
  107722. */
  107723. scene: Scene;
  107724. /**
  107725. * Creates a new instance of the component for the given scene
  107726. * @param scene Defines the scene to register the component in
  107727. */
  107728. constructor(scene: Scene);
  107729. /**
  107730. * Registers the component in a given scene
  107731. */
  107732. register(): void;
  107733. /**
  107734. * Rebuilds the elements related to this component in case of
  107735. * context lost for instance.
  107736. */
  107737. rebuild(): void;
  107738. /**
  107739. * Adds all the element from the container to the scene
  107740. * @param container the container holding the elements
  107741. */
  107742. addFromContainer(container: AbstractScene): void;
  107743. /**
  107744. * Removes all the elements in the container from the scene
  107745. * @param container contains the elements to remove
  107746. * @param dispose if the removed element should be disposed (default: false)
  107747. */
  107748. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107749. /**
  107750. * Serializes the component data to the specified json object
  107751. * @param serializationObject The object to serialize to
  107752. */
  107753. serialize(serializationObject: any): void;
  107754. /**
  107755. * Disposes the component and the associated ressources.
  107756. */
  107757. dispose(): void;
  107758. private _draw;
  107759. }
  107760. }
  107761. declare module BABYLON {
  107762. /**
  107763. * Defines the shadow generator component responsible to manage any shadow generators
  107764. * in a given scene.
  107765. */
  107766. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107767. /**
  107768. * The component name helpfull to identify the component in the list of scene components.
  107769. */
  107770. readonly name: string;
  107771. /**
  107772. * The scene the component belongs to.
  107773. */
  107774. scene: Scene;
  107775. /**
  107776. * Creates a new instance of the component for the given scene
  107777. * @param scene Defines the scene to register the component in
  107778. */
  107779. constructor(scene: Scene);
  107780. /**
  107781. * Registers the component in a given scene
  107782. */
  107783. register(): void;
  107784. /**
  107785. * Rebuilds the elements related to this component in case of
  107786. * context lost for instance.
  107787. */
  107788. rebuild(): void;
  107789. /**
  107790. * Serializes the component data to the specified json object
  107791. * @param serializationObject The object to serialize to
  107792. */
  107793. serialize(serializationObject: any): void;
  107794. /**
  107795. * Adds all the element from the container to the scene
  107796. * @param container the container holding the elements
  107797. */
  107798. addFromContainer(container: AbstractScene): void;
  107799. /**
  107800. * Removes all the elements in the container from the scene
  107801. * @param container contains the elements to remove
  107802. * @param dispose if the removed element should be disposed (default: false)
  107803. */
  107804. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107805. /**
  107806. * Rebuilds the elements related to this component in case of
  107807. * context lost for instance.
  107808. */
  107809. dispose(): void;
  107810. private _gatherRenderTargets;
  107811. }
  107812. }
  107813. declare module BABYLON {
  107814. /**
  107815. * A point light is a light defined by an unique point in world space.
  107816. * The light is emitted in every direction from this point.
  107817. * A good example of a point light is a standard light bulb.
  107818. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107819. */
  107820. export class PointLight extends ShadowLight {
  107821. private _shadowAngle;
  107822. /**
  107823. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107824. * This specifies what angle the shadow will use to be created.
  107825. *
  107826. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107827. */
  107828. /**
  107829. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107830. * This specifies what angle the shadow will use to be created.
  107831. *
  107832. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107833. */
  107834. shadowAngle: number;
  107835. /**
  107836. * Gets the direction if it has been set.
  107837. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107838. */
  107839. /**
  107840. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107841. */
  107842. direction: Vector3;
  107843. /**
  107844. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107845. * A PointLight emits the light in every direction.
  107846. * It can cast shadows.
  107847. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107848. * ```javascript
  107849. * var pointLight = new PointLight("pl", camera.position, scene);
  107850. * ```
  107851. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107852. * @param name The light friendly name
  107853. * @param position The position of the point light in the scene
  107854. * @param scene The scene the lights belongs to
  107855. */
  107856. constructor(name: string, position: Vector3, scene: Scene);
  107857. /**
  107858. * Returns the string "PointLight"
  107859. * @returns the class name
  107860. */
  107861. getClassName(): string;
  107862. /**
  107863. * Returns the integer 0.
  107864. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107865. */
  107866. getTypeID(): number;
  107867. /**
  107868. * Specifies wether or not the shadowmap should be a cube texture.
  107869. * @returns true if the shadowmap needs to be a cube texture.
  107870. */
  107871. needCube(): boolean;
  107872. /**
  107873. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107874. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107875. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107876. */
  107877. getShadowDirection(faceIndex?: number): Vector3;
  107878. /**
  107879. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107880. * - fov = PI / 2
  107881. * - aspect ratio : 1.0
  107882. * - z-near and far equal to the active camera minZ and maxZ.
  107883. * Returns the PointLight.
  107884. */
  107885. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107886. protected _buildUniformLayout(): void;
  107887. /**
  107888. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107889. * @param effect The effect to update
  107890. * @param lightIndex The index of the light in the effect to update
  107891. * @returns The point light
  107892. */
  107893. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107894. /**
  107895. * Prepares the list of defines specific to the light type.
  107896. * @param defines the list of defines
  107897. * @param lightIndex defines the index of the light for the effect
  107898. */
  107899. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107900. }
  107901. }
  107902. declare module BABYLON {
  107903. /**
  107904. * Header information of HDR texture files.
  107905. */
  107906. export interface HDRInfo {
  107907. /**
  107908. * The height of the texture in pixels.
  107909. */
  107910. height: number;
  107911. /**
  107912. * The width of the texture in pixels.
  107913. */
  107914. width: number;
  107915. /**
  107916. * The index of the beginning of the data in the binary file.
  107917. */
  107918. dataPosition: number;
  107919. }
  107920. /**
  107921. * This groups tools to convert HDR texture to native colors array.
  107922. */
  107923. export class HDRTools {
  107924. private static Ldexp;
  107925. private static Rgbe2float;
  107926. private static readStringLine;
  107927. /**
  107928. * Reads header information from an RGBE texture stored in a native array.
  107929. * More information on this format are available here:
  107930. * https://en.wikipedia.org/wiki/RGBE_image_format
  107931. *
  107932. * @param uint8array The binary file stored in native array.
  107933. * @return The header information.
  107934. */
  107935. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107936. /**
  107937. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107938. * This RGBE texture needs to store the information as a panorama.
  107939. *
  107940. * More information on this format are available here:
  107941. * https://en.wikipedia.org/wiki/RGBE_image_format
  107942. *
  107943. * @param buffer The binary file stored in an array buffer.
  107944. * @param size The expected size of the extracted cubemap.
  107945. * @return The Cube Map information.
  107946. */
  107947. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107948. /**
  107949. * Returns the pixels data extracted from an RGBE texture.
  107950. * This pixels will be stored left to right up to down in the R G B order in one array.
  107951. *
  107952. * More information on this format are available here:
  107953. * https://en.wikipedia.org/wiki/RGBE_image_format
  107954. *
  107955. * @param uint8array The binary file stored in an array buffer.
  107956. * @param hdrInfo The header information of the file.
  107957. * @return The pixels data in RGB right to left up to down order.
  107958. */
  107959. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107960. private static RGBE_ReadPixels_RLE;
  107961. }
  107962. }
  107963. declare module BABYLON {
  107964. /**
  107965. * This represents a texture coming from an HDR input.
  107966. *
  107967. * The only supported format is currently panorama picture stored in RGBE format.
  107968. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107969. */
  107970. export class HDRCubeTexture extends BaseTexture {
  107971. private static _facesMapping;
  107972. private _generateHarmonics;
  107973. private _noMipmap;
  107974. private _textureMatrix;
  107975. private _size;
  107976. private _onLoad;
  107977. private _onError;
  107978. /**
  107979. * The texture URL.
  107980. */
  107981. url: string;
  107982. /**
  107983. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107984. */
  107985. coordinatesMode: number;
  107986. protected _isBlocking: boolean;
  107987. /**
  107988. * Sets wether or not the texture is blocking during loading.
  107989. */
  107990. /**
  107991. * Gets wether or not the texture is blocking during loading.
  107992. */
  107993. isBlocking: boolean;
  107994. protected _rotationY: number;
  107995. /**
  107996. * Sets texture matrix rotation angle around Y axis in radians.
  107997. */
  107998. /**
  107999. * Gets texture matrix rotation angle around Y axis radians.
  108000. */
  108001. rotationY: number;
  108002. /**
  108003. * Gets or sets the center of the bounding box associated with the cube texture
  108004. * It must define where the camera used to render the texture was set
  108005. */
  108006. boundingBoxPosition: Vector3;
  108007. private _boundingBoxSize;
  108008. /**
  108009. * Gets or sets the size of the bounding box associated with the cube texture
  108010. * When defined, the cubemap will switch to local mode
  108011. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108012. * @example https://www.babylonjs-playground.com/#RNASML
  108013. */
  108014. boundingBoxSize: Vector3;
  108015. /**
  108016. * Instantiates an HDRTexture from the following parameters.
  108017. *
  108018. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108019. * @param scene The scene the texture will be used in
  108020. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108021. * @param noMipmap Forces to not generate the mipmap if true
  108022. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108023. * @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)
  108024. * @param reserved Reserved flag for internal use.
  108025. */
  108026. 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>);
  108027. /**
  108028. * Get the current class name of the texture useful for serialization or dynamic coding.
  108029. * @returns "HDRCubeTexture"
  108030. */
  108031. getClassName(): string;
  108032. /**
  108033. * Occurs when the file is raw .hdr file.
  108034. */
  108035. private loadTexture;
  108036. clone(): HDRCubeTexture;
  108037. delayLoad(): void;
  108038. /**
  108039. * Get the texture reflection matrix used to rotate/transform the reflection.
  108040. * @returns the reflection matrix
  108041. */
  108042. getReflectionTextureMatrix(): Matrix;
  108043. /**
  108044. * Set the texture reflection matrix used to rotate/transform the reflection.
  108045. * @param value Define the reflection matrix to set
  108046. */
  108047. setReflectionTextureMatrix(value: Matrix): void;
  108048. /**
  108049. * Parses a JSON representation of an HDR Texture in order to create the texture
  108050. * @param parsedTexture Define the JSON representation
  108051. * @param scene Define the scene the texture should be created in
  108052. * @param rootUrl Define the root url in case we need to load relative dependencies
  108053. * @returns the newly created texture after parsing
  108054. */
  108055. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108056. serialize(): any;
  108057. }
  108058. }
  108059. declare module BABYLON {
  108060. /**
  108061. * Class used to control physics engine
  108062. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108063. */
  108064. export class PhysicsEngine implements IPhysicsEngine {
  108065. private _physicsPlugin;
  108066. /**
  108067. * Global value used to control the smallest number supported by the simulation
  108068. */
  108069. static Epsilon: number;
  108070. private _impostors;
  108071. private _joints;
  108072. /**
  108073. * Gets the gravity vector used by the simulation
  108074. */
  108075. gravity: Vector3;
  108076. /**
  108077. * Factory used to create the default physics plugin.
  108078. * @returns The default physics plugin
  108079. */
  108080. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108081. /**
  108082. * Creates a new Physics Engine
  108083. * @param gravity defines the gravity vector used by the simulation
  108084. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108085. */
  108086. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108087. /**
  108088. * Sets the gravity vector used by the simulation
  108089. * @param gravity defines the gravity vector to use
  108090. */
  108091. setGravity(gravity: Vector3): void;
  108092. /**
  108093. * Set the time step of the physics engine.
  108094. * Default is 1/60.
  108095. * To slow it down, enter 1/600 for example.
  108096. * To speed it up, 1/30
  108097. * @param newTimeStep defines the new timestep to apply to this world.
  108098. */
  108099. setTimeStep(newTimeStep?: number): void;
  108100. /**
  108101. * Get the time step of the physics engine.
  108102. * @returns the current time step
  108103. */
  108104. getTimeStep(): number;
  108105. /**
  108106. * Release all resources
  108107. */
  108108. dispose(): void;
  108109. /**
  108110. * Gets the name of the current physics plugin
  108111. * @returns the name of the plugin
  108112. */
  108113. getPhysicsPluginName(): string;
  108114. /**
  108115. * Adding a new impostor for the impostor tracking.
  108116. * This will be done by the impostor itself.
  108117. * @param impostor the impostor to add
  108118. */
  108119. addImpostor(impostor: PhysicsImpostor): void;
  108120. /**
  108121. * Remove an impostor from the engine.
  108122. * This impostor and its mesh will not longer be updated by the physics engine.
  108123. * @param impostor the impostor to remove
  108124. */
  108125. removeImpostor(impostor: PhysicsImpostor): void;
  108126. /**
  108127. * Add a joint to the physics engine
  108128. * @param mainImpostor defines the main impostor to which the joint is added.
  108129. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108130. * @param joint defines the joint that will connect both impostors.
  108131. */
  108132. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108133. /**
  108134. * Removes a joint from the simulation
  108135. * @param mainImpostor defines the impostor used with the joint
  108136. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108137. * @param joint defines the joint to remove
  108138. */
  108139. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108140. /**
  108141. * Called by the scene. No need to call it.
  108142. * @param delta defines the timespam between frames
  108143. */
  108144. _step(delta: number): void;
  108145. /**
  108146. * Gets the current plugin used to run the simulation
  108147. * @returns current plugin
  108148. */
  108149. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108150. /**
  108151. * Gets the list of physic impostors
  108152. * @returns an array of PhysicsImpostor
  108153. */
  108154. getImpostors(): Array<PhysicsImpostor>;
  108155. /**
  108156. * Gets the impostor for a physics enabled object
  108157. * @param object defines the object impersonated by the impostor
  108158. * @returns the PhysicsImpostor or null if not found
  108159. */
  108160. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108161. /**
  108162. * Gets the impostor for a physics body object
  108163. * @param body defines physics body used by the impostor
  108164. * @returns the PhysicsImpostor or null if not found
  108165. */
  108166. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108167. /**
  108168. * Does a raycast in the physics world
  108169. * @param from when should the ray start?
  108170. * @param to when should the ray end?
  108171. * @returns PhysicsRaycastResult
  108172. */
  108173. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108174. }
  108175. }
  108176. declare module BABYLON {
  108177. /** @hidden */
  108178. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108179. private _useDeltaForWorldStep;
  108180. world: any;
  108181. name: string;
  108182. private _physicsMaterials;
  108183. private _fixedTimeStep;
  108184. private _cannonRaycastResult;
  108185. private _raycastResult;
  108186. private _removeAfterStep;
  108187. BJSCANNON: any;
  108188. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108189. setGravity(gravity: Vector3): void;
  108190. setTimeStep(timeStep: number): void;
  108191. getTimeStep(): number;
  108192. executeStep(delta: number): void;
  108193. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108194. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108195. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108196. private _processChildMeshes;
  108197. removePhysicsBody(impostor: PhysicsImpostor): void;
  108198. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108199. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108200. private _addMaterial;
  108201. private _checkWithEpsilon;
  108202. private _createShape;
  108203. private _createHeightmap;
  108204. private _minus90X;
  108205. private _plus90X;
  108206. private _tmpPosition;
  108207. private _tmpDeltaPosition;
  108208. private _tmpUnityRotation;
  108209. private _updatePhysicsBodyTransformation;
  108210. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108211. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108212. isSupported(): boolean;
  108213. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108214. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108215. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108216. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108218. getBodyMass(impostor: PhysicsImpostor): number;
  108219. getBodyFriction(impostor: PhysicsImpostor): number;
  108220. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108221. getBodyRestitution(impostor: PhysicsImpostor): number;
  108222. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108223. sleepBody(impostor: PhysicsImpostor): void;
  108224. wakeUpBody(impostor: PhysicsImpostor): void;
  108225. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108226. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108227. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108228. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108229. getRadius(impostor: PhysicsImpostor): number;
  108230. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108231. dispose(): void;
  108232. private _extendNamespace;
  108233. /**
  108234. * Does a raycast in the physics world
  108235. * @param from when should the ray start?
  108236. * @param to when should the ray end?
  108237. * @returns PhysicsRaycastResult
  108238. */
  108239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108240. }
  108241. }
  108242. declare module BABYLON {
  108243. /** @hidden */
  108244. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108245. world: any;
  108246. name: string;
  108247. BJSOIMO: any;
  108248. private _raycastResult;
  108249. constructor(iterations?: number, oimoInjection?: any);
  108250. setGravity(gravity: Vector3): void;
  108251. setTimeStep(timeStep: number): void;
  108252. getTimeStep(): number;
  108253. private _tmpImpostorsArray;
  108254. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108255. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108256. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108257. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108258. private _tmpPositionVector;
  108259. removePhysicsBody(impostor: PhysicsImpostor): void;
  108260. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108261. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108262. isSupported(): boolean;
  108263. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108264. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108265. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108266. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108267. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108268. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108269. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108270. getBodyMass(impostor: PhysicsImpostor): number;
  108271. getBodyFriction(impostor: PhysicsImpostor): number;
  108272. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108273. getBodyRestitution(impostor: PhysicsImpostor): number;
  108274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108275. sleepBody(impostor: PhysicsImpostor): void;
  108276. wakeUpBody(impostor: PhysicsImpostor): void;
  108277. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108278. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108280. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108281. getRadius(impostor: PhysicsImpostor): number;
  108282. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108283. dispose(): void;
  108284. /**
  108285. * Does a raycast in the physics world
  108286. * @param from when should the ray start?
  108287. * @param to when should the ray end?
  108288. * @returns PhysicsRaycastResult
  108289. */
  108290. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108291. }
  108292. }
  108293. declare module BABYLON {
  108294. /**
  108295. * Class containing static functions to help procedurally build meshes
  108296. */
  108297. export class RibbonBuilder {
  108298. /**
  108299. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108300. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108301. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108302. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108303. * * 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
  108304. * * 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
  108305. * * 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
  108306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108309. * * 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
  108310. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108311. * * 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
  108312. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108314. * @param name defines the name of the mesh
  108315. * @param options defines the options used to create the mesh
  108316. * @param scene defines the hosting scene
  108317. * @returns the ribbon mesh
  108318. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108319. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108320. */
  108321. static CreateRibbon(name: string, options: {
  108322. pathArray: Vector3[][];
  108323. closeArray?: boolean;
  108324. closePath?: boolean;
  108325. offset?: number;
  108326. updatable?: boolean;
  108327. sideOrientation?: number;
  108328. frontUVs?: Vector4;
  108329. backUVs?: Vector4;
  108330. instance?: Mesh;
  108331. invertUV?: boolean;
  108332. uvs?: Vector2[];
  108333. colors?: Color4[];
  108334. }, scene?: Nullable<Scene>): Mesh;
  108335. }
  108336. }
  108337. declare module BABYLON {
  108338. /**
  108339. * Class containing static functions to help procedurally build meshes
  108340. */
  108341. export class ShapeBuilder {
  108342. /**
  108343. * 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.
  108344. * * 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.
  108345. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108346. * * 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.
  108347. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108348. * * 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
  108349. * * 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
  108350. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108355. * @param name defines the name of the mesh
  108356. * @param options defines the options used to create the mesh
  108357. * @param scene defines the hosting scene
  108358. * @returns the extruded shape mesh
  108359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108361. */
  108362. static ExtrudeShape(name: string, options: {
  108363. shape: Vector3[];
  108364. path: Vector3[];
  108365. scale?: number;
  108366. rotation?: number;
  108367. cap?: number;
  108368. updatable?: boolean;
  108369. sideOrientation?: number;
  108370. frontUVs?: Vector4;
  108371. backUVs?: Vector4;
  108372. instance?: Mesh;
  108373. invertUV?: boolean;
  108374. }, scene?: Nullable<Scene>): Mesh;
  108375. /**
  108376. * Creates an custom extruded shape mesh.
  108377. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108378. * * 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.
  108379. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108380. * * 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
  108381. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108382. * * 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
  108383. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108384. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108385. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108386. * * 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
  108387. * * 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
  108388. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108393. * @param name defines the name of the mesh
  108394. * @param options defines the options used to create the mesh
  108395. * @param scene defines the hosting scene
  108396. * @returns the custom extruded shape mesh
  108397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108398. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108400. */
  108401. static ExtrudeShapeCustom(name: string, options: {
  108402. shape: Vector3[];
  108403. path: Vector3[];
  108404. scaleFunction?: any;
  108405. rotationFunction?: any;
  108406. ribbonCloseArray?: boolean;
  108407. ribbonClosePath?: boolean;
  108408. cap?: number;
  108409. updatable?: boolean;
  108410. sideOrientation?: number;
  108411. frontUVs?: Vector4;
  108412. backUVs?: Vector4;
  108413. instance?: Mesh;
  108414. invertUV?: boolean;
  108415. }, scene?: Nullable<Scene>): Mesh;
  108416. private static _ExtrudeShapeGeneric;
  108417. }
  108418. }
  108419. declare module BABYLON {
  108420. /**
  108421. * AmmoJS Physics plugin
  108422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108423. * @see https://github.com/kripken/ammo.js/
  108424. */
  108425. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108426. private _useDeltaForWorldStep;
  108427. /**
  108428. * Reference to the Ammo library
  108429. */
  108430. bjsAMMO: any;
  108431. /**
  108432. * Created ammoJS world which physics bodies are added to
  108433. */
  108434. world: any;
  108435. /**
  108436. * Name of the plugin
  108437. */
  108438. name: string;
  108439. private _timeStep;
  108440. private _fixedTimeStep;
  108441. private _maxSteps;
  108442. private _tmpQuaternion;
  108443. private _tmpAmmoTransform;
  108444. private _tmpAmmoQuaternion;
  108445. private _tmpAmmoConcreteContactResultCallback;
  108446. private _collisionConfiguration;
  108447. private _dispatcher;
  108448. private _overlappingPairCache;
  108449. private _solver;
  108450. private _softBodySolver;
  108451. private _tmpAmmoVectorA;
  108452. private _tmpAmmoVectorB;
  108453. private _tmpAmmoVectorC;
  108454. private _tmpAmmoVectorD;
  108455. private _tmpContactCallbackResult;
  108456. private _tmpAmmoVectorRCA;
  108457. private _tmpAmmoVectorRCB;
  108458. private _raycastResult;
  108459. private static readonly DISABLE_COLLISION_FLAG;
  108460. private static readonly KINEMATIC_FLAG;
  108461. private static readonly DISABLE_DEACTIVATION_FLAG;
  108462. /**
  108463. * Initializes the ammoJS plugin
  108464. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108465. * @param ammoInjection can be used to inject your own ammo reference
  108466. */
  108467. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108468. /**
  108469. * Sets the gravity of the physics world (m/(s^2))
  108470. * @param gravity Gravity to set
  108471. */
  108472. setGravity(gravity: Vector3): void;
  108473. /**
  108474. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108475. * @param timeStep timestep to use in seconds
  108476. */
  108477. setTimeStep(timeStep: number): void;
  108478. /**
  108479. * 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)
  108480. * @param fixedTimeStep fixedTimeStep to use in seconds
  108481. */
  108482. setFixedTimeStep(fixedTimeStep: number): void;
  108483. /**
  108484. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108485. * @param maxSteps the maximum number of steps by the physics engine per frame
  108486. */
  108487. setMaxSteps(maxSteps: number): void;
  108488. /**
  108489. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108490. * @returns the current timestep in seconds
  108491. */
  108492. getTimeStep(): number;
  108493. private _isImpostorInContact;
  108494. private _isImpostorPairInContact;
  108495. private _stepSimulation;
  108496. /**
  108497. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108498. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108499. * After the step the babylon meshes are set to the position of the physics imposters
  108500. * @param delta amount of time to step forward
  108501. * @param impostors array of imposters to update before/after the step
  108502. */
  108503. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108504. /**
  108505. * Update babylon mesh to match physics world object
  108506. * @param impostor imposter to match
  108507. */
  108508. private _afterSoftStep;
  108509. /**
  108510. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108511. * @param impostor imposter to match
  108512. */
  108513. private _ropeStep;
  108514. /**
  108515. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108516. * @param impostor imposter to match
  108517. */
  108518. private _softbodyOrClothStep;
  108519. private _tmpVector;
  108520. private _tmpMatrix;
  108521. /**
  108522. * Applies an impulse on the imposter
  108523. * @param impostor imposter to apply impulse to
  108524. * @param force amount of force to be applied to the imposter
  108525. * @param contactPoint the location to apply the impulse on the imposter
  108526. */
  108527. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108528. /**
  108529. * Applies a force on the imposter
  108530. * @param impostor imposter to apply force
  108531. * @param force amount of force to be applied to the imposter
  108532. * @param contactPoint the location to apply the force on the imposter
  108533. */
  108534. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108535. /**
  108536. * Creates a physics body using the plugin
  108537. * @param impostor the imposter to create the physics body on
  108538. */
  108539. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108540. /**
  108541. * Removes the physics body from the imposter and disposes of the body's memory
  108542. * @param impostor imposter to remove the physics body from
  108543. */
  108544. removePhysicsBody(impostor: PhysicsImpostor): void;
  108545. /**
  108546. * Generates a joint
  108547. * @param impostorJoint the imposter joint to create the joint with
  108548. */
  108549. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108550. /**
  108551. * Removes a joint
  108552. * @param impostorJoint the imposter joint to remove the joint from
  108553. */
  108554. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108555. private _addMeshVerts;
  108556. /**
  108557. * Initialise the soft body vertices to match its object's (mesh) vertices
  108558. * Softbody vertices (nodes) are in world space and to match this
  108559. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108560. * @param impostor to create the softbody for
  108561. */
  108562. private _softVertexData;
  108563. /**
  108564. * Create an impostor's soft body
  108565. * @param impostor to create the softbody for
  108566. */
  108567. private _createSoftbody;
  108568. /**
  108569. * Create cloth for an impostor
  108570. * @param impostor to create the softbody for
  108571. */
  108572. private _createCloth;
  108573. /**
  108574. * Create rope for an impostor
  108575. * @param impostor to create the softbody for
  108576. */
  108577. private _createRope;
  108578. private _addHullVerts;
  108579. private _createShape;
  108580. /**
  108581. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108582. * @param impostor imposter containing the physics body and babylon object
  108583. */
  108584. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108585. /**
  108586. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108587. * @param impostor imposter containing the physics body and babylon object
  108588. * @param newPosition new position
  108589. * @param newRotation new rotation
  108590. */
  108591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108592. /**
  108593. * If this plugin is supported
  108594. * @returns true if its supported
  108595. */
  108596. isSupported(): boolean;
  108597. /**
  108598. * Sets the linear velocity of the physics body
  108599. * @param impostor imposter to set the velocity on
  108600. * @param velocity velocity to set
  108601. */
  108602. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108603. /**
  108604. * Sets the angular velocity of the physics body
  108605. * @param impostor imposter to set the velocity on
  108606. * @param velocity velocity to set
  108607. */
  108608. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108609. /**
  108610. * gets the linear velocity
  108611. * @param impostor imposter to get linear velocity from
  108612. * @returns linear velocity
  108613. */
  108614. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108615. /**
  108616. * gets the angular velocity
  108617. * @param impostor imposter to get angular velocity from
  108618. * @returns angular velocity
  108619. */
  108620. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108621. /**
  108622. * Sets the mass of physics body
  108623. * @param impostor imposter to set the mass on
  108624. * @param mass mass to set
  108625. */
  108626. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108627. /**
  108628. * Gets the mass of the physics body
  108629. * @param impostor imposter to get the mass from
  108630. * @returns mass
  108631. */
  108632. getBodyMass(impostor: PhysicsImpostor): number;
  108633. /**
  108634. * Gets friction of the impostor
  108635. * @param impostor impostor to get friction from
  108636. * @returns friction value
  108637. */
  108638. getBodyFriction(impostor: PhysicsImpostor): number;
  108639. /**
  108640. * Sets friction of the impostor
  108641. * @param impostor impostor to set friction on
  108642. * @param friction friction value
  108643. */
  108644. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108645. /**
  108646. * Gets restitution of the impostor
  108647. * @param impostor impostor to get restitution from
  108648. * @returns restitution value
  108649. */
  108650. getBodyRestitution(impostor: PhysicsImpostor): number;
  108651. /**
  108652. * Sets resitution of the impostor
  108653. * @param impostor impostor to set resitution on
  108654. * @param restitution resitution value
  108655. */
  108656. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108657. /**
  108658. * Gets pressure inside the impostor
  108659. * @param impostor impostor to get pressure from
  108660. * @returns pressure value
  108661. */
  108662. getBodyPressure(impostor: PhysicsImpostor): number;
  108663. /**
  108664. * Sets pressure inside a soft body impostor
  108665. * Cloth and rope must remain 0 pressure
  108666. * @param impostor impostor to set pressure on
  108667. * @param pressure pressure value
  108668. */
  108669. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108670. /**
  108671. * Gets stiffness of the impostor
  108672. * @param impostor impostor to get stiffness from
  108673. * @returns pressure value
  108674. */
  108675. getBodyStiffness(impostor: PhysicsImpostor): number;
  108676. /**
  108677. * Sets stiffness of the impostor
  108678. * @param impostor impostor to set stiffness on
  108679. * @param stiffness stiffness value from 0 to 1
  108680. */
  108681. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108682. /**
  108683. * Gets velocityIterations of the impostor
  108684. * @param impostor impostor to get velocity iterations from
  108685. * @returns velocityIterations value
  108686. */
  108687. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108688. /**
  108689. * Sets velocityIterations of the impostor
  108690. * @param impostor impostor to set velocity iterations on
  108691. * @param velocityIterations velocityIterations value
  108692. */
  108693. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108694. /**
  108695. * Gets positionIterations of the impostor
  108696. * @param impostor impostor to get position iterations from
  108697. * @returns positionIterations value
  108698. */
  108699. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108700. /**
  108701. * Sets positionIterations of the impostor
  108702. * @param impostor impostor to set position on
  108703. * @param positionIterations positionIterations value
  108704. */
  108705. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108706. /**
  108707. * Append an anchor to a cloth object
  108708. * @param impostor is the cloth impostor to add anchor to
  108709. * @param otherImpostor is the rigid impostor to anchor to
  108710. * @param width ratio across width from 0 to 1
  108711. * @param height ratio up height from 0 to 1
  108712. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108713. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108714. */
  108715. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108716. /**
  108717. * Append an hook to a rope object
  108718. * @param impostor is the rope impostor to add hook to
  108719. * @param otherImpostor is the rigid impostor to hook to
  108720. * @param length ratio along the rope from 0 to 1
  108721. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108722. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108723. */
  108724. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108725. /**
  108726. * Sleeps the physics body and stops it from being active
  108727. * @param impostor impostor to sleep
  108728. */
  108729. sleepBody(impostor: PhysicsImpostor): void;
  108730. /**
  108731. * Activates the physics body
  108732. * @param impostor impostor to activate
  108733. */
  108734. wakeUpBody(impostor: PhysicsImpostor): void;
  108735. /**
  108736. * Updates the distance parameters of the joint
  108737. * @param joint joint to update
  108738. * @param maxDistance maximum distance of the joint
  108739. * @param minDistance minimum distance of the joint
  108740. */
  108741. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108742. /**
  108743. * Sets a motor on the joint
  108744. * @param joint joint to set motor on
  108745. * @param speed speed of the motor
  108746. * @param maxForce maximum force of the motor
  108747. * @param motorIndex index of the motor
  108748. */
  108749. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108750. /**
  108751. * Sets the motors limit
  108752. * @param joint joint to set limit on
  108753. * @param upperLimit upper limit
  108754. * @param lowerLimit lower limit
  108755. */
  108756. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108757. /**
  108758. * Syncs the position and rotation of a mesh with the impostor
  108759. * @param mesh mesh to sync
  108760. * @param impostor impostor to update the mesh with
  108761. */
  108762. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108763. /**
  108764. * Gets the radius of the impostor
  108765. * @param impostor impostor to get radius from
  108766. * @returns the radius
  108767. */
  108768. getRadius(impostor: PhysicsImpostor): number;
  108769. /**
  108770. * Gets the box size of the impostor
  108771. * @param impostor impostor to get box size from
  108772. * @param result the resulting box size
  108773. */
  108774. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108775. /**
  108776. * Disposes of the impostor
  108777. */
  108778. dispose(): void;
  108779. /**
  108780. * Does a raycast in the physics world
  108781. * @param from when should the ray start?
  108782. * @param to when should the ray end?
  108783. * @returns PhysicsRaycastResult
  108784. */
  108785. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108786. }
  108787. }
  108788. declare module BABYLON {
  108789. interface AbstractScene {
  108790. /**
  108791. * The list of reflection probes added to the scene
  108792. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108793. */
  108794. reflectionProbes: Array<ReflectionProbe>;
  108795. /**
  108796. * Removes the given reflection probe from this scene.
  108797. * @param toRemove The reflection probe to remove
  108798. * @returns The index of the removed reflection probe
  108799. */
  108800. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108801. /**
  108802. * Adds the given reflection probe to this scene.
  108803. * @param newReflectionProbe The reflection probe to add
  108804. */
  108805. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108806. }
  108807. /**
  108808. * Class used to generate realtime reflection / refraction cube textures
  108809. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108810. */
  108811. export class ReflectionProbe {
  108812. /** defines the name of the probe */
  108813. name: string;
  108814. private _scene;
  108815. private _renderTargetTexture;
  108816. private _projectionMatrix;
  108817. private _viewMatrix;
  108818. private _target;
  108819. private _add;
  108820. private _attachedMesh;
  108821. private _invertYAxis;
  108822. /** Gets or sets probe position (center of the cube map) */
  108823. position: Vector3;
  108824. /**
  108825. * Creates a new reflection probe
  108826. * @param name defines the name of the probe
  108827. * @param size defines the texture resolution (for each face)
  108828. * @param scene defines the hosting scene
  108829. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108830. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108831. */
  108832. constructor(
  108833. /** defines the name of the probe */
  108834. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108835. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108836. samples: number;
  108837. /** Gets or sets the refresh rate to use (on every frame by default) */
  108838. refreshRate: number;
  108839. /**
  108840. * Gets the hosting scene
  108841. * @returns a Scene
  108842. */
  108843. getScene(): Scene;
  108844. /** Gets the internal CubeTexture used to render to */
  108845. readonly cubeTexture: RenderTargetTexture;
  108846. /** Gets the list of meshes to render */
  108847. readonly renderList: Nullable<AbstractMesh[]>;
  108848. /**
  108849. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108850. * @param mesh defines the mesh to attach to
  108851. */
  108852. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108853. /**
  108854. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108855. * @param renderingGroupId The rendering group id corresponding to its index
  108856. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108857. */
  108858. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108859. /**
  108860. * Clean all associated resources
  108861. */
  108862. dispose(): void;
  108863. /**
  108864. * Converts the reflection probe information to a readable string for debug purpose.
  108865. * @param fullDetails Supports for multiple levels of logging within scene loading
  108866. * @returns the human readable reflection probe info
  108867. */
  108868. toString(fullDetails?: boolean): string;
  108869. /**
  108870. * Get the class name of the relfection probe.
  108871. * @returns "ReflectionProbe"
  108872. */
  108873. getClassName(): string;
  108874. /**
  108875. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108876. * @returns The JSON representation of the texture
  108877. */
  108878. serialize(): any;
  108879. /**
  108880. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108881. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108882. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108883. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108884. * @returns The parsed reflection probe if successful
  108885. */
  108886. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108887. }
  108888. }
  108889. declare module BABYLON {
  108890. /** @hidden */
  108891. export var _BabylonLoaderRegistered: boolean;
  108892. }
  108893. declare module BABYLON {
  108894. /**
  108895. * The Physically based simple base material of BJS.
  108896. *
  108897. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108898. * It is used as the base class for both the specGloss and metalRough conventions.
  108899. */
  108900. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108901. /**
  108902. * Number of Simultaneous lights allowed on the material.
  108903. */
  108904. maxSimultaneousLights: number;
  108905. /**
  108906. * If sets to true, disables all the lights affecting the material.
  108907. */
  108908. disableLighting: boolean;
  108909. /**
  108910. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108911. */
  108912. environmentTexture: BaseTexture;
  108913. /**
  108914. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108915. */
  108916. invertNormalMapX: boolean;
  108917. /**
  108918. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108919. */
  108920. invertNormalMapY: boolean;
  108921. /**
  108922. * Normal map used in the model.
  108923. */
  108924. normalTexture: BaseTexture;
  108925. /**
  108926. * Emissivie color used to self-illuminate the model.
  108927. */
  108928. emissiveColor: Color3;
  108929. /**
  108930. * Emissivie texture used to self-illuminate the model.
  108931. */
  108932. emissiveTexture: BaseTexture;
  108933. /**
  108934. * Occlusion Channel Strenght.
  108935. */
  108936. occlusionStrength: number;
  108937. /**
  108938. * Occlusion Texture of the material (adding extra occlusion effects).
  108939. */
  108940. occlusionTexture: BaseTexture;
  108941. /**
  108942. * Defines the alpha limits in alpha test mode.
  108943. */
  108944. alphaCutOff: number;
  108945. /**
  108946. * Gets the current double sided mode.
  108947. */
  108948. /**
  108949. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108950. */
  108951. doubleSided: boolean;
  108952. /**
  108953. * Stores the pre-calculated light information of a mesh in a texture.
  108954. */
  108955. lightmapTexture: BaseTexture;
  108956. /**
  108957. * If true, the light map contains occlusion information instead of lighting info.
  108958. */
  108959. useLightmapAsShadowmap: boolean;
  108960. /**
  108961. * Instantiates a new PBRMaterial instance.
  108962. *
  108963. * @param name The material name
  108964. * @param scene The scene the material will be use in.
  108965. */
  108966. constructor(name: string, scene: Scene);
  108967. getClassName(): string;
  108968. }
  108969. }
  108970. declare module BABYLON {
  108971. /**
  108972. * The PBR material of BJS following the metal roughness convention.
  108973. *
  108974. * This fits to the PBR convention in the GLTF definition:
  108975. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108976. */
  108977. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108978. /**
  108979. * The base color has two different interpretations depending on the value of metalness.
  108980. * When the material is a metal, the base color is the specific measured reflectance value
  108981. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108982. * of the material.
  108983. */
  108984. baseColor: Color3;
  108985. /**
  108986. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108987. * well as opacity information in the alpha channel.
  108988. */
  108989. baseTexture: BaseTexture;
  108990. /**
  108991. * Specifies the metallic scalar value of the material.
  108992. * Can also be used to scale the metalness values of the metallic texture.
  108993. */
  108994. metallic: number;
  108995. /**
  108996. * Specifies the roughness scalar value of the material.
  108997. * Can also be used to scale the roughness values of the metallic texture.
  108998. */
  108999. roughness: number;
  109000. /**
  109001. * Texture containing both the metallic value in the B channel and the
  109002. * roughness value in the G channel to keep better precision.
  109003. */
  109004. metallicRoughnessTexture: BaseTexture;
  109005. /**
  109006. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109007. *
  109008. * @param name The material name
  109009. * @param scene The scene the material will be use in.
  109010. */
  109011. constructor(name: string, scene: Scene);
  109012. /**
  109013. * Return the currrent class name of the material.
  109014. */
  109015. getClassName(): string;
  109016. /**
  109017. * Makes a duplicate of the current material.
  109018. * @param name - name to use for the new material.
  109019. */
  109020. clone(name: string): PBRMetallicRoughnessMaterial;
  109021. /**
  109022. * Serialize the material to a parsable JSON object.
  109023. */
  109024. serialize(): any;
  109025. /**
  109026. * Parses a JSON object correponding to the serialize function.
  109027. */
  109028. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109029. }
  109030. }
  109031. declare module BABYLON {
  109032. /**
  109033. * The PBR material of BJS following the specular glossiness convention.
  109034. *
  109035. * This fits to the PBR convention in the GLTF definition:
  109036. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109037. */
  109038. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109039. /**
  109040. * Specifies the diffuse color of the material.
  109041. */
  109042. diffuseColor: Color3;
  109043. /**
  109044. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109045. * channel.
  109046. */
  109047. diffuseTexture: BaseTexture;
  109048. /**
  109049. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109050. */
  109051. specularColor: Color3;
  109052. /**
  109053. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109054. */
  109055. glossiness: number;
  109056. /**
  109057. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109058. */
  109059. specularGlossinessTexture: BaseTexture;
  109060. /**
  109061. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109062. *
  109063. * @param name The material name
  109064. * @param scene The scene the material will be use in.
  109065. */
  109066. constructor(name: string, scene: Scene);
  109067. /**
  109068. * Return the currrent class name of the material.
  109069. */
  109070. getClassName(): string;
  109071. /**
  109072. * Makes a duplicate of the current material.
  109073. * @param name - name to use for the new material.
  109074. */
  109075. clone(name: string): PBRSpecularGlossinessMaterial;
  109076. /**
  109077. * Serialize the material to a parsable JSON object.
  109078. */
  109079. serialize(): any;
  109080. /**
  109081. * Parses a JSON object correponding to the serialize function.
  109082. */
  109083. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109084. }
  109085. }
  109086. declare module BABYLON {
  109087. /**
  109088. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109089. * It can help converting any input color in a desired output one. This can then be used to create effects
  109090. * from sepia, black and white to sixties or futuristic rendering...
  109091. *
  109092. * The only supported format is currently 3dl.
  109093. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109094. */
  109095. export class ColorGradingTexture extends BaseTexture {
  109096. /**
  109097. * The current texture matrix. (will always be identity in color grading texture)
  109098. */
  109099. private _textureMatrix;
  109100. /**
  109101. * The texture URL.
  109102. */
  109103. url: string;
  109104. /**
  109105. * Empty line regex stored for GC.
  109106. */
  109107. private static _noneEmptyLineRegex;
  109108. private _engine;
  109109. /**
  109110. * Instantiates a ColorGradingTexture from the following parameters.
  109111. *
  109112. * @param url The location of the color gradind data (currently only supporting 3dl)
  109113. * @param scene The scene the texture will be used in
  109114. */
  109115. constructor(url: string, scene: Scene);
  109116. /**
  109117. * Returns the texture matrix used in most of the material.
  109118. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109119. */
  109120. getTextureMatrix(): Matrix;
  109121. /**
  109122. * Occurs when the file being loaded is a .3dl LUT file.
  109123. */
  109124. private load3dlTexture;
  109125. /**
  109126. * Starts the loading process of the texture.
  109127. */
  109128. private loadTexture;
  109129. /**
  109130. * Clones the color gradind texture.
  109131. */
  109132. clone(): ColorGradingTexture;
  109133. /**
  109134. * Called during delayed load for textures.
  109135. */
  109136. delayLoad(): void;
  109137. /**
  109138. * Parses a color grading texture serialized by Babylon.
  109139. * @param parsedTexture The texture information being parsedTexture
  109140. * @param scene The scene to load the texture in
  109141. * @param rootUrl The root url of the data assets to load
  109142. * @return A color gradind texture
  109143. */
  109144. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109145. /**
  109146. * Serializes the LUT texture to json format.
  109147. */
  109148. serialize(): any;
  109149. }
  109150. }
  109151. declare module BABYLON {
  109152. /**
  109153. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109154. */
  109155. export class EquiRectangularCubeTexture extends BaseTexture {
  109156. /** The six faces of the cube. */
  109157. private static _FacesMapping;
  109158. private _noMipmap;
  109159. private _onLoad;
  109160. private _onError;
  109161. /** The size of the cubemap. */
  109162. private _size;
  109163. /** The buffer of the image. */
  109164. private _buffer;
  109165. /** The width of the input image. */
  109166. private _width;
  109167. /** The height of the input image. */
  109168. private _height;
  109169. /** The URL to the image. */
  109170. url: string;
  109171. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109172. coordinatesMode: number;
  109173. /**
  109174. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109175. * @param url The location of the image
  109176. * @param scene The scene the texture will be used in
  109177. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109178. * @param noMipmap Forces to not generate the mipmap if true
  109179. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109180. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109181. * @param onLoad — defines a callback called when texture is loaded
  109182. * @param onError — defines a callback called if there is an error
  109183. */
  109184. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109185. /**
  109186. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109187. */
  109188. private loadImage;
  109189. /**
  109190. * Convert the image buffer into a cubemap and create a CubeTexture.
  109191. */
  109192. private loadTexture;
  109193. /**
  109194. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109195. * @param buffer The ArrayBuffer that should be converted.
  109196. * @returns The buffer as Float32Array.
  109197. */
  109198. private getFloat32ArrayFromArrayBuffer;
  109199. /**
  109200. * Get the current class name of the texture useful for serialization or dynamic coding.
  109201. * @returns "EquiRectangularCubeTexture"
  109202. */
  109203. getClassName(): string;
  109204. /**
  109205. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109206. * @returns A clone of the current EquiRectangularCubeTexture.
  109207. */
  109208. clone(): EquiRectangularCubeTexture;
  109209. }
  109210. }
  109211. declare module BABYLON {
  109212. /**
  109213. * Based on jsTGALoader - Javascript loader for TGA file
  109214. * By Vincent Thibault
  109215. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109216. */
  109217. export class TGATools {
  109218. private static _TYPE_INDEXED;
  109219. private static _TYPE_RGB;
  109220. private static _TYPE_GREY;
  109221. private static _TYPE_RLE_INDEXED;
  109222. private static _TYPE_RLE_RGB;
  109223. private static _TYPE_RLE_GREY;
  109224. private static _ORIGIN_MASK;
  109225. private static _ORIGIN_SHIFT;
  109226. private static _ORIGIN_BL;
  109227. private static _ORIGIN_BR;
  109228. private static _ORIGIN_UL;
  109229. private static _ORIGIN_UR;
  109230. /**
  109231. * Gets the header of a TGA file
  109232. * @param data defines the TGA data
  109233. * @returns the header
  109234. */
  109235. static GetTGAHeader(data: Uint8Array): any;
  109236. /**
  109237. * Uploads TGA content to a Babylon Texture
  109238. * @hidden
  109239. */
  109240. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109241. /** @hidden */
  109242. 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;
  109243. /** @hidden */
  109244. 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;
  109245. /** @hidden */
  109246. 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;
  109247. /** @hidden */
  109248. 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;
  109249. /** @hidden */
  109250. 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;
  109251. /** @hidden */
  109252. 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;
  109253. }
  109254. }
  109255. declare module BABYLON {
  109256. /**
  109257. * Implementation of the TGA Texture Loader.
  109258. * @hidden
  109259. */
  109260. export class _TGATextureLoader implements IInternalTextureLoader {
  109261. /**
  109262. * Defines wether the loader supports cascade loading the different faces.
  109263. */
  109264. readonly supportCascades: boolean;
  109265. /**
  109266. * This returns if the loader support the current file information.
  109267. * @param extension defines the file extension of the file being loaded
  109268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109269. * @param fallback defines the fallback internal texture if any
  109270. * @param isBase64 defines whether the texture is encoded as a base64
  109271. * @param isBuffer defines whether the texture data are stored as a buffer
  109272. * @returns true if the loader can load the specified file
  109273. */
  109274. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109275. /**
  109276. * Transform the url before loading if required.
  109277. * @param rootUrl the url of the texture
  109278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109279. * @returns the transformed texture
  109280. */
  109281. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109282. /**
  109283. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109284. * @param rootUrl the url of the texture
  109285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109286. * @returns the fallback texture
  109287. */
  109288. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109289. /**
  109290. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109291. * @param data contains the texture data
  109292. * @param texture defines the BabylonJS internal texture
  109293. * @param createPolynomials will be true if polynomials have been requested
  109294. * @param onLoad defines the callback to trigger once the texture is ready
  109295. * @param onError defines the callback to trigger in case of error
  109296. */
  109297. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109298. /**
  109299. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109300. * @param data contains the texture data
  109301. * @param texture defines the BabylonJS internal texture
  109302. * @param callback defines the method to call once ready to upload
  109303. */
  109304. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109305. }
  109306. }
  109307. declare module BABYLON {
  109308. /**
  109309. * 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.
  109310. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109311. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109312. */
  109313. export class CustomProceduralTexture extends ProceduralTexture {
  109314. private _animate;
  109315. private _time;
  109316. private _config;
  109317. private _texturePath;
  109318. /**
  109319. * Instantiates a new Custom Procedural Texture.
  109320. * 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.
  109321. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109322. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109323. * @param name Define the name of the texture
  109324. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109325. * @param size Define the size of the texture to create
  109326. * @param scene Define the scene the texture belongs to
  109327. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109328. * @param generateMipMaps Define if the texture should creates mip maps or not
  109329. */
  109330. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109331. private _loadJson;
  109332. /**
  109333. * Is the texture ready to be used ? (rendered at least once)
  109334. * @returns true if ready, otherwise, false.
  109335. */
  109336. isReady(): boolean;
  109337. /**
  109338. * Render the texture to its associated render target.
  109339. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109340. */
  109341. render(useCameraPostProcess?: boolean): void;
  109342. /**
  109343. * Update the list of dependant textures samplers in the shader.
  109344. */
  109345. updateTextures(): void;
  109346. /**
  109347. * Update the uniform values of the procedural texture in the shader.
  109348. */
  109349. updateShaderUniforms(): void;
  109350. /**
  109351. * Define if the texture animates or not.
  109352. */
  109353. animate: boolean;
  109354. }
  109355. }
  109356. declare module BABYLON {
  109357. /** @hidden */
  109358. export var noisePixelShader: {
  109359. name: string;
  109360. shader: string;
  109361. };
  109362. }
  109363. declare module BABYLON {
  109364. /**
  109365. * Class used to generate noise procedural textures
  109366. */
  109367. export class NoiseProceduralTexture extends ProceduralTexture {
  109368. private _time;
  109369. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109370. brightness: number;
  109371. /** Defines the number of octaves to process */
  109372. octaves: number;
  109373. /** Defines the level of persistence (0.8 by default) */
  109374. persistence: number;
  109375. /** Gets or sets animation speed factor (default is 1) */
  109376. animationSpeedFactor: number;
  109377. /**
  109378. * Creates a new NoiseProceduralTexture
  109379. * @param name defines the name fo the texture
  109380. * @param size defines the size of the texture (default is 256)
  109381. * @param scene defines the hosting scene
  109382. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109383. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109384. */
  109385. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109386. private _updateShaderUniforms;
  109387. protected _getDefines(): string;
  109388. /** Generate the current state of the procedural texture */
  109389. render(useCameraPostProcess?: boolean): void;
  109390. /**
  109391. * Serializes this noise procedural texture
  109392. * @returns a serialized noise procedural texture object
  109393. */
  109394. serialize(): any;
  109395. /**
  109396. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109397. * @param parsedTexture defines parsed texture data
  109398. * @param scene defines the current scene
  109399. * @param rootUrl defines the root URL containing noise procedural texture information
  109400. * @returns a parsed NoiseProceduralTexture
  109401. */
  109402. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109403. }
  109404. }
  109405. declare module BABYLON {
  109406. /**
  109407. * Raw cube texture where the raw buffers are passed in
  109408. */
  109409. export class RawCubeTexture extends CubeTexture {
  109410. /**
  109411. * Creates a cube texture where the raw buffers are passed in.
  109412. * @param scene defines the scene the texture is attached to
  109413. * @param data defines the array of data to use to create each face
  109414. * @param size defines the size of the textures
  109415. * @param format defines the format of the data
  109416. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109417. * @param generateMipMaps defines if the engine should generate the mip levels
  109418. * @param invertY defines if data must be stored with Y axis inverted
  109419. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109420. * @param compression defines the compression used (null by default)
  109421. */
  109422. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109423. /**
  109424. * Updates the raw cube texture.
  109425. * @param data defines the data to store
  109426. * @param format defines the data format
  109427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109428. * @param invertY defines if data must be stored with Y axis inverted
  109429. * @param compression defines the compression used (null by default)
  109430. * @param level defines which level of the texture to update
  109431. */
  109432. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109433. /**
  109434. * Updates a raw cube texture with RGBD encoded data.
  109435. * @param data defines the array of data [mipmap][face] to use to create each face
  109436. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109439. * @returns a promsie that resolves when the operation is complete
  109440. */
  109441. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109442. /**
  109443. * Clones the raw cube texture.
  109444. * @return a new cube texture
  109445. */
  109446. clone(): CubeTexture;
  109447. /** @hidden */
  109448. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109449. }
  109450. }
  109451. declare module BABYLON {
  109452. /**
  109453. * Class used to store 3D textures containing user data
  109454. */
  109455. export class RawTexture3D extends Texture {
  109456. /** Gets or sets the texture format to use */
  109457. format: number;
  109458. private _engine;
  109459. /**
  109460. * Create a new RawTexture3D
  109461. * @param data defines the data of the texture
  109462. * @param width defines the width of the texture
  109463. * @param height defines the height of the texture
  109464. * @param depth defines the depth of the texture
  109465. * @param format defines the texture format to use
  109466. * @param scene defines the hosting scene
  109467. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109468. * @param invertY defines if texture must be stored with Y axis inverted
  109469. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109470. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109471. */
  109472. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109473. /** Gets or sets the texture format to use */
  109474. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109475. /**
  109476. * Update the texture with new data
  109477. * @param data defines the data to store in the texture
  109478. */
  109479. update(data: ArrayBufferView): void;
  109480. }
  109481. }
  109482. declare module BABYLON {
  109483. /**
  109484. * Creates a refraction texture used by refraction channel of the standard material.
  109485. * It is like a mirror but to see through a material.
  109486. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109487. */
  109488. export class RefractionTexture extends RenderTargetTexture {
  109489. /**
  109490. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109491. * 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.
  109492. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109493. */
  109494. refractionPlane: Plane;
  109495. /**
  109496. * Define how deep under the surface we should see.
  109497. */
  109498. depth: number;
  109499. /**
  109500. * Creates a refraction texture used by refraction channel of the standard material.
  109501. * It is like a mirror but to see through a material.
  109502. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109503. * @param name Define the texture name
  109504. * @param size Define the size of the underlying texture
  109505. * @param scene Define the scene the refraction belongs to
  109506. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109507. */
  109508. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109509. /**
  109510. * Clone the refraction texture.
  109511. * @returns the cloned texture
  109512. */
  109513. clone(): RefractionTexture;
  109514. /**
  109515. * Serialize the texture to a JSON representation you could use in Parse later on
  109516. * @returns the serialized JSON representation
  109517. */
  109518. serialize(): any;
  109519. }
  109520. }
  109521. declare module BABYLON {
  109522. /**
  109523. * Defines the options related to the creation of an HtmlElementTexture
  109524. */
  109525. export interface IHtmlElementTextureOptions {
  109526. /**
  109527. * Defines wether mip maps should be created or not.
  109528. */
  109529. generateMipMaps?: boolean;
  109530. /**
  109531. * Defines the sampling mode of the texture.
  109532. */
  109533. samplingMode?: number;
  109534. /**
  109535. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109536. */
  109537. engine: Nullable<Engine>;
  109538. /**
  109539. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109540. */
  109541. scene: Nullable<Scene>;
  109542. }
  109543. /**
  109544. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109545. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109546. * is automatically managed.
  109547. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109548. * in your application.
  109549. *
  109550. * As the update is not automatic, you need to call them manually.
  109551. */
  109552. export class HtmlElementTexture extends BaseTexture {
  109553. /**
  109554. * The texture URL.
  109555. */
  109556. element: HTMLVideoElement | HTMLCanvasElement;
  109557. private static readonly DefaultOptions;
  109558. private _textureMatrix;
  109559. private _engine;
  109560. private _isVideo;
  109561. private _generateMipMaps;
  109562. private _samplingMode;
  109563. /**
  109564. * Instantiates a HtmlElementTexture from the following parameters.
  109565. *
  109566. * @param name Defines the name of the texture
  109567. * @param element Defines the video or canvas the texture is filled with
  109568. * @param options Defines the other none mandatory texture creation options
  109569. */
  109570. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109571. private _createInternalTexture;
  109572. /**
  109573. * Returns the texture matrix used in most of the material.
  109574. */
  109575. getTextureMatrix(): Matrix;
  109576. /**
  109577. * Updates the content of the texture.
  109578. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109579. */
  109580. update(invertY?: Nullable<boolean>): void;
  109581. }
  109582. }
  109583. declare module BABYLON {
  109584. /**
  109585. * Helper class to push actions to a pool of workers.
  109586. */
  109587. export class WorkerPool implements IDisposable {
  109588. private _workerInfos;
  109589. private _pendingActions;
  109590. /**
  109591. * Constructor
  109592. * @param workers Array of workers to use for actions
  109593. */
  109594. constructor(workers: Array<Worker>);
  109595. /**
  109596. * Terminates all workers and clears any pending actions.
  109597. */
  109598. dispose(): void;
  109599. /**
  109600. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109601. * pended until a worker has completed its action.
  109602. * @param action The action to perform. Call onComplete when the action is complete.
  109603. */
  109604. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109605. private _execute;
  109606. }
  109607. }
  109608. declare module BABYLON {
  109609. /**
  109610. * Configuration for Draco compression
  109611. */
  109612. export interface IDracoCompressionConfiguration {
  109613. /**
  109614. * Configuration for the decoder.
  109615. */
  109616. decoder?: {
  109617. /**
  109618. * The url to the WebAssembly module.
  109619. */
  109620. wasmUrl?: string;
  109621. /**
  109622. * The url to the WebAssembly binary.
  109623. */
  109624. wasmBinaryUrl?: string;
  109625. /**
  109626. * The url to the fallback JavaScript module.
  109627. */
  109628. fallbackUrl?: string;
  109629. };
  109630. }
  109631. /**
  109632. * Draco compression (https://google.github.io/draco/)
  109633. *
  109634. * This class wraps the Draco module.
  109635. *
  109636. * **Encoder**
  109637. *
  109638. * The encoder is not currently implemented.
  109639. *
  109640. * **Decoder**
  109641. *
  109642. * 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.
  109643. *
  109644. * To update the configuration, use the following code:
  109645. * ```javascript
  109646. * DracoCompression.Configuration = {
  109647. * decoder: {
  109648. * wasmUrl: "<url to the WebAssembly library>",
  109649. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109650. * fallbackUrl: "<url to the fallback JavaScript library>",
  109651. * }
  109652. * };
  109653. * ```
  109654. *
  109655. * 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.
  109656. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109657. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109658. *
  109659. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109660. * ```javascript
  109661. * var dracoCompression = new DracoCompression();
  109662. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109663. * [VertexBuffer.PositionKind]: 0
  109664. * });
  109665. * ```
  109666. *
  109667. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109668. */
  109669. export class DracoCompression implements IDisposable {
  109670. private _workerPoolPromise;
  109671. /**
  109672. * The configuration. Defaults to the following urls:
  109673. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109674. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109675. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109676. */
  109677. static Configuration: IDracoCompressionConfiguration;
  109678. /**
  109679. * Returns true if the decoder is available.
  109680. */
  109681. static readonly DecoderAvailable: boolean;
  109682. /**
  109683. * Default number of workers to create when creating the draco compression object.
  109684. */
  109685. static DefaultNumWorkers: number;
  109686. private static GetDefaultNumWorkers;
  109687. /**
  109688. * Constructor
  109689. * @param numWorkers The number of workers for async operations
  109690. */
  109691. constructor(numWorkers?: number);
  109692. /**
  109693. * Stop all async operations and release resources.
  109694. */
  109695. dispose(): void;
  109696. /**
  109697. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109698. * @returns a promise that resolves when ready
  109699. */
  109700. whenReadyAsync(): Promise<void>;
  109701. /**
  109702. * Decode Draco compressed mesh data to vertex data.
  109703. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109704. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109705. * @returns A promise that resolves with the decoded vertex data
  109706. */
  109707. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109708. [kind: string]: number;
  109709. }): Promise<VertexData>;
  109710. /**
  109711. * The worker function that gets converted to a blob url to pass into a worker.
  109712. */
  109713. private static _Worker;
  109714. private _loadDecoderWasmBinaryAsync;
  109715. }
  109716. }
  109717. declare module BABYLON {
  109718. /**
  109719. * Class for building Constructive Solid Geometry
  109720. */
  109721. export class CSG {
  109722. private polygons;
  109723. /**
  109724. * The world matrix
  109725. */
  109726. matrix: Matrix;
  109727. /**
  109728. * Stores the position
  109729. */
  109730. position: Vector3;
  109731. /**
  109732. * Stores the rotation
  109733. */
  109734. rotation: Vector3;
  109735. /**
  109736. * Stores the rotation quaternion
  109737. */
  109738. rotationQuaternion: Nullable<Quaternion>;
  109739. /**
  109740. * Stores the scaling vector
  109741. */
  109742. scaling: Vector3;
  109743. /**
  109744. * Convert the Mesh to CSG
  109745. * @param mesh The Mesh to convert to CSG
  109746. * @returns A new CSG from the Mesh
  109747. */
  109748. static FromMesh(mesh: Mesh): CSG;
  109749. /**
  109750. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109751. * @param polygons Polygons used to construct a CSG solid
  109752. */
  109753. private static FromPolygons;
  109754. /**
  109755. * Clones, or makes a deep copy, of the CSG
  109756. * @returns A new CSG
  109757. */
  109758. clone(): CSG;
  109759. /**
  109760. * Unions this CSG with another CSG
  109761. * @param csg The CSG to union against this CSG
  109762. * @returns The unioned CSG
  109763. */
  109764. union(csg: CSG): CSG;
  109765. /**
  109766. * Unions this CSG with another CSG in place
  109767. * @param csg The CSG to union against this CSG
  109768. */
  109769. unionInPlace(csg: CSG): void;
  109770. /**
  109771. * Subtracts this CSG with another CSG
  109772. * @param csg The CSG to subtract against this CSG
  109773. * @returns A new CSG
  109774. */
  109775. subtract(csg: CSG): CSG;
  109776. /**
  109777. * Subtracts this CSG with another CSG in place
  109778. * @param csg The CSG to subtact against this CSG
  109779. */
  109780. subtractInPlace(csg: CSG): void;
  109781. /**
  109782. * Intersect this CSG with another CSG
  109783. * @param csg The CSG to intersect against this CSG
  109784. * @returns A new CSG
  109785. */
  109786. intersect(csg: CSG): CSG;
  109787. /**
  109788. * Intersects this CSG with another CSG in place
  109789. * @param csg The CSG to intersect against this CSG
  109790. */
  109791. intersectInPlace(csg: CSG): void;
  109792. /**
  109793. * Return a new CSG solid with solid and empty space switched. This solid is
  109794. * not modified.
  109795. * @returns A new CSG solid with solid and empty space switched
  109796. */
  109797. inverse(): CSG;
  109798. /**
  109799. * Inverses the CSG in place
  109800. */
  109801. inverseInPlace(): void;
  109802. /**
  109803. * This is used to keep meshes transformations so they can be restored
  109804. * when we build back a Babylon Mesh
  109805. * NB : All CSG operations are performed in world coordinates
  109806. * @param csg The CSG to copy the transform attributes from
  109807. * @returns This CSG
  109808. */
  109809. copyTransformAttributes(csg: CSG): CSG;
  109810. /**
  109811. * Build Raw mesh from CSG
  109812. * Coordinates here are in world space
  109813. * @param name The name of the mesh geometry
  109814. * @param scene The Scene
  109815. * @param keepSubMeshes Specifies if the submeshes should be kept
  109816. * @returns A new Mesh
  109817. */
  109818. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109819. /**
  109820. * Build Mesh from CSG taking material and transforms into account
  109821. * @param name The name of the Mesh
  109822. * @param material The material of the Mesh
  109823. * @param scene The Scene
  109824. * @param keepSubMeshes Specifies if submeshes should be kept
  109825. * @returns The new Mesh
  109826. */
  109827. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109828. }
  109829. }
  109830. declare module BABYLON {
  109831. /**
  109832. * Class used to create a trail following a mesh
  109833. */
  109834. export class TrailMesh extends Mesh {
  109835. private _generator;
  109836. private _autoStart;
  109837. private _running;
  109838. private _diameter;
  109839. private _length;
  109840. private _sectionPolygonPointsCount;
  109841. private _sectionVectors;
  109842. private _sectionNormalVectors;
  109843. private _beforeRenderObserver;
  109844. /**
  109845. * @constructor
  109846. * @param name The value used by scene.getMeshByName() to do a lookup.
  109847. * @param generator The mesh to generate a trail.
  109848. * @param scene The scene to add this mesh to.
  109849. * @param diameter Diameter of trailing mesh. Default is 1.
  109850. * @param length Length of trailing mesh. Default is 60.
  109851. * @param autoStart Automatically start trailing mesh. Default true.
  109852. */
  109853. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109854. /**
  109855. * "TrailMesh"
  109856. * @returns "TrailMesh"
  109857. */
  109858. getClassName(): string;
  109859. private _createMesh;
  109860. /**
  109861. * Start trailing mesh.
  109862. */
  109863. start(): void;
  109864. /**
  109865. * Stop trailing mesh.
  109866. */
  109867. stop(): void;
  109868. /**
  109869. * Update trailing mesh geometry.
  109870. */
  109871. update(): void;
  109872. /**
  109873. * Returns a new TrailMesh object.
  109874. * @param name is a string, the name given to the new mesh
  109875. * @param newGenerator use new generator object for cloned trail mesh
  109876. * @returns a new mesh
  109877. */
  109878. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109879. /**
  109880. * Serializes this trail mesh
  109881. * @param serializationObject object to write serialization to
  109882. */
  109883. serialize(serializationObject: any): void;
  109884. /**
  109885. * Parses a serialized trail mesh
  109886. * @param parsedMesh the serialized mesh
  109887. * @param scene the scene to create the trail mesh in
  109888. * @returns the created trail mesh
  109889. */
  109890. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109891. }
  109892. }
  109893. declare module BABYLON {
  109894. /**
  109895. * Class containing static functions to help procedurally build meshes
  109896. */
  109897. export class TorusKnotBuilder {
  109898. /**
  109899. * Creates a torus knot mesh
  109900. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109901. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109902. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109903. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109907. * @param name defines the name of the mesh
  109908. * @param options defines the options used to create the mesh
  109909. * @param scene defines the hosting scene
  109910. * @returns the torus knot mesh
  109911. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109912. */
  109913. static CreateTorusKnot(name: string, options: {
  109914. radius?: number;
  109915. tube?: number;
  109916. radialSegments?: number;
  109917. tubularSegments?: number;
  109918. p?: number;
  109919. q?: number;
  109920. updatable?: boolean;
  109921. sideOrientation?: number;
  109922. frontUVs?: Vector4;
  109923. backUVs?: Vector4;
  109924. }, scene: any): Mesh;
  109925. }
  109926. }
  109927. declare module BABYLON {
  109928. /**
  109929. * Polygon
  109930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109931. */
  109932. export class Polygon {
  109933. /**
  109934. * Creates a rectangle
  109935. * @param xmin bottom X coord
  109936. * @param ymin bottom Y coord
  109937. * @param xmax top X coord
  109938. * @param ymax top Y coord
  109939. * @returns points that make the resulting rectation
  109940. */
  109941. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109942. /**
  109943. * Creates a circle
  109944. * @param radius radius of circle
  109945. * @param cx scale in x
  109946. * @param cy scale in y
  109947. * @param numberOfSides number of sides that make up the circle
  109948. * @returns points that make the resulting circle
  109949. */
  109950. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109951. /**
  109952. * Creates a polygon from input string
  109953. * @param input Input polygon data
  109954. * @returns the parsed points
  109955. */
  109956. static Parse(input: string): Vector2[];
  109957. /**
  109958. * Starts building a polygon from x and y coordinates
  109959. * @param x x coordinate
  109960. * @param y y coordinate
  109961. * @returns the started path2
  109962. */
  109963. static StartingAt(x: number, y: number): Path2;
  109964. }
  109965. /**
  109966. * Builds a polygon
  109967. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109968. */
  109969. export class PolygonMeshBuilder {
  109970. private _points;
  109971. private _outlinepoints;
  109972. private _holes;
  109973. private _name;
  109974. private _scene;
  109975. private _epoints;
  109976. private _eholes;
  109977. private _addToepoint;
  109978. /**
  109979. * Babylon reference to the earcut plugin.
  109980. */
  109981. bjsEarcut: any;
  109982. /**
  109983. * Creates a PolygonMeshBuilder
  109984. * @param name name of the builder
  109985. * @param contours Path of the polygon
  109986. * @param scene scene to add to when creating the mesh
  109987. * @param earcutInjection can be used to inject your own earcut reference
  109988. */
  109989. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109990. /**
  109991. * Adds a whole within the polygon
  109992. * @param hole Array of points defining the hole
  109993. * @returns this
  109994. */
  109995. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109996. /**
  109997. * Creates the polygon
  109998. * @param updatable If the mesh should be updatable
  109999. * @param depth The depth of the mesh created
  110000. * @returns the created mesh
  110001. */
  110002. build(updatable?: boolean, depth?: number): Mesh;
  110003. /**
  110004. * Creates the polygon
  110005. * @param depth The depth of the mesh created
  110006. * @returns the created VertexData
  110007. */
  110008. buildVertexData(depth?: number): VertexData;
  110009. /**
  110010. * Adds a side to the polygon
  110011. * @param positions points that make the polygon
  110012. * @param normals normals of the polygon
  110013. * @param uvs uvs of the polygon
  110014. * @param indices indices of the polygon
  110015. * @param bounds bounds of the polygon
  110016. * @param points points of the polygon
  110017. * @param depth depth of the polygon
  110018. * @param flip flip of the polygon
  110019. */
  110020. private addSide;
  110021. }
  110022. }
  110023. declare module BABYLON {
  110024. /**
  110025. * Class containing static functions to help procedurally build meshes
  110026. */
  110027. export class PolygonBuilder {
  110028. /**
  110029. * Creates a polygon mesh
  110030. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110031. * * 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
  110032. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110035. * * Remember you can only change the shape positions, not their number when updating a polygon
  110036. * @param name defines the name of the mesh
  110037. * @param options defines the options used to create the mesh
  110038. * @param scene defines the hosting scene
  110039. * @param earcutInjection can be used to inject your own earcut reference
  110040. * @returns the polygon mesh
  110041. */
  110042. static CreatePolygon(name: string, options: {
  110043. shape: Vector3[];
  110044. holes?: Vector3[][];
  110045. depth?: number;
  110046. faceUV?: Vector4[];
  110047. faceColors?: Color4[];
  110048. updatable?: boolean;
  110049. sideOrientation?: number;
  110050. frontUVs?: Vector4;
  110051. backUVs?: Vector4;
  110052. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110053. /**
  110054. * Creates an extruded polygon mesh, with depth in the Y direction.
  110055. * * 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)
  110056. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110057. * @param name defines the name of the mesh
  110058. * @param options defines the options used to create the mesh
  110059. * @param scene defines the hosting scene
  110060. * @param earcutInjection can be used to inject your own earcut reference
  110061. * @returns the polygon mesh
  110062. */
  110063. static ExtrudePolygon(name: string, options: {
  110064. shape: Vector3[];
  110065. holes?: Vector3[][];
  110066. depth?: number;
  110067. faceUV?: Vector4[];
  110068. faceColors?: Color4[];
  110069. updatable?: boolean;
  110070. sideOrientation?: number;
  110071. frontUVs?: Vector4;
  110072. backUVs?: Vector4;
  110073. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110074. }
  110075. }
  110076. declare module BABYLON {
  110077. /**
  110078. * Class containing static functions to help procedurally build meshes
  110079. */
  110080. export class LatheBuilder {
  110081. /**
  110082. * Creates lathe mesh.
  110083. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110084. * * 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
  110085. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110086. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110087. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110088. * * 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
  110089. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110090. * * 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
  110091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110095. * @param name defines the name of the mesh
  110096. * @param options defines the options used to create the mesh
  110097. * @param scene defines the hosting scene
  110098. * @returns the lathe mesh
  110099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110100. */
  110101. static CreateLathe(name: string, options: {
  110102. shape: Vector3[];
  110103. radius?: number;
  110104. tessellation?: number;
  110105. clip?: number;
  110106. arc?: number;
  110107. closed?: boolean;
  110108. updatable?: boolean;
  110109. sideOrientation?: number;
  110110. frontUVs?: Vector4;
  110111. backUVs?: Vector4;
  110112. cap?: number;
  110113. invertUV?: boolean;
  110114. }, scene?: Nullable<Scene>): Mesh;
  110115. }
  110116. }
  110117. declare module BABYLON {
  110118. /**
  110119. * Class containing static functions to help procedurally build meshes
  110120. */
  110121. export class TubeBuilder {
  110122. /**
  110123. * Creates a tube mesh.
  110124. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110125. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110126. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110127. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110128. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110129. * * 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)
  110130. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110131. * * 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
  110132. * * 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
  110133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110137. * @param name defines the name of the mesh
  110138. * @param options defines the options used to create the mesh
  110139. * @param scene defines the hosting scene
  110140. * @returns the tube mesh
  110141. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110142. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110143. */
  110144. static CreateTube(name: string, options: {
  110145. path: Vector3[];
  110146. radius?: number;
  110147. tessellation?: number;
  110148. radiusFunction?: {
  110149. (i: number, distance: number): number;
  110150. };
  110151. cap?: number;
  110152. arc?: number;
  110153. updatable?: boolean;
  110154. sideOrientation?: number;
  110155. frontUVs?: Vector4;
  110156. backUVs?: Vector4;
  110157. instance?: Mesh;
  110158. invertUV?: boolean;
  110159. }, scene?: Nullable<Scene>): Mesh;
  110160. }
  110161. }
  110162. declare module BABYLON {
  110163. /**
  110164. * Class containing static functions to help procedurally build meshes
  110165. */
  110166. export class IcoSphereBuilder {
  110167. /**
  110168. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110169. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110170. * * 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`)
  110171. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110172. * * 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
  110173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110176. * @param name defines the name of the mesh
  110177. * @param options defines the options used to create the mesh
  110178. * @param scene defines the hosting scene
  110179. * @returns the icosahedron mesh
  110180. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110181. */
  110182. static CreateIcoSphere(name: string, options: {
  110183. radius?: number;
  110184. radiusX?: number;
  110185. radiusY?: number;
  110186. radiusZ?: number;
  110187. flat?: boolean;
  110188. subdivisions?: number;
  110189. sideOrientation?: number;
  110190. frontUVs?: Vector4;
  110191. backUVs?: Vector4;
  110192. updatable?: boolean;
  110193. }, scene?: Nullable<Scene>): Mesh;
  110194. }
  110195. }
  110196. declare module BABYLON {
  110197. /**
  110198. * Class containing static functions to help procedurally build meshes
  110199. */
  110200. export class DecalBuilder {
  110201. /**
  110202. * Creates a decal mesh.
  110203. * 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
  110204. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110205. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110206. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110207. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110208. * @param name defines the name of the mesh
  110209. * @param sourceMesh defines the mesh where the decal must be applied
  110210. * @param options defines the options used to create the mesh
  110211. * @param scene defines the hosting scene
  110212. * @returns the decal mesh
  110213. * @see https://doc.babylonjs.com/how_to/decals
  110214. */
  110215. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110216. position?: Vector3;
  110217. normal?: Vector3;
  110218. size?: Vector3;
  110219. angle?: number;
  110220. }): Mesh;
  110221. }
  110222. }
  110223. declare module BABYLON {
  110224. /**
  110225. * Class containing static functions to help procedurally build meshes
  110226. */
  110227. export class MeshBuilder {
  110228. /**
  110229. * Creates a box mesh
  110230. * * The parameter `size` sets the size (float) of each box side (default 1)
  110231. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110232. * * 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)
  110233. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110237. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110238. * @param name defines the name of the mesh
  110239. * @param options defines the options used to create the mesh
  110240. * @param scene defines the hosting scene
  110241. * @returns the box mesh
  110242. */
  110243. static CreateBox(name: string, options: {
  110244. size?: number;
  110245. width?: number;
  110246. height?: number;
  110247. depth?: number;
  110248. faceUV?: Vector4[];
  110249. faceColors?: Color4[];
  110250. sideOrientation?: number;
  110251. frontUVs?: Vector4;
  110252. backUVs?: Vector4;
  110253. updatable?: boolean;
  110254. }, scene?: Nullable<Scene>): Mesh;
  110255. /**
  110256. * Creates a sphere mesh
  110257. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110258. * * 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`)
  110259. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110260. * * 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
  110261. * * 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)
  110262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the sphere mesh
  110269. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110270. */
  110271. static CreateSphere(name: string, options: {
  110272. segments?: number;
  110273. diameter?: number;
  110274. diameterX?: number;
  110275. diameterY?: number;
  110276. diameterZ?: number;
  110277. arc?: number;
  110278. slice?: number;
  110279. sideOrientation?: number;
  110280. frontUVs?: Vector4;
  110281. backUVs?: Vector4;
  110282. updatable?: boolean;
  110283. }, scene?: Nullable<Scene>): Mesh;
  110284. /**
  110285. * Creates a plane polygonal mesh. By default, this is a disc
  110286. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110287. * * 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
  110288. * * 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
  110289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110292. * @param name defines the name of the mesh
  110293. * @param options defines the options used to create the mesh
  110294. * @param scene defines the hosting scene
  110295. * @returns the plane polygonal mesh
  110296. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110297. */
  110298. static CreateDisc(name: string, options: {
  110299. radius?: number;
  110300. tessellation?: number;
  110301. arc?: number;
  110302. updatable?: boolean;
  110303. sideOrientation?: number;
  110304. frontUVs?: Vector4;
  110305. backUVs?: Vector4;
  110306. }, scene?: Nullable<Scene>): Mesh;
  110307. /**
  110308. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110309. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110310. * * 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`)
  110311. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110312. * * 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
  110313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110316. * @param name defines the name of the mesh
  110317. * @param options defines the options used to create the mesh
  110318. * @param scene defines the hosting scene
  110319. * @returns the icosahedron mesh
  110320. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110321. */
  110322. static CreateIcoSphere(name: string, options: {
  110323. radius?: number;
  110324. radiusX?: number;
  110325. radiusY?: number;
  110326. radiusZ?: number;
  110327. flat?: boolean;
  110328. subdivisions?: number;
  110329. sideOrientation?: number;
  110330. frontUVs?: Vector4;
  110331. backUVs?: Vector4;
  110332. updatable?: boolean;
  110333. }, scene?: Nullable<Scene>): Mesh;
  110334. /**
  110335. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110336. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110337. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110338. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110339. * * 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
  110340. * * 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
  110341. * * 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
  110342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110345. * * 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
  110346. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110347. * * 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
  110348. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110350. * @param name defines the name of the mesh
  110351. * @param options defines the options used to create the mesh
  110352. * @param scene defines the hosting scene
  110353. * @returns the ribbon mesh
  110354. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110356. */
  110357. static CreateRibbon(name: string, options: {
  110358. pathArray: Vector3[][];
  110359. closeArray?: boolean;
  110360. closePath?: boolean;
  110361. offset?: number;
  110362. updatable?: boolean;
  110363. sideOrientation?: number;
  110364. frontUVs?: Vector4;
  110365. backUVs?: Vector4;
  110366. instance?: Mesh;
  110367. invertUV?: boolean;
  110368. uvs?: Vector2[];
  110369. colors?: Color4[];
  110370. }, scene?: Nullable<Scene>): Mesh;
  110371. /**
  110372. * Creates a cylinder or a cone mesh
  110373. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110374. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110375. * * 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.
  110376. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110377. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110378. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110379. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110380. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110381. * * 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).
  110382. * * 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
  110383. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110384. * * 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
  110385. * * 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.
  110386. * * If `enclose` is false, a ring surface is one element.
  110387. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110388. * * 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
  110389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110392. * @param name defines the name of the mesh
  110393. * @param options defines the options used to create the mesh
  110394. * @param scene defines the hosting scene
  110395. * @returns the cylinder mesh
  110396. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110397. */
  110398. static CreateCylinder(name: string, options: {
  110399. height?: number;
  110400. diameterTop?: number;
  110401. diameterBottom?: number;
  110402. diameter?: number;
  110403. tessellation?: number;
  110404. subdivisions?: number;
  110405. arc?: number;
  110406. faceColors?: Color4[];
  110407. faceUV?: Vector4[];
  110408. updatable?: boolean;
  110409. hasRings?: boolean;
  110410. enclose?: boolean;
  110411. sideOrientation?: number;
  110412. frontUVs?: Vector4;
  110413. backUVs?: Vector4;
  110414. }, scene?: Nullable<Scene>): Mesh;
  110415. /**
  110416. * Creates a torus mesh
  110417. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110418. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110419. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110423. * @param name defines the name of the mesh
  110424. * @param options defines the options used to create the mesh
  110425. * @param scene defines the hosting scene
  110426. * @returns the torus mesh
  110427. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110428. */
  110429. static CreateTorus(name: string, options: {
  110430. diameter?: number;
  110431. thickness?: number;
  110432. tessellation?: number;
  110433. updatable?: boolean;
  110434. sideOrientation?: number;
  110435. frontUVs?: Vector4;
  110436. backUVs?: Vector4;
  110437. }, scene?: Nullable<Scene>): Mesh;
  110438. /**
  110439. * Creates a torus knot mesh
  110440. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110441. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110442. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110443. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110447. * @param name defines the name of the mesh
  110448. * @param options defines the options used to create the mesh
  110449. * @param scene defines the hosting scene
  110450. * @returns the torus knot mesh
  110451. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110452. */
  110453. static CreateTorusKnot(name: string, options: {
  110454. radius?: number;
  110455. tube?: number;
  110456. radialSegments?: number;
  110457. tubularSegments?: number;
  110458. p?: number;
  110459. q?: number;
  110460. updatable?: boolean;
  110461. sideOrientation?: number;
  110462. frontUVs?: Vector4;
  110463. backUVs?: Vector4;
  110464. }, scene?: Nullable<Scene>): Mesh;
  110465. /**
  110466. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110467. * * 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
  110468. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110469. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110470. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110471. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110472. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110473. * * 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
  110474. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110477. * @param name defines the name of the new line system
  110478. * @param options defines the options used to create the line system
  110479. * @param scene defines the hosting scene
  110480. * @returns a new line system mesh
  110481. */
  110482. static CreateLineSystem(name: string, options: {
  110483. lines: Vector3[][];
  110484. updatable?: boolean;
  110485. instance?: Nullable<LinesMesh>;
  110486. colors?: Nullable<Color4[][]>;
  110487. useVertexAlpha?: boolean;
  110488. }, scene: Nullable<Scene>): LinesMesh;
  110489. /**
  110490. * Creates a line mesh
  110491. * 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
  110492. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110493. * * The parameter `points` is an array successive Vector3
  110494. * * 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
  110495. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110496. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110497. * * When updating an instance, remember that only point positions can change, not the number of points
  110498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110500. * @param name defines the name of the new line system
  110501. * @param options defines the options used to create the line system
  110502. * @param scene defines the hosting scene
  110503. * @returns a new line mesh
  110504. */
  110505. static CreateLines(name: string, options: {
  110506. points: Vector3[];
  110507. updatable?: boolean;
  110508. instance?: Nullable<LinesMesh>;
  110509. colors?: Color4[];
  110510. useVertexAlpha?: boolean;
  110511. }, scene?: Nullable<Scene>): LinesMesh;
  110512. /**
  110513. * Creates a dashed line mesh
  110514. * * 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
  110515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110516. * * The parameter `points` is an array successive Vector3
  110517. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110518. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110519. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110520. * * 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
  110521. * * When updating an instance, remember that only point positions can change, not the number of points
  110522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110523. * @param name defines the name of the mesh
  110524. * @param options defines the options used to create the mesh
  110525. * @param scene defines the hosting scene
  110526. * @returns the dashed line mesh
  110527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110528. */
  110529. static CreateDashedLines(name: string, options: {
  110530. points: Vector3[];
  110531. dashSize?: number;
  110532. gapSize?: number;
  110533. dashNb?: number;
  110534. updatable?: boolean;
  110535. instance?: LinesMesh;
  110536. }, scene?: Nullable<Scene>): LinesMesh;
  110537. /**
  110538. * 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.
  110539. * * 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.
  110540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110541. * * 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.
  110542. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110543. * * 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
  110544. * * 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
  110545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110550. * @param name defines the name of the mesh
  110551. * @param options defines the options used to create the mesh
  110552. * @param scene defines the hosting scene
  110553. * @returns the extruded shape mesh
  110554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110556. */
  110557. static ExtrudeShape(name: string, options: {
  110558. shape: Vector3[];
  110559. path: Vector3[];
  110560. scale?: number;
  110561. rotation?: number;
  110562. cap?: number;
  110563. updatable?: boolean;
  110564. sideOrientation?: number;
  110565. frontUVs?: Vector4;
  110566. backUVs?: Vector4;
  110567. instance?: Mesh;
  110568. invertUV?: boolean;
  110569. }, scene?: Nullable<Scene>): Mesh;
  110570. /**
  110571. * Creates an custom extruded shape mesh.
  110572. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110573. * * 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.
  110574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110575. * * 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
  110576. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110577. * * 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
  110578. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110579. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110580. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110581. * * 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
  110582. * * 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
  110583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110588. * @param name defines the name of the mesh
  110589. * @param options defines the options used to create the mesh
  110590. * @param scene defines the hosting scene
  110591. * @returns the custom extruded shape mesh
  110592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110595. */
  110596. static ExtrudeShapeCustom(name: string, options: {
  110597. shape: Vector3[];
  110598. path: Vector3[];
  110599. scaleFunction?: any;
  110600. rotationFunction?: any;
  110601. ribbonCloseArray?: boolean;
  110602. ribbonClosePath?: boolean;
  110603. cap?: number;
  110604. updatable?: boolean;
  110605. sideOrientation?: number;
  110606. frontUVs?: Vector4;
  110607. backUVs?: Vector4;
  110608. instance?: Mesh;
  110609. invertUV?: boolean;
  110610. }, scene?: Nullable<Scene>): Mesh;
  110611. /**
  110612. * Creates lathe mesh.
  110613. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110614. * * 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
  110615. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110616. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110617. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110618. * * 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
  110619. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110620. * * 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
  110621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110625. * @param name defines the name of the mesh
  110626. * @param options defines the options used to create the mesh
  110627. * @param scene defines the hosting scene
  110628. * @returns the lathe mesh
  110629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110630. */
  110631. static CreateLathe(name: string, options: {
  110632. shape: Vector3[];
  110633. radius?: number;
  110634. tessellation?: number;
  110635. clip?: number;
  110636. arc?: number;
  110637. closed?: boolean;
  110638. updatable?: boolean;
  110639. sideOrientation?: number;
  110640. frontUVs?: Vector4;
  110641. backUVs?: Vector4;
  110642. cap?: number;
  110643. invertUV?: boolean;
  110644. }, scene?: Nullable<Scene>): Mesh;
  110645. /**
  110646. * Creates a plane mesh
  110647. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110648. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110649. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110653. * @param name defines the name of the mesh
  110654. * @param options defines the options used to create the mesh
  110655. * @param scene defines the hosting scene
  110656. * @returns the plane mesh
  110657. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110658. */
  110659. static CreatePlane(name: string, options: {
  110660. size?: number;
  110661. width?: number;
  110662. height?: number;
  110663. sideOrientation?: number;
  110664. frontUVs?: Vector4;
  110665. backUVs?: Vector4;
  110666. updatable?: boolean;
  110667. sourcePlane?: Plane;
  110668. }, scene?: Nullable<Scene>): Mesh;
  110669. /**
  110670. * Creates a ground mesh
  110671. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110672. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110674. * @param name defines the name of the mesh
  110675. * @param options defines the options used to create the mesh
  110676. * @param scene defines the hosting scene
  110677. * @returns the ground mesh
  110678. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110679. */
  110680. static CreateGround(name: string, options: {
  110681. width?: number;
  110682. height?: number;
  110683. subdivisions?: number;
  110684. subdivisionsX?: number;
  110685. subdivisionsY?: number;
  110686. updatable?: boolean;
  110687. }, scene?: Nullable<Scene>): Mesh;
  110688. /**
  110689. * Creates a tiled ground mesh
  110690. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110691. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110692. * * 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
  110693. * * 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
  110694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110695. * @param name defines the name of the mesh
  110696. * @param options defines the options used to create the mesh
  110697. * @param scene defines the hosting scene
  110698. * @returns the tiled ground mesh
  110699. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110700. */
  110701. static CreateTiledGround(name: string, options: {
  110702. xmin: number;
  110703. zmin: number;
  110704. xmax: number;
  110705. zmax: number;
  110706. subdivisions?: {
  110707. w: number;
  110708. h: number;
  110709. };
  110710. precision?: {
  110711. w: number;
  110712. h: number;
  110713. };
  110714. updatable?: boolean;
  110715. }, scene?: Nullable<Scene>): Mesh;
  110716. /**
  110717. * Creates a ground mesh from a height map
  110718. * * The parameter `url` sets the URL of the height map image resource.
  110719. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110720. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110721. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110722. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110723. * * 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.
  110724. * * 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).
  110725. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110727. * @param name defines the name of the mesh
  110728. * @param url defines the url to the height map
  110729. * @param options defines the options used to create the mesh
  110730. * @param scene defines the hosting scene
  110731. * @returns the ground mesh
  110732. * @see https://doc.babylonjs.com/babylon101/height_map
  110733. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110734. */
  110735. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110736. width?: number;
  110737. height?: number;
  110738. subdivisions?: number;
  110739. minHeight?: number;
  110740. maxHeight?: number;
  110741. colorFilter?: Color3;
  110742. alphaFilter?: number;
  110743. updatable?: boolean;
  110744. onReady?: (mesh: GroundMesh) => void;
  110745. }, scene?: Nullable<Scene>): GroundMesh;
  110746. /**
  110747. * Creates a polygon mesh
  110748. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110749. * * 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
  110750. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110753. * * Remember you can only change the shape positions, not their number when updating a polygon
  110754. * @param name defines the name of the mesh
  110755. * @param options defines the options used to create the mesh
  110756. * @param scene defines the hosting scene
  110757. * @param earcutInjection can be used to inject your own earcut reference
  110758. * @returns the polygon mesh
  110759. */
  110760. static CreatePolygon(name: string, options: {
  110761. shape: Vector3[];
  110762. holes?: Vector3[][];
  110763. depth?: number;
  110764. faceUV?: Vector4[];
  110765. faceColors?: Color4[];
  110766. updatable?: boolean;
  110767. sideOrientation?: number;
  110768. frontUVs?: Vector4;
  110769. backUVs?: Vector4;
  110770. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110771. /**
  110772. * Creates an extruded polygon mesh, with depth in the Y direction.
  110773. * * 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)
  110774. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110775. * @param name defines the name of the mesh
  110776. * @param options defines the options used to create the mesh
  110777. * @param scene defines the hosting scene
  110778. * @param earcutInjection can be used to inject your own earcut reference
  110779. * @returns the polygon mesh
  110780. */
  110781. static ExtrudePolygon(name: string, options: {
  110782. shape: Vector3[];
  110783. holes?: Vector3[][];
  110784. depth?: number;
  110785. faceUV?: Vector4[];
  110786. faceColors?: Color4[];
  110787. updatable?: boolean;
  110788. sideOrientation?: number;
  110789. frontUVs?: Vector4;
  110790. backUVs?: Vector4;
  110791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110792. /**
  110793. * Creates a tube mesh.
  110794. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110795. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110796. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110797. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110798. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110799. * * 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)
  110800. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110801. * * 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
  110802. * * 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
  110803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110805. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110807. * @param name defines the name of the mesh
  110808. * @param options defines the options used to create the mesh
  110809. * @param scene defines the hosting scene
  110810. * @returns the tube mesh
  110811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110812. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110813. */
  110814. static CreateTube(name: string, options: {
  110815. path: Vector3[];
  110816. radius?: number;
  110817. tessellation?: number;
  110818. radiusFunction?: {
  110819. (i: number, distance: number): number;
  110820. };
  110821. cap?: number;
  110822. arc?: number;
  110823. updatable?: boolean;
  110824. sideOrientation?: number;
  110825. frontUVs?: Vector4;
  110826. backUVs?: Vector4;
  110827. instance?: Mesh;
  110828. invertUV?: boolean;
  110829. }, scene?: Nullable<Scene>): Mesh;
  110830. /**
  110831. * Creates a polyhedron mesh
  110832. * * 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
  110833. * * The parameter `size` (positive float, default 1) sets the polygon size
  110834. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110835. * * 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`
  110836. * * 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
  110837. * * 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)`)
  110838. * * 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
  110839. * * 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
  110840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110843. * @param name defines the name of the mesh
  110844. * @param options defines the options used to create the mesh
  110845. * @param scene defines the hosting scene
  110846. * @returns the polyhedron mesh
  110847. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110848. */
  110849. static CreatePolyhedron(name: string, options: {
  110850. type?: number;
  110851. size?: number;
  110852. sizeX?: number;
  110853. sizeY?: number;
  110854. sizeZ?: number;
  110855. custom?: any;
  110856. faceUV?: Vector4[];
  110857. faceColors?: Color4[];
  110858. flat?: boolean;
  110859. updatable?: boolean;
  110860. sideOrientation?: number;
  110861. frontUVs?: Vector4;
  110862. backUVs?: Vector4;
  110863. }, scene?: Nullable<Scene>): Mesh;
  110864. /**
  110865. * Creates a decal mesh.
  110866. * 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
  110867. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110868. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110869. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110870. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110871. * @param name defines the name of the mesh
  110872. * @param sourceMesh defines the mesh where the decal must be applied
  110873. * @param options defines the options used to create the mesh
  110874. * @param scene defines the hosting scene
  110875. * @returns the decal mesh
  110876. * @see https://doc.babylonjs.com/how_to/decals
  110877. */
  110878. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110879. position?: Vector3;
  110880. normal?: Vector3;
  110881. size?: Vector3;
  110882. angle?: number;
  110883. }): Mesh;
  110884. }
  110885. }
  110886. declare module BABYLON {
  110887. /**
  110888. * A simplifier interface for future simplification implementations
  110889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110890. */
  110891. export interface ISimplifier {
  110892. /**
  110893. * Simplification of a given mesh according to the given settings.
  110894. * Since this requires computation, it is assumed that the function runs async.
  110895. * @param settings The settings of the simplification, including quality and distance
  110896. * @param successCallback A callback that will be called after the mesh was simplified.
  110897. * @param errorCallback in case of an error, this callback will be called. optional.
  110898. */
  110899. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110900. }
  110901. /**
  110902. * Expected simplification settings.
  110903. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110905. */
  110906. export interface ISimplificationSettings {
  110907. /**
  110908. * Gets or sets the expected quality
  110909. */
  110910. quality: number;
  110911. /**
  110912. * Gets or sets the distance when this optimized version should be used
  110913. */
  110914. distance: number;
  110915. /**
  110916. * Gets an already optimized mesh
  110917. */
  110918. optimizeMesh?: boolean;
  110919. }
  110920. /**
  110921. * Class used to specify simplification options
  110922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110923. */
  110924. export class SimplificationSettings implements ISimplificationSettings {
  110925. /** expected quality */
  110926. quality: number;
  110927. /** distance when this optimized version should be used */
  110928. distance: number;
  110929. /** already optimized mesh */
  110930. optimizeMesh?: boolean | undefined;
  110931. /**
  110932. * Creates a SimplificationSettings
  110933. * @param quality expected quality
  110934. * @param distance distance when this optimized version should be used
  110935. * @param optimizeMesh already optimized mesh
  110936. */
  110937. constructor(
  110938. /** expected quality */
  110939. quality: number,
  110940. /** distance when this optimized version should be used */
  110941. distance: number,
  110942. /** already optimized mesh */
  110943. optimizeMesh?: boolean | undefined);
  110944. }
  110945. /**
  110946. * Interface used to define a simplification task
  110947. */
  110948. export interface ISimplificationTask {
  110949. /**
  110950. * Array of settings
  110951. */
  110952. settings: Array<ISimplificationSettings>;
  110953. /**
  110954. * Simplification type
  110955. */
  110956. simplificationType: SimplificationType;
  110957. /**
  110958. * Mesh to simplify
  110959. */
  110960. mesh: Mesh;
  110961. /**
  110962. * Callback called on success
  110963. */
  110964. successCallback?: () => void;
  110965. /**
  110966. * Defines if parallel processing can be used
  110967. */
  110968. parallelProcessing: boolean;
  110969. }
  110970. /**
  110971. * Queue used to order the simplification tasks
  110972. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110973. */
  110974. export class SimplificationQueue {
  110975. private _simplificationArray;
  110976. /**
  110977. * Gets a boolean indicating that the process is still running
  110978. */
  110979. running: boolean;
  110980. /**
  110981. * Creates a new queue
  110982. */
  110983. constructor();
  110984. /**
  110985. * Adds a new simplification task
  110986. * @param task defines a task to add
  110987. */
  110988. addTask(task: ISimplificationTask): void;
  110989. /**
  110990. * Execute next task
  110991. */
  110992. executeNext(): void;
  110993. /**
  110994. * Execute a simplification task
  110995. * @param task defines the task to run
  110996. */
  110997. runSimplification(task: ISimplificationTask): void;
  110998. private getSimplifier;
  110999. }
  111000. /**
  111001. * The implemented types of simplification
  111002. * At the moment only Quadratic Error Decimation is implemented
  111003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111004. */
  111005. export enum SimplificationType {
  111006. /** Quadratic error decimation */
  111007. QUADRATIC = 0
  111008. }
  111009. }
  111010. declare module BABYLON {
  111011. interface Scene {
  111012. /** @hidden (Backing field) */
  111013. _simplificationQueue: SimplificationQueue;
  111014. /**
  111015. * Gets or sets the simplification queue attached to the scene
  111016. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111017. */
  111018. simplificationQueue: SimplificationQueue;
  111019. }
  111020. interface Mesh {
  111021. /**
  111022. * Simplify the mesh according to the given array of settings.
  111023. * Function will return immediately and will simplify async
  111024. * @param settings a collection of simplification settings
  111025. * @param parallelProcessing should all levels calculate parallel or one after the other
  111026. * @param simplificationType the type of simplification to run
  111027. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111028. * @returns the current mesh
  111029. */
  111030. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111031. }
  111032. /**
  111033. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111034. * created in a scene
  111035. */
  111036. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111037. /**
  111038. * The component name helpfull to identify the component in the list of scene components.
  111039. */
  111040. readonly name: string;
  111041. /**
  111042. * The scene the component belongs to.
  111043. */
  111044. scene: Scene;
  111045. /**
  111046. * Creates a new instance of the component for the given scene
  111047. * @param scene Defines the scene to register the component in
  111048. */
  111049. constructor(scene: Scene);
  111050. /**
  111051. * Registers the component in a given scene
  111052. */
  111053. register(): void;
  111054. /**
  111055. * Rebuilds the elements related to this component in case of
  111056. * context lost for instance.
  111057. */
  111058. rebuild(): void;
  111059. /**
  111060. * Disposes the component and the associated ressources
  111061. */
  111062. dispose(): void;
  111063. private _beforeCameraUpdate;
  111064. }
  111065. }
  111066. declare module BABYLON {
  111067. /**
  111068. * Class used to enable access to IndexedDB
  111069. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111070. */
  111071. export class Database implements IOfflineProvider {
  111072. private _callbackManifestChecked;
  111073. private _currentSceneUrl;
  111074. private _db;
  111075. private _enableSceneOffline;
  111076. private _enableTexturesOffline;
  111077. private _manifestVersionFound;
  111078. private _mustUpdateRessources;
  111079. private _hasReachedQuota;
  111080. private _isSupported;
  111081. private _idbFactory;
  111082. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111083. private static IsUASupportingBlobStorage;
  111084. /**
  111085. * Gets a boolean indicating if Database storate is enabled (off by default)
  111086. */
  111087. static IDBStorageEnabled: boolean;
  111088. /**
  111089. * Gets a boolean indicating if scene must be saved in the database
  111090. */
  111091. readonly enableSceneOffline: boolean;
  111092. /**
  111093. * Gets a boolean indicating if textures must be saved in the database
  111094. */
  111095. readonly enableTexturesOffline: boolean;
  111096. /**
  111097. * Creates a new Database
  111098. * @param urlToScene defines the url to load the scene
  111099. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111100. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111101. */
  111102. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111103. private static _ParseURL;
  111104. private static _ReturnFullUrlLocation;
  111105. private _checkManifestFile;
  111106. /**
  111107. * Open the database and make it available
  111108. * @param successCallback defines the callback to call on success
  111109. * @param errorCallback defines the callback to call on error
  111110. */
  111111. open(successCallback: () => void, errorCallback: () => void): void;
  111112. /**
  111113. * Loads an image from the database
  111114. * @param url defines the url to load from
  111115. * @param image defines the target DOM image
  111116. */
  111117. loadImage(url: string, image: HTMLImageElement): void;
  111118. private _loadImageFromDBAsync;
  111119. private _saveImageIntoDBAsync;
  111120. private _checkVersionFromDB;
  111121. private _loadVersionFromDBAsync;
  111122. private _saveVersionIntoDBAsync;
  111123. /**
  111124. * Loads a file from database
  111125. * @param url defines the URL to load from
  111126. * @param sceneLoaded defines a callback to call on success
  111127. * @param progressCallBack defines a callback to call when progress changed
  111128. * @param errorCallback defines a callback to call on error
  111129. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111130. */
  111131. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111132. private _loadFileAsync;
  111133. private _saveFileAsync;
  111134. /**
  111135. * Validates if xhr data is correct
  111136. * @param xhr defines the request to validate
  111137. * @param dataType defines the expected data type
  111138. * @returns true if data is correct
  111139. */
  111140. private static _ValidateXHRData;
  111141. }
  111142. }
  111143. declare module BABYLON {
  111144. /** @hidden */
  111145. export var gpuUpdateParticlesPixelShader: {
  111146. name: string;
  111147. shader: string;
  111148. };
  111149. }
  111150. declare module BABYLON {
  111151. /** @hidden */
  111152. export var gpuUpdateParticlesVertexShader: {
  111153. name: string;
  111154. shader: string;
  111155. };
  111156. }
  111157. declare module BABYLON {
  111158. /** @hidden */
  111159. export var clipPlaneFragmentDeclaration2: {
  111160. name: string;
  111161. shader: string;
  111162. };
  111163. }
  111164. declare module BABYLON {
  111165. /** @hidden */
  111166. export var gpuRenderParticlesPixelShader: {
  111167. name: string;
  111168. shader: string;
  111169. };
  111170. }
  111171. declare module BABYLON {
  111172. /** @hidden */
  111173. export var clipPlaneVertexDeclaration2: {
  111174. name: string;
  111175. shader: string;
  111176. };
  111177. }
  111178. declare module BABYLON {
  111179. /** @hidden */
  111180. export var gpuRenderParticlesVertexShader: {
  111181. name: string;
  111182. shader: string;
  111183. };
  111184. }
  111185. declare module BABYLON {
  111186. /**
  111187. * This represents a GPU particle system in Babylon
  111188. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111189. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111190. */
  111191. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111192. /**
  111193. * The layer mask we are rendering the particles through.
  111194. */
  111195. layerMask: number;
  111196. private _capacity;
  111197. private _activeCount;
  111198. private _currentActiveCount;
  111199. private _accumulatedCount;
  111200. private _renderEffect;
  111201. private _updateEffect;
  111202. private _buffer0;
  111203. private _buffer1;
  111204. private _spriteBuffer;
  111205. private _updateVAO;
  111206. private _renderVAO;
  111207. private _targetIndex;
  111208. private _sourceBuffer;
  111209. private _targetBuffer;
  111210. private _engine;
  111211. private _currentRenderId;
  111212. private _started;
  111213. private _stopped;
  111214. private _timeDelta;
  111215. private _randomTexture;
  111216. private _randomTexture2;
  111217. private _attributesStrideSize;
  111218. private _updateEffectOptions;
  111219. private _randomTextureSize;
  111220. private _actualFrame;
  111221. private readonly _rawTextureWidth;
  111222. /**
  111223. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111224. */
  111225. static readonly IsSupported: boolean;
  111226. /**
  111227. * An event triggered when the system is disposed.
  111228. */
  111229. onDisposeObservable: Observable<GPUParticleSystem>;
  111230. /**
  111231. * Gets the maximum number of particles active at the same time.
  111232. * @returns The max number of active particles.
  111233. */
  111234. getCapacity(): number;
  111235. /**
  111236. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111237. * to override the particles.
  111238. */
  111239. forceDepthWrite: boolean;
  111240. /**
  111241. * Gets or set the number of active particles
  111242. */
  111243. activeParticleCount: number;
  111244. private _preWarmDone;
  111245. /**
  111246. * Is this system ready to be used/rendered
  111247. * @return true if the system is ready
  111248. */
  111249. isReady(): boolean;
  111250. /**
  111251. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111252. * @returns True if it has been started, otherwise false.
  111253. */
  111254. isStarted(): boolean;
  111255. /**
  111256. * Starts the particle system and begins to emit
  111257. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111258. */
  111259. start(delay?: number): void;
  111260. /**
  111261. * Stops the particle system.
  111262. */
  111263. stop(): void;
  111264. /**
  111265. * Remove all active particles
  111266. */
  111267. reset(): void;
  111268. /**
  111269. * Returns the string "GPUParticleSystem"
  111270. * @returns a string containing the class name
  111271. */
  111272. getClassName(): string;
  111273. private _colorGradientsTexture;
  111274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111275. /**
  111276. * Adds a new color gradient
  111277. * @param gradient defines the gradient to use (between 0 and 1)
  111278. * @param color1 defines the color to affect to the specified gradient
  111279. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111280. * @returns the current particle system
  111281. */
  111282. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111283. /**
  111284. * Remove a specific color gradient
  111285. * @param gradient defines the gradient to remove
  111286. * @returns the current particle system
  111287. */
  111288. removeColorGradient(gradient: number): GPUParticleSystem;
  111289. private _angularSpeedGradientsTexture;
  111290. private _sizeGradientsTexture;
  111291. private _velocityGradientsTexture;
  111292. private _limitVelocityGradientsTexture;
  111293. private _dragGradientsTexture;
  111294. private _addFactorGradient;
  111295. /**
  111296. * Adds a new size gradient
  111297. * @param gradient defines the gradient to use (between 0 and 1)
  111298. * @param factor defines the size factor to affect to the specified gradient
  111299. * @returns the current particle system
  111300. */
  111301. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111302. /**
  111303. * Remove a specific size gradient
  111304. * @param gradient defines the gradient to remove
  111305. * @returns the current particle system
  111306. */
  111307. removeSizeGradient(gradient: number): GPUParticleSystem;
  111308. /**
  111309. * Adds a new angular speed gradient
  111310. * @param gradient defines the gradient to use (between 0 and 1)
  111311. * @param factor defines the angular speed to affect to the specified gradient
  111312. * @returns the current particle system
  111313. */
  111314. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111315. /**
  111316. * Remove a specific angular speed gradient
  111317. * @param gradient defines the gradient to remove
  111318. * @returns the current particle system
  111319. */
  111320. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111321. /**
  111322. * Adds a new velocity gradient
  111323. * @param gradient defines the gradient to use (between 0 and 1)
  111324. * @param factor defines the velocity to affect to the specified gradient
  111325. * @returns the current particle system
  111326. */
  111327. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111328. /**
  111329. * Remove a specific velocity gradient
  111330. * @param gradient defines the gradient to remove
  111331. * @returns the current particle system
  111332. */
  111333. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111334. /**
  111335. * Adds a new limit velocity gradient
  111336. * @param gradient defines the gradient to use (between 0 and 1)
  111337. * @param factor defines the limit velocity value to affect to the specified gradient
  111338. * @returns the current particle system
  111339. */
  111340. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111341. /**
  111342. * Remove a specific limit velocity gradient
  111343. * @param gradient defines the gradient to remove
  111344. * @returns the current particle system
  111345. */
  111346. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111347. /**
  111348. * Adds a new drag gradient
  111349. * @param gradient defines the gradient to use (between 0 and 1)
  111350. * @param factor defines the drag value to affect to the specified gradient
  111351. * @returns the current particle system
  111352. */
  111353. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111354. /**
  111355. * Remove a specific drag gradient
  111356. * @param gradient defines the gradient to remove
  111357. * @returns the current particle system
  111358. */
  111359. removeDragGradient(gradient: number): GPUParticleSystem;
  111360. /**
  111361. * Not supported by GPUParticleSystem
  111362. * @param gradient defines the gradient to use (between 0 and 1)
  111363. * @param factor defines the emit rate value to affect to the specified gradient
  111364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111365. * @returns the current particle system
  111366. */
  111367. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111368. /**
  111369. * Not supported by GPUParticleSystem
  111370. * @param gradient defines the gradient to remove
  111371. * @returns the current particle system
  111372. */
  111373. removeEmitRateGradient(gradient: number): IParticleSystem;
  111374. /**
  111375. * Not supported by GPUParticleSystem
  111376. * @param gradient defines the gradient to use (between 0 and 1)
  111377. * @param factor defines the start size value to affect to the specified gradient
  111378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111379. * @returns the current particle system
  111380. */
  111381. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111382. /**
  111383. * Not supported by GPUParticleSystem
  111384. * @param gradient defines the gradient to remove
  111385. * @returns the current particle system
  111386. */
  111387. removeStartSizeGradient(gradient: number): IParticleSystem;
  111388. /**
  111389. * Not supported by GPUParticleSystem
  111390. * @param gradient defines the gradient to use (between 0 and 1)
  111391. * @param min defines the color remap minimal range
  111392. * @param max defines the color remap maximal range
  111393. * @returns the current particle system
  111394. */
  111395. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111396. /**
  111397. * Not supported by GPUParticleSystem
  111398. * @param gradient defines the gradient to remove
  111399. * @returns the current particle system
  111400. */
  111401. removeColorRemapGradient(): IParticleSystem;
  111402. /**
  111403. * Not supported by GPUParticleSystem
  111404. * @param gradient defines the gradient to use (between 0 and 1)
  111405. * @param min defines the alpha remap minimal range
  111406. * @param max defines the alpha remap maximal range
  111407. * @returns the current particle system
  111408. */
  111409. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111410. /**
  111411. * Not supported by GPUParticleSystem
  111412. * @param gradient defines the gradient to remove
  111413. * @returns the current particle system
  111414. */
  111415. removeAlphaRemapGradient(): IParticleSystem;
  111416. /**
  111417. * Not supported by GPUParticleSystem
  111418. * @param gradient defines the gradient to use (between 0 and 1)
  111419. * @param color defines the color to affect to the specified gradient
  111420. * @returns the current particle system
  111421. */
  111422. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111423. /**
  111424. * Not supported by GPUParticleSystem
  111425. * @param gradient defines the gradient to remove
  111426. * @returns the current particle system
  111427. */
  111428. removeRampGradient(): IParticleSystem;
  111429. /**
  111430. * Not supported by GPUParticleSystem
  111431. * @returns the list of ramp gradients
  111432. */
  111433. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111434. /**
  111435. * Not supported by GPUParticleSystem
  111436. * Gets or sets a boolean indicating that ramp gradients must be used
  111437. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111438. */
  111439. useRampGradients: boolean;
  111440. /**
  111441. * Not supported by GPUParticleSystem
  111442. * @param gradient defines the gradient to use (between 0 and 1)
  111443. * @param factor defines the life time factor to affect to the specified gradient
  111444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111445. * @returns the current particle system
  111446. */
  111447. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111448. /**
  111449. * Not supported by GPUParticleSystem
  111450. * @param gradient defines the gradient to remove
  111451. * @returns the current particle system
  111452. */
  111453. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111454. /**
  111455. * Instantiates a GPU particle system.
  111456. * 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.
  111457. * @param name The name of the particle system
  111458. * @param options The options used to create the system
  111459. * @param scene The scene the particle system belongs to
  111460. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111461. */
  111462. constructor(name: string, options: Partial<{
  111463. capacity: number;
  111464. randomTextureSize: number;
  111465. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111466. protected _reset(): void;
  111467. private _createUpdateVAO;
  111468. private _createRenderVAO;
  111469. private _initialize;
  111470. /** @hidden */
  111471. _recreateUpdateEffect(): void;
  111472. /** @hidden */
  111473. _recreateRenderEffect(): void;
  111474. /**
  111475. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111476. * @param preWarm defines if we are in the pre-warmimg phase
  111477. */
  111478. animate(preWarm?: boolean): void;
  111479. private _createFactorGradientTexture;
  111480. private _createSizeGradientTexture;
  111481. private _createAngularSpeedGradientTexture;
  111482. private _createVelocityGradientTexture;
  111483. private _createLimitVelocityGradientTexture;
  111484. private _createDragGradientTexture;
  111485. private _createColorGradientTexture;
  111486. /**
  111487. * Renders the particle system in its current state
  111488. * @param preWarm defines if the system should only update the particles but not render them
  111489. * @returns the current number of particles
  111490. */
  111491. render(preWarm?: boolean): number;
  111492. /**
  111493. * Rebuilds the particle system
  111494. */
  111495. rebuild(): void;
  111496. private _releaseBuffers;
  111497. private _releaseVAOs;
  111498. /**
  111499. * Disposes the particle system and free the associated resources
  111500. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111501. */
  111502. dispose(disposeTexture?: boolean): void;
  111503. /**
  111504. * Clones the particle system.
  111505. * @param name The name of the cloned object
  111506. * @param newEmitter The new emitter to use
  111507. * @returns the cloned particle system
  111508. */
  111509. clone(name: string, newEmitter: any): GPUParticleSystem;
  111510. /**
  111511. * Serializes the particle system to a JSON object.
  111512. * @returns the JSON object
  111513. */
  111514. serialize(): any;
  111515. /**
  111516. * Parses a JSON object to create a GPU particle system.
  111517. * @param parsedParticleSystem The JSON object to parse
  111518. * @param scene The scene to create the particle system in
  111519. * @param rootUrl The root url to use to load external dependencies like texture
  111520. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111521. * @returns the parsed GPU particle system
  111522. */
  111523. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111524. }
  111525. }
  111526. declare module BABYLON {
  111527. /**
  111528. * Represents a set of particle systems working together to create a specific effect
  111529. */
  111530. export class ParticleSystemSet implements IDisposable {
  111531. private _emitterCreationOptions;
  111532. private _emitterNode;
  111533. /**
  111534. * Gets the particle system list
  111535. */
  111536. systems: IParticleSystem[];
  111537. /**
  111538. * Gets the emitter node used with this set
  111539. */
  111540. readonly emitterNode: Nullable<TransformNode>;
  111541. /**
  111542. * Creates a new emitter mesh as a sphere
  111543. * @param options defines the options used to create the sphere
  111544. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111545. * @param scene defines the hosting scene
  111546. */
  111547. setEmitterAsSphere(options: {
  111548. diameter: number;
  111549. segments: number;
  111550. color: Color3;
  111551. }, renderingGroupId: number, scene: Scene): void;
  111552. /**
  111553. * Starts all particle systems of the set
  111554. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111555. */
  111556. start(emitter?: AbstractMesh): void;
  111557. /**
  111558. * Release all associated resources
  111559. */
  111560. dispose(): void;
  111561. /**
  111562. * Serialize the set into a JSON compatible object
  111563. * @returns a JSON compatible representation of the set
  111564. */
  111565. serialize(): any;
  111566. /**
  111567. * Parse a new ParticleSystemSet from a serialized source
  111568. * @param data defines a JSON compatible representation of the set
  111569. * @param scene defines the hosting scene
  111570. * @param gpu defines if we want GPU particles or CPU particles
  111571. * @returns a new ParticleSystemSet
  111572. */
  111573. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111574. }
  111575. }
  111576. declare module BABYLON {
  111577. /**
  111578. * This class is made for on one-liner static method to help creating particle system set.
  111579. */
  111580. export class ParticleHelper {
  111581. /**
  111582. * Gets or sets base Assets URL
  111583. */
  111584. static BaseAssetsUrl: string;
  111585. /**
  111586. * Create a default particle system that you can tweak
  111587. * @param emitter defines the emitter to use
  111588. * @param capacity defines the system capacity (default is 500 particles)
  111589. * @param scene defines the hosting scene
  111590. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111591. * @returns the new Particle system
  111592. */
  111593. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111594. /**
  111595. * This is the main static method (one-liner) of this helper to create different particle systems
  111596. * @param type This string represents the type to the particle system to create
  111597. * @param scene The scene where the particle system should live
  111598. * @param gpu If the system will use gpu
  111599. * @returns the ParticleSystemSet created
  111600. */
  111601. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111602. /**
  111603. * Static function used to export a particle system to a ParticleSystemSet variable.
  111604. * Please note that the emitter shape is not exported
  111605. * @param systems defines the particle systems to export
  111606. * @returns the created particle system set
  111607. */
  111608. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111609. }
  111610. }
  111611. declare module BABYLON {
  111612. interface Engine {
  111613. /**
  111614. * Create an effect to use with particle systems.
  111615. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111616. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111617. * @param uniformsNames defines a list of attribute names
  111618. * @param samplers defines an array of string used to represent textures
  111619. * @param defines defines the string containing the defines to use to compile the shaders
  111620. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111621. * @param onCompiled defines a function to call when the effect creation is successful
  111622. * @param onError defines a function to call when the effect creation has failed
  111623. * @returns the new Effect
  111624. */
  111625. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111626. }
  111627. interface Mesh {
  111628. /**
  111629. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111630. * @returns an array of IParticleSystem
  111631. */
  111632. getEmittedParticleSystems(): IParticleSystem[];
  111633. /**
  111634. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111635. * @returns an array of IParticleSystem
  111636. */
  111637. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111638. }
  111639. /**
  111640. * @hidden
  111641. */
  111642. export var _IDoNeedToBeInTheBuild: number;
  111643. }
  111644. declare module BABYLON {
  111645. interface Scene {
  111646. /** @hidden (Backing field) */
  111647. _physicsEngine: Nullable<IPhysicsEngine>;
  111648. /**
  111649. * Gets the current physics engine
  111650. * @returns a IPhysicsEngine or null if none attached
  111651. */
  111652. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111653. /**
  111654. * Enables physics to the current scene
  111655. * @param gravity defines the scene's gravity for the physics engine
  111656. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111657. * @return a boolean indicating if the physics engine was initialized
  111658. */
  111659. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111660. /**
  111661. * Disables and disposes the physics engine associated with the scene
  111662. */
  111663. disablePhysicsEngine(): void;
  111664. /**
  111665. * Gets a boolean indicating if there is an active physics engine
  111666. * @returns a boolean indicating if there is an active physics engine
  111667. */
  111668. isPhysicsEnabled(): boolean;
  111669. /**
  111670. * Deletes a physics compound impostor
  111671. * @param compound defines the compound to delete
  111672. */
  111673. deleteCompoundImpostor(compound: any): void;
  111674. /**
  111675. * An event triggered when physic simulation is about to be run
  111676. */
  111677. onBeforePhysicsObservable: Observable<Scene>;
  111678. /**
  111679. * An event triggered when physic simulation has been done
  111680. */
  111681. onAfterPhysicsObservable: Observable<Scene>;
  111682. }
  111683. interface AbstractMesh {
  111684. /** @hidden */
  111685. _physicsImpostor: Nullable<PhysicsImpostor>;
  111686. /**
  111687. * Gets or sets impostor used for physic simulation
  111688. * @see http://doc.babylonjs.com/features/physics_engine
  111689. */
  111690. physicsImpostor: Nullable<PhysicsImpostor>;
  111691. /**
  111692. * Gets the current physics impostor
  111693. * @see http://doc.babylonjs.com/features/physics_engine
  111694. * @returns a physics impostor or null
  111695. */
  111696. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111697. /** Apply a physic impulse to the mesh
  111698. * @param force defines the force to apply
  111699. * @param contactPoint defines where to apply the force
  111700. * @returns the current mesh
  111701. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111702. */
  111703. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111704. /**
  111705. * Creates a physic joint between two meshes
  111706. * @param otherMesh defines the other mesh to use
  111707. * @param pivot1 defines the pivot to use on this mesh
  111708. * @param pivot2 defines the pivot to use on the other mesh
  111709. * @param options defines additional options (can be plugin dependent)
  111710. * @returns the current mesh
  111711. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111712. */
  111713. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111714. /** @hidden */
  111715. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111716. }
  111717. /**
  111718. * Defines the physics engine scene component responsible to manage a physics engine
  111719. */
  111720. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111721. /**
  111722. * The component name helpful to identify the component in the list of scene components.
  111723. */
  111724. readonly name: string;
  111725. /**
  111726. * The scene the component belongs to.
  111727. */
  111728. scene: Scene;
  111729. /**
  111730. * Creates a new instance of the component for the given scene
  111731. * @param scene Defines the scene to register the component in
  111732. */
  111733. constructor(scene: Scene);
  111734. /**
  111735. * Registers the component in a given scene
  111736. */
  111737. register(): void;
  111738. /**
  111739. * Rebuilds the elements related to this component in case of
  111740. * context lost for instance.
  111741. */
  111742. rebuild(): void;
  111743. /**
  111744. * Disposes the component and the associated ressources
  111745. */
  111746. dispose(): void;
  111747. }
  111748. }
  111749. declare module BABYLON {
  111750. /**
  111751. * A helper for physics simulations
  111752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111753. */
  111754. export class PhysicsHelper {
  111755. private _scene;
  111756. private _physicsEngine;
  111757. /**
  111758. * Initializes the Physics helper
  111759. * @param scene Babylon.js scene
  111760. */
  111761. constructor(scene: Scene);
  111762. /**
  111763. * Applies a radial explosion impulse
  111764. * @param origin the origin of the explosion
  111765. * @param radiusOrEventOptions the radius or the options of radial explosion
  111766. * @param strength the explosion strength
  111767. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111768. * @returns A physics radial explosion event, or null
  111769. */
  111770. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111771. /**
  111772. * Applies a radial explosion force
  111773. * @param origin the origin of the explosion
  111774. * @param radiusOrEventOptions the radius or the options of radial explosion
  111775. * @param strength the explosion strength
  111776. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111777. * @returns A physics radial explosion event, or null
  111778. */
  111779. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111780. /**
  111781. * Creates a gravitational field
  111782. * @param origin the origin of the explosion
  111783. * @param radiusOrEventOptions the radius or the options of radial explosion
  111784. * @param strength the explosion strength
  111785. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111786. * @returns A physics gravitational field event, or null
  111787. */
  111788. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111789. /**
  111790. * Creates a physics updraft event
  111791. * @param origin the origin of the updraft
  111792. * @param radiusOrEventOptions the radius or the options of the updraft
  111793. * @param strength the strength of the updraft
  111794. * @param height the height of the updraft
  111795. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111796. * @returns A physics updraft event, or null
  111797. */
  111798. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111799. /**
  111800. * Creates a physics vortex event
  111801. * @param origin the of the vortex
  111802. * @param radiusOrEventOptions the radius or the options of the vortex
  111803. * @param strength the strength of the vortex
  111804. * @param height the height of the vortex
  111805. * @returns a Physics vortex event, or null
  111806. * A physics vortex event or null
  111807. */
  111808. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111809. }
  111810. /**
  111811. * Represents a physics radial explosion event
  111812. */
  111813. class PhysicsRadialExplosionEvent {
  111814. private _scene;
  111815. private _options;
  111816. private _sphere;
  111817. private _dataFetched;
  111818. /**
  111819. * Initializes a radial explosioin event
  111820. * @param _scene BabylonJS scene
  111821. * @param _options The options for the vortex event
  111822. */
  111823. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111824. /**
  111825. * Returns the data related to the radial explosion event (sphere).
  111826. * @returns The radial explosion event data
  111827. */
  111828. getData(): PhysicsRadialExplosionEventData;
  111829. /**
  111830. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111831. * @param impostor A physics imposter
  111832. * @param origin the origin of the explosion
  111833. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111834. */
  111835. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111836. /**
  111837. * Triggers affecterd impostors callbacks
  111838. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111839. */
  111840. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111841. /**
  111842. * Disposes the sphere.
  111843. * @param force Specifies if the sphere should be disposed by force
  111844. */
  111845. dispose(force?: boolean): void;
  111846. /*** Helpers ***/
  111847. private _prepareSphere;
  111848. private _intersectsWithSphere;
  111849. }
  111850. /**
  111851. * Represents a gravitational field event
  111852. */
  111853. class PhysicsGravitationalFieldEvent {
  111854. private _physicsHelper;
  111855. private _scene;
  111856. private _origin;
  111857. private _options;
  111858. private _tickCallback;
  111859. private _sphere;
  111860. private _dataFetched;
  111861. /**
  111862. * Initializes the physics gravitational field event
  111863. * @param _physicsHelper A physics helper
  111864. * @param _scene BabylonJS scene
  111865. * @param _origin The origin position of the gravitational field event
  111866. * @param _options The options for the vortex event
  111867. */
  111868. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111869. /**
  111870. * Returns the data related to the gravitational field event (sphere).
  111871. * @returns A gravitational field event
  111872. */
  111873. getData(): PhysicsGravitationalFieldEventData;
  111874. /**
  111875. * Enables the gravitational field.
  111876. */
  111877. enable(): void;
  111878. /**
  111879. * Disables the gravitational field.
  111880. */
  111881. disable(): void;
  111882. /**
  111883. * Disposes the sphere.
  111884. * @param force The force to dispose from the gravitational field event
  111885. */
  111886. dispose(force?: boolean): void;
  111887. private _tick;
  111888. }
  111889. /**
  111890. * Represents a physics updraft event
  111891. */
  111892. class PhysicsUpdraftEvent {
  111893. private _scene;
  111894. private _origin;
  111895. private _options;
  111896. private _physicsEngine;
  111897. private _originTop;
  111898. private _originDirection;
  111899. private _tickCallback;
  111900. private _cylinder;
  111901. private _cylinderPosition;
  111902. private _dataFetched;
  111903. /**
  111904. * Initializes the physics updraft event
  111905. * @param _scene BabylonJS scene
  111906. * @param _origin The origin position of the updraft
  111907. * @param _options The options for the updraft event
  111908. */
  111909. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111910. /**
  111911. * Returns the data related to the updraft event (cylinder).
  111912. * @returns A physics updraft event
  111913. */
  111914. getData(): PhysicsUpdraftEventData;
  111915. /**
  111916. * Enables the updraft.
  111917. */
  111918. enable(): void;
  111919. /**
  111920. * Disables the updraft.
  111921. */
  111922. disable(): void;
  111923. /**
  111924. * Disposes the cylinder.
  111925. * @param force Specifies if the updraft should be disposed by force
  111926. */
  111927. dispose(force?: boolean): void;
  111928. private getImpostorHitData;
  111929. private _tick;
  111930. /*** Helpers ***/
  111931. private _prepareCylinder;
  111932. private _intersectsWithCylinder;
  111933. }
  111934. /**
  111935. * Represents a physics vortex event
  111936. */
  111937. class PhysicsVortexEvent {
  111938. private _scene;
  111939. private _origin;
  111940. private _options;
  111941. private _physicsEngine;
  111942. private _originTop;
  111943. private _tickCallback;
  111944. private _cylinder;
  111945. private _cylinderPosition;
  111946. private _dataFetched;
  111947. /**
  111948. * Initializes the physics vortex event
  111949. * @param _scene The BabylonJS scene
  111950. * @param _origin The origin position of the vortex
  111951. * @param _options The options for the vortex event
  111952. */
  111953. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111954. /**
  111955. * Returns the data related to the vortex event (cylinder).
  111956. * @returns The physics vortex event data
  111957. */
  111958. getData(): PhysicsVortexEventData;
  111959. /**
  111960. * Enables the vortex.
  111961. */
  111962. enable(): void;
  111963. /**
  111964. * Disables the cortex.
  111965. */
  111966. disable(): void;
  111967. /**
  111968. * Disposes the sphere.
  111969. * @param force
  111970. */
  111971. dispose(force?: boolean): void;
  111972. private getImpostorHitData;
  111973. private _tick;
  111974. /*** Helpers ***/
  111975. private _prepareCylinder;
  111976. private _intersectsWithCylinder;
  111977. }
  111978. /**
  111979. * Options fot the radial explosion event
  111980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111981. */
  111982. export class PhysicsRadialExplosionEventOptions {
  111983. /**
  111984. * The radius of the sphere for the radial explosion.
  111985. */
  111986. radius: number;
  111987. /**
  111988. * The strenth of the explosion.
  111989. */
  111990. strength: number;
  111991. /**
  111992. * The strenght of the force in correspondence to the distance of the affected object
  111993. */
  111994. falloff: PhysicsRadialImpulseFalloff;
  111995. /**
  111996. * Sphere options for the radial explosion.
  111997. */
  111998. sphere: {
  111999. segments: number;
  112000. diameter: number;
  112001. };
  112002. /**
  112003. * Sphere options for the radial explosion.
  112004. */
  112005. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112006. }
  112007. /**
  112008. * Options fot the updraft event
  112009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112010. */
  112011. export class PhysicsUpdraftEventOptions {
  112012. /**
  112013. * The radius of the cylinder for the vortex
  112014. */
  112015. radius: number;
  112016. /**
  112017. * The strenth of the updraft.
  112018. */
  112019. strength: number;
  112020. /**
  112021. * The height of the cylinder for the updraft.
  112022. */
  112023. height: number;
  112024. /**
  112025. * The mode for the the updraft.
  112026. */
  112027. updraftMode: PhysicsUpdraftMode;
  112028. }
  112029. /**
  112030. * Options fot the vortex event
  112031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112032. */
  112033. export class PhysicsVortexEventOptions {
  112034. /**
  112035. * The radius of the cylinder for the vortex
  112036. */
  112037. radius: number;
  112038. /**
  112039. * The strenth of the vortex.
  112040. */
  112041. strength: number;
  112042. /**
  112043. * The height of the cylinder for the vortex.
  112044. */
  112045. height: number;
  112046. /**
  112047. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112048. */
  112049. centripetalForceThreshold: number;
  112050. /**
  112051. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112052. */
  112053. centripetalForceMultiplier: number;
  112054. /**
  112055. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112056. */
  112057. centrifugalForceMultiplier: number;
  112058. /**
  112059. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112060. */
  112061. updraftForceMultiplier: number;
  112062. }
  112063. /**
  112064. * The strenght of the force in correspondence to the distance of the affected object
  112065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112066. */
  112067. export enum PhysicsRadialImpulseFalloff {
  112068. /** Defines that impulse is constant in strength across it's whole radius */
  112069. Constant = 0,
  112070. /** Defines that impulse gets weaker if it's further from the origin */
  112071. Linear = 1
  112072. }
  112073. /**
  112074. * The strength of the force in correspondence to the distance of the affected object
  112075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112076. */
  112077. export enum PhysicsUpdraftMode {
  112078. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112079. Center = 0,
  112080. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112081. Perpendicular = 1
  112082. }
  112083. /**
  112084. * Interface for a physics hit data
  112085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112086. */
  112087. export interface PhysicsHitData {
  112088. /**
  112089. * The force applied at the contact point
  112090. */
  112091. force: Vector3;
  112092. /**
  112093. * The contact point
  112094. */
  112095. contactPoint: Vector3;
  112096. /**
  112097. * The distance from the origin to the contact point
  112098. */
  112099. distanceFromOrigin: number;
  112100. }
  112101. /**
  112102. * Interface for radial explosion event data
  112103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112104. */
  112105. export interface PhysicsRadialExplosionEventData {
  112106. /**
  112107. * A sphere used for the radial explosion event
  112108. */
  112109. sphere: Mesh;
  112110. }
  112111. /**
  112112. * Interface for gravitational field event data
  112113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112114. */
  112115. export interface PhysicsGravitationalFieldEventData {
  112116. /**
  112117. * A sphere mesh used for the gravitational field event
  112118. */
  112119. sphere: Mesh;
  112120. }
  112121. /**
  112122. * Interface for updraft event data
  112123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112124. */
  112125. export interface PhysicsUpdraftEventData {
  112126. /**
  112127. * A cylinder used for the updraft event
  112128. */
  112129. cylinder: Mesh;
  112130. }
  112131. /**
  112132. * Interface for vortex event data
  112133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112134. */
  112135. export interface PhysicsVortexEventData {
  112136. /**
  112137. * A cylinder used for the vortex event
  112138. */
  112139. cylinder: Mesh;
  112140. }
  112141. /**
  112142. * Interface for an affected physics impostor
  112143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112144. */
  112145. export interface PhysicsAffectedImpostorWithData {
  112146. /**
  112147. * The impostor affected by the effect
  112148. */
  112149. impostor: PhysicsImpostor;
  112150. /**
  112151. * The data about the hit/horce from the explosion
  112152. */
  112153. hitData: PhysicsHitData;
  112154. }
  112155. }
  112156. declare module BABYLON {
  112157. /** @hidden */
  112158. export var blackAndWhitePixelShader: {
  112159. name: string;
  112160. shader: string;
  112161. };
  112162. }
  112163. declare module BABYLON {
  112164. /**
  112165. * Post process used to render in black and white
  112166. */
  112167. export class BlackAndWhitePostProcess extends PostProcess {
  112168. /**
  112169. * Linear about to convert he result to black and white (default: 1)
  112170. */
  112171. degree: number;
  112172. /**
  112173. * Creates a black and white post process
  112174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112175. * @param name The name of the effect.
  112176. * @param options The required width/height ratio to downsize to before computing the render pass.
  112177. * @param camera The camera to apply the render pass to.
  112178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112179. * @param engine The engine which the post process will be applied. (default: current engine)
  112180. * @param reusable If the post process can be reused on the same frame. (default: false)
  112181. */
  112182. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112183. }
  112184. }
  112185. declare module BABYLON {
  112186. /**
  112187. * This represents a set of one or more post processes in Babylon.
  112188. * A post process can be used to apply a shader to a texture after it is rendered.
  112189. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112190. */
  112191. export class PostProcessRenderEffect {
  112192. private _postProcesses;
  112193. private _getPostProcesses;
  112194. private _singleInstance;
  112195. private _cameras;
  112196. private _indicesForCamera;
  112197. /**
  112198. * Name of the effect
  112199. * @hidden
  112200. */
  112201. _name: string;
  112202. /**
  112203. * Instantiates a post process render effect.
  112204. * A post process can be used to apply a shader to a texture after it is rendered.
  112205. * @param engine The engine the effect is tied to
  112206. * @param name The name of the effect
  112207. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112208. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112209. */
  112210. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112211. /**
  112212. * Checks if all the post processes in the effect are supported.
  112213. */
  112214. readonly isSupported: boolean;
  112215. /**
  112216. * Updates the current state of the effect
  112217. * @hidden
  112218. */
  112219. _update(): void;
  112220. /**
  112221. * Attaches the effect on cameras
  112222. * @param cameras The camera to attach to.
  112223. * @hidden
  112224. */
  112225. _attachCameras(cameras: Camera): void;
  112226. /**
  112227. * Attaches the effect on cameras
  112228. * @param cameras The camera to attach to.
  112229. * @hidden
  112230. */
  112231. _attachCameras(cameras: Camera[]): void;
  112232. /**
  112233. * Detaches the effect on cameras
  112234. * @param cameras The camera to detatch from.
  112235. * @hidden
  112236. */
  112237. _detachCameras(cameras: Camera): void;
  112238. /**
  112239. * Detatches the effect on cameras
  112240. * @param cameras The camera to detatch from.
  112241. * @hidden
  112242. */
  112243. _detachCameras(cameras: Camera[]): void;
  112244. /**
  112245. * Enables the effect on given cameras
  112246. * @param cameras The camera to enable.
  112247. * @hidden
  112248. */
  112249. _enable(cameras: Camera): void;
  112250. /**
  112251. * Enables the effect on given cameras
  112252. * @param cameras The camera to enable.
  112253. * @hidden
  112254. */
  112255. _enable(cameras: Nullable<Camera[]>): void;
  112256. /**
  112257. * Disables the effect on the given cameras
  112258. * @param cameras The camera to disable.
  112259. * @hidden
  112260. */
  112261. _disable(cameras: Camera): void;
  112262. /**
  112263. * Disables the effect on the given cameras
  112264. * @param cameras The camera to disable.
  112265. * @hidden
  112266. */
  112267. _disable(cameras: Nullable<Camera[]>): void;
  112268. /**
  112269. * Gets a list of the post processes contained in the effect.
  112270. * @param camera The camera to get the post processes on.
  112271. * @returns The list of the post processes in the effect.
  112272. */
  112273. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112274. }
  112275. }
  112276. declare module BABYLON {
  112277. /** @hidden */
  112278. export var extractHighlightsPixelShader: {
  112279. name: string;
  112280. shader: string;
  112281. };
  112282. }
  112283. declare module BABYLON {
  112284. /**
  112285. * 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.
  112286. */
  112287. export class ExtractHighlightsPostProcess extends PostProcess {
  112288. /**
  112289. * The luminance threshold, pixels below this value will be set to black.
  112290. */
  112291. threshold: number;
  112292. /** @hidden */
  112293. _exposure: number;
  112294. /**
  112295. * Post process which has the input texture to be used when performing highlight extraction
  112296. * @hidden
  112297. */
  112298. _inputPostProcess: Nullable<PostProcess>;
  112299. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112300. }
  112301. }
  112302. declare module BABYLON {
  112303. /** @hidden */
  112304. export var bloomMergePixelShader: {
  112305. name: string;
  112306. shader: string;
  112307. };
  112308. }
  112309. declare module BABYLON {
  112310. /**
  112311. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112312. */
  112313. export class BloomMergePostProcess extends PostProcess {
  112314. /** Weight of the bloom to be added to the original input. */
  112315. weight: number;
  112316. /**
  112317. * Creates a new instance of @see BloomMergePostProcess
  112318. * @param name The name of the effect.
  112319. * @param originalFromInput Post process which's input will be used for the merge.
  112320. * @param blurred Blurred highlights post process which's output will be used.
  112321. * @param weight Weight of the bloom to be added to the original input.
  112322. * @param options The required width/height ratio to downsize to before computing the render pass.
  112323. * @param camera The camera to apply the render pass to.
  112324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112325. * @param engine The engine which the post process will be applied. (default: current engine)
  112326. * @param reusable If the post process can be reused on the same frame. (default: false)
  112327. * @param textureType Type of textures used when performing the post process. (default: 0)
  112328. * @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)
  112329. */
  112330. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112331. /** Weight of the bloom to be added to the original input. */
  112332. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112333. }
  112334. }
  112335. declare module BABYLON {
  112336. /**
  112337. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112338. */
  112339. export class BloomEffect extends PostProcessRenderEffect {
  112340. private bloomScale;
  112341. /**
  112342. * @hidden Internal
  112343. */
  112344. _effects: Array<PostProcess>;
  112345. /**
  112346. * @hidden Internal
  112347. */
  112348. _downscale: ExtractHighlightsPostProcess;
  112349. private _blurX;
  112350. private _blurY;
  112351. private _merge;
  112352. /**
  112353. * The luminance threshold to find bright areas of the image to bloom.
  112354. */
  112355. threshold: number;
  112356. /**
  112357. * The strength of the bloom.
  112358. */
  112359. weight: number;
  112360. /**
  112361. * Specifies the size of the bloom blur kernel, relative to the final output size
  112362. */
  112363. kernel: number;
  112364. /**
  112365. * Creates a new instance of @see BloomEffect
  112366. * @param scene The scene the effect belongs to.
  112367. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112368. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112369. * @param bloomWeight The the strength of bloom.
  112370. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112371. * @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)
  112372. */
  112373. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112374. /**
  112375. * Disposes each of the internal effects for a given camera.
  112376. * @param camera The camera to dispose the effect on.
  112377. */
  112378. disposeEffects(camera: Camera): void;
  112379. /**
  112380. * @hidden Internal
  112381. */
  112382. _updateEffects(): void;
  112383. /**
  112384. * Internal
  112385. * @returns if all the contained post processes are ready.
  112386. * @hidden
  112387. */
  112388. _isReady(): boolean;
  112389. }
  112390. }
  112391. declare module BABYLON {
  112392. /** @hidden */
  112393. export var chromaticAberrationPixelShader: {
  112394. name: string;
  112395. shader: string;
  112396. };
  112397. }
  112398. declare module BABYLON {
  112399. /**
  112400. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112401. */
  112402. export class ChromaticAberrationPostProcess extends PostProcess {
  112403. /**
  112404. * The amount of seperation of rgb channels (default: 30)
  112405. */
  112406. aberrationAmount: number;
  112407. /**
  112408. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112409. */
  112410. radialIntensity: number;
  112411. /**
  112412. * 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))
  112413. */
  112414. direction: Vector2;
  112415. /**
  112416. * 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))
  112417. */
  112418. centerPosition: Vector2;
  112419. /**
  112420. * Creates a new instance ChromaticAberrationPostProcess
  112421. * @param name The name of the effect.
  112422. * @param screenWidth The width of the screen to apply the effect on.
  112423. * @param screenHeight The height of the screen to apply the effect on.
  112424. * @param options The required width/height ratio to downsize to before computing the render pass.
  112425. * @param camera The camera to apply the render pass to.
  112426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112427. * @param engine The engine which the post process will be applied. (default: current engine)
  112428. * @param reusable If the post process can be reused on the same frame. (default: false)
  112429. * @param textureType Type of textures used when performing the post process. (default: 0)
  112430. * @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)
  112431. */
  112432. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112433. }
  112434. }
  112435. declare module BABYLON {
  112436. /** @hidden */
  112437. export var circleOfConfusionPixelShader: {
  112438. name: string;
  112439. shader: string;
  112440. };
  112441. }
  112442. declare module BABYLON {
  112443. /**
  112444. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112445. */
  112446. export class CircleOfConfusionPostProcess extends PostProcess {
  112447. /**
  112448. * 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.
  112449. */
  112450. lensSize: number;
  112451. /**
  112452. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112453. */
  112454. fStop: number;
  112455. /**
  112456. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112457. */
  112458. focusDistance: number;
  112459. /**
  112460. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112461. */
  112462. focalLength: number;
  112463. private _depthTexture;
  112464. /**
  112465. * Creates a new instance CircleOfConfusionPostProcess
  112466. * @param name The name of the effect.
  112467. * @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.
  112468. * @param options The required width/height ratio to downsize to before computing the render pass.
  112469. * @param camera The camera to apply the render pass to.
  112470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112471. * @param engine The engine which the post process will be applied. (default: current engine)
  112472. * @param reusable If the post process can be reused on the same frame. (default: false)
  112473. * @param textureType Type of textures used when performing the post process. (default: 0)
  112474. * @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)
  112475. */
  112476. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112477. /**
  112478. * 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.
  112479. */
  112480. depthTexture: RenderTargetTexture;
  112481. }
  112482. }
  112483. declare module BABYLON {
  112484. /** @hidden */
  112485. export var colorCorrectionPixelShader: {
  112486. name: string;
  112487. shader: string;
  112488. };
  112489. }
  112490. declare module BABYLON {
  112491. /**
  112492. *
  112493. * This post-process allows the modification of rendered colors by using
  112494. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112495. *
  112496. * The object needs to be provided an url to a texture containing the color
  112497. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112498. * Use an image editing software to tweak the LUT to match your needs.
  112499. *
  112500. * For an example of a color LUT, see here:
  112501. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112502. * For explanations on color grading, see here:
  112503. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112504. *
  112505. */
  112506. export class ColorCorrectionPostProcess extends PostProcess {
  112507. private _colorTableTexture;
  112508. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112509. }
  112510. }
  112511. declare module BABYLON {
  112512. /** @hidden */
  112513. export var convolutionPixelShader: {
  112514. name: string;
  112515. shader: string;
  112516. };
  112517. }
  112518. declare module BABYLON {
  112519. /**
  112520. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112521. * input texture to perform effects such as edge detection or sharpening
  112522. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112523. */
  112524. export class ConvolutionPostProcess extends PostProcess {
  112525. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112526. kernel: number[];
  112527. /**
  112528. * Creates a new instance ConvolutionPostProcess
  112529. * @param name The name of the effect.
  112530. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112531. * @param options The required width/height ratio to downsize to before computing the render pass.
  112532. * @param camera The camera to apply the render pass to.
  112533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112534. * @param engine The engine which the post process will be applied. (default: current engine)
  112535. * @param reusable If the post process can be reused on the same frame. (default: false)
  112536. * @param textureType Type of textures used when performing the post process. (default: 0)
  112537. */
  112538. constructor(name: string,
  112539. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112540. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112541. /**
  112542. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112543. */
  112544. static EdgeDetect0Kernel: number[];
  112545. /**
  112546. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112547. */
  112548. static EdgeDetect1Kernel: number[];
  112549. /**
  112550. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112551. */
  112552. static EdgeDetect2Kernel: number[];
  112553. /**
  112554. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112555. */
  112556. static SharpenKernel: number[];
  112557. /**
  112558. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112559. */
  112560. static EmbossKernel: number[];
  112561. /**
  112562. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112563. */
  112564. static GaussianKernel: number[];
  112565. }
  112566. }
  112567. declare module BABYLON {
  112568. /**
  112569. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112570. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112571. * based on samples that have a large difference in distance than the center pixel.
  112572. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112573. */
  112574. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112575. direction: Vector2;
  112576. /**
  112577. * Creates a new instance CircleOfConfusionPostProcess
  112578. * @param name The name of the effect.
  112579. * @param scene The scene the effect belongs to.
  112580. * @param direction The direction the blur should be applied.
  112581. * @param kernel The size of the kernel used to blur.
  112582. * @param options The required width/height ratio to downsize to before computing the render pass.
  112583. * @param camera The camera to apply the render pass to.
  112584. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112585. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112587. * @param engine The engine which the post process will be applied. (default: current engine)
  112588. * @param reusable If the post process can be reused on the same frame. (default: false)
  112589. * @param textureType Type of textures used when performing the post process. (default: 0)
  112590. * @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)
  112591. */
  112592. 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);
  112593. }
  112594. }
  112595. declare module BABYLON {
  112596. /** @hidden */
  112597. export var depthOfFieldMergePixelShader: {
  112598. name: string;
  112599. shader: string;
  112600. };
  112601. }
  112602. declare module BABYLON {
  112603. /**
  112604. * Options to be set when merging outputs from the default pipeline.
  112605. */
  112606. export class DepthOfFieldMergePostProcessOptions {
  112607. /**
  112608. * The original image to merge on top of
  112609. */
  112610. originalFromInput: PostProcess;
  112611. /**
  112612. * Parameters to perform the merge of the depth of field effect
  112613. */
  112614. depthOfField?: {
  112615. circleOfConfusion: PostProcess;
  112616. blurSteps: Array<PostProcess>;
  112617. };
  112618. /**
  112619. * Parameters to perform the merge of bloom effect
  112620. */
  112621. bloom?: {
  112622. blurred: PostProcess;
  112623. weight: number;
  112624. };
  112625. }
  112626. /**
  112627. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112628. */
  112629. export class DepthOfFieldMergePostProcess extends PostProcess {
  112630. private blurSteps;
  112631. /**
  112632. * Creates a new instance of DepthOfFieldMergePostProcess
  112633. * @param name The name of the effect.
  112634. * @param originalFromInput Post process which's input will be used for the merge.
  112635. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112636. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112637. * @param options The required width/height ratio to downsize to before computing the render pass.
  112638. * @param camera The camera to apply the render pass to.
  112639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112640. * @param engine The engine which the post process will be applied. (default: current engine)
  112641. * @param reusable If the post process can be reused on the same frame. (default: false)
  112642. * @param textureType Type of textures used when performing the post process. (default: 0)
  112643. * @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)
  112644. */
  112645. 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);
  112646. /**
  112647. * Updates the effect with the current post process compile time values and recompiles the shader.
  112648. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112649. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112650. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112651. * @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
  112652. * @param onCompiled Called when the shader has been compiled.
  112653. * @param onError Called if there is an error when compiling a shader.
  112654. */
  112655. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112656. }
  112657. }
  112658. declare module BABYLON {
  112659. /**
  112660. * Specifies the level of max blur that should be applied when using the depth of field effect
  112661. */
  112662. export enum DepthOfFieldEffectBlurLevel {
  112663. /**
  112664. * Subtle blur
  112665. */
  112666. Low = 0,
  112667. /**
  112668. * Medium blur
  112669. */
  112670. Medium = 1,
  112671. /**
  112672. * Large blur
  112673. */
  112674. High = 2
  112675. }
  112676. /**
  112677. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112678. */
  112679. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112680. private _circleOfConfusion;
  112681. /**
  112682. * @hidden Internal, blurs from high to low
  112683. */
  112684. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112685. private _depthOfFieldBlurY;
  112686. private _dofMerge;
  112687. /**
  112688. * @hidden Internal post processes in depth of field effect
  112689. */
  112690. _effects: Array<PostProcess>;
  112691. /**
  112692. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112693. */
  112694. focalLength: number;
  112695. /**
  112696. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112697. */
  112698. fStop: number;
  112699. /**
  112700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112701. */
  112702. focusDistance: number;
  112703. /**
  112704. * 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.
  112705. */
  112706. lensSize: number;
  112707. /**
  112708. * Creates a new instance DepthOfFieldEffect
  112709. * @param scene The scene the effect belongs to.
  112710. * @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.
  112711. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112712. * @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)
  112713. */
  112714. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112715. /**
  112716. * Get the current class name of the current effet
  112717. * @returns "DepthOfFieldEffect"
  112718. */
  112719. getClassName(): string;
  112720. /**
  112721. * 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.
  112722. */
  112723. depthTexture: RenderTargetTexture;
  112724. /**
  112725. * Disposes each of the internal effects for a given camera.
  112726. * @param camera The camera to dispose the effect on.
  112727. */
  112728. disposeEffects(camera: Camera): void;
  112729. /**
  112730. * @hidden Internal
  112731. */
  112732. _updateEffects(): void;
  112733. /**
  112734. * Internal
  112735. * @returns if all the contained post processes are ready.
  112736. * @hidden
  112737. */
  112738. _isReady(): boolean;
  112739. }
  112740. }
  112741. declare module BABYLON {
  112742. /** @hidden */
  112743. export var displayPassPixelShader: {
  112744. name: string;
  112745. shader: string;
  112746. };
  112747. }
  112748. declare module BABYLON {
  112749. /**
  112750. * DisplayPassPostProcess which produces an output the same as it's input
  112751. */
  112752. export class DisplayPassPostProcess extends PostProcess {
  112753. /**
  112754. * Creates the DisplayPassPostProcess
  112755. * @param name The name of the effect.
  112756. * @param options The required width/height ratio to downsize to before computing the render pass.
  112757. * @param camera The camera to apply the render pass to.
  112758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112759. * @param engine The engine which the post process will be applied. (default: current engine)
  112760. * @param reusable If the post process can be reused on the same frame. (default: false)
  112761. */
  112762. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112763. }
  112764. }
  112765. declare module BABYLON {
  112766. /** @hidden */
  112767. export var filterPixelShader: {
  112768. name: string;
  112769. shader: string;
  112770. };
  112771. }
  112772. declare module BABYLON {
  112773. /**
  112774. * Applies a kernel filter to the image
  112775. */
  112776. export class FilterPostProcess extends PostProcess {
  112777. /** The matrix to be applied to the image */
  112778. kernelMatrix: Matrix;
  112779. /**
  112780. *
  112781. * @param name The name of the effect.
  112782. * @param kernelMatrix The matrix to be applied to the image
  112783. * @param options The required width/height ratio to downsize to before computing the render pass.
  112784. * @param camera The camera to apply the render pass to.
  112785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112786. * @param engine The engine which the post process will be applied. (default: current engine)
  112787. * @param reusable If the post process can be reused on the same frame. (default: false)
  112788. */
  112789. constructor(name: string,
  112790. /** The matrix to be applied to the image */
  112791. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112792. }
  112793. }
  112794. declare module BABYLON {
  112795. /** @hidden */
  112796. export var fxaaPixelShader: {
  112797. name: string;
  112798. shader: string;
  112799. };
  112800. }
  112801. declare module BABYLON {
  112802. /** @hidden */
  112803. export var fxaaVertexShader: {
  112804. name: string;
  112805. shader: string;
  112806. };
  112807. }
  112808. declare module BABYLON {
  112809. /**
  112810. * Fxaa post process
  112811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112812. */
  112813. export class FxaaPostProcess extends PostProcess {
  112814. /** @hidden */
  112815. texelWidth: number;
  112816. /** @hidden */
  112817. texelHeight: number;
  112818. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112819. private _getDefines;
  112820. }
  112821. }
  112822. declare module BABYLON {
  112823. /** @hidden */
  112824. export var grainPixelShader: {
  112825. name: string;
  112826. shader: string;
  112827. };
  112828. }
  112829. declare module BABYLON {
  112830. /**
  112831. * The GrainPostProcess adds noise to the image at mid luminance levels
  112832. */
  112833. export class GrainPostProcess extends PostProcess {
  112834. /**
  112835. * The intensity of the grain added (default: 30)
  112836. */
  112837. intensity: number;
  112838. /**
  112839. * If the grain should be randomized on every frame
  112840. */
  112841. animated: boolean;
  112842. /**
  112843. * Creates a new instance of @see GrainPostProcess
  112844. * @param name The name of the effect.
  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, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112854. }
  112855. }
  112856. declare module BABYLON {
  112857. /** @hidden */
  112858. export var highlightsPixelShader: {
  112859. name: string;
  112860. shader: string;
  112861. };
  112862. }
  112863. declare module BABYLON {
  112864. /**
  112865. * Extracts highlights from the image
  112866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112867. */
  112868. export class HighlightsPostProcess extends PostProcess {
  112869. /**
  112870. * Extracts highlights from the image
  112871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112872. * @param name The name of the effect.
  112873. * @param options The required width/height ratio to downsize to before computing the render pass.
  112874. * @param camera The camera to apply the render pass to.
  112875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112876. * @param engine The engine which the post process will be applied. (default: current engine)
  112877. * @param reusable If the post process can be reused on the same frame. (default: false)
  112878. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112879. */
  112880. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112881. }
  112882. }
  112883. declare module BABYLON {
  112884. /** @hidden */
  112885. export var mrtFragmentDeclaration: {
  112886. name: string;
  112887. shader: string;
  112888. };
  112889. }
  112890. declare module BABYLON {
  112891. /** @hidden */
  112892. export var geometryPixelShader: {
  112893. name: string;
  112894. shader: string;
  112895. };
  112896. }
  112897. declare module BABYLON {
  112898. /** @hidden */
  112899. export var geometryVertexShader: {
  112900. name: string;
  112901. shader: string;
  112902. };
  112903. }
  112904. declare module BABYLON {
  112905. /**
  112906. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112907. */
  112908. export class GeometryBufferRenderer {
  112909. /**
  112910. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112911. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112912. */
  112913. static readonly POSITION_TEXTURE_TYPE: number;
  112914. /**
  112915. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112916. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112917. */
  112918. static readonly VELOCITY_TEXTURE_TYPE: number;
  112919. /**
  112920. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112921. * in order to compute objects velocities when enableVelocity is set to "true"
  112922. * @hidden
  112923. */
  112924. _previousTransformationMatrices: {
  112925. [index: number]: Matrix;
  112926. };
  112927. private _scene;
  112928. private _multiRenderTarget;
  112929. private _ratio;
  112930. private _enablePosition;
  112931. private _enableVelocity;
  112932. private _positionIndex;
  112933. private _velocityIndex;
  112934. protected _effect: Effect;
  112935. protected _cachedDefines: string;
  112936. /**
  112937. * Set the render list (meshes to be rendered) used in the G buffer.
  112938. */
  112939. renderList: Mesh[];
  112940. /**
  112941. * Gets wether or not G buffer are supported by the running hardware.
  112942. * This requires draw buffer supports
  112943. */
  112944. readonly isSupported: boolean;
  112945. /**
  112946. * Returns the index of the given texture type in the G-Buffer textures array
  112947. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112948. * @returns the index of the given texture type in the G-Buffer textures array
  112949. */
  112950. getTextureIndex(textureType: number): number;
  112951. /**
  112952. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112953. */
  112954. /**
  112955. * Sets whether or not objects positions are enabled for the G buffer.
  112956. */
  112957. enablePosition: boolean;
  112958. /**
  112959. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112960. */
  112961. /**
  112962. * Sets wether or not objects velocities are enabled for the G buffer.
  112963. */
  112964. enableVelocity: boolean;
  112965. /**
  112966. * Gets the scene associated with the buffer.
  112967. */
  112968. readonly scene: Scene;
  112969. /**
  112970. * Gets the ratio used by the buffer during its creation.
  112971. * How big is the buffer related to the main canvas.
  112972. */
  112973. readonly ratio: number;
  112974. /** @hidden */
  112975. static _SceneComponentInitialization: (scene: Scene) => void;
  112976. /**
  112977. * Creates a new G Buffer for the scene
  112978. * @param scene The scene the buffer belongs to
  112979. * @param ratio How big is the buffer related to the main canvas.
  112980. */
  112981. constructor(scene: Scene, ratio?: number);
  112982. /**
  112983. * Checks wether everything is ready to render a submesh to the G buffer.
  112984. * @param subMesh the submesh to check readiness for
  112985. * @param useInstances is the mesh drawn using instance or not
  112986. * @returns true if ready otherwise false
  112987. */
  112988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112989. /**
  112990. * Gets the current underlying G Buffer.
  112991. * @returns the buffer
  112992. */
  112993. getGBuffer(): MultiRenderTarget;
  112994. /**
  112995. * Gets the number of samples used to render the buffer (anti aliasing).
  112996. */
  112997. /**
  112998. * Sets the number of samples used to render the buffer (anti aliasing).
  112999. */
  113000. samples: number;
  113001. /**
  113002. * Disposes the renderer and frees up associated resources.
  113003. */
  113004. dispose(): void;
  113005. protected _createRenderTargets(): void;
  113006. }
  113007. }
  113008. declare module BABYLON {
  113009. interface Scene {
  113010. /** @hidden (Backing field) */
  113011. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113012. /**
  113013. * Gets or Sets the current geometry buffer associated to the scene.
  113014. */
  113015. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113016. /**
  113017. * Enables a GeometryBufferRender and associates it with the scene
  113018. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113019. * @returns the GeometryBufferRenderer
  113020. */
  113021. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113022. /**
  113023. * Disables the GeometryBufferRender associated with the scene
  113024. */
  113025. disableGeometryBufferRenderer(): void;
  113026. }
  113027. /**
  113028. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113029. * in several rendering techniques.
  113030. */
  113031. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113032. /**
  113033. * The component name helpful to identify the component in the list of scene components.
  113034. */
  113035. readonly name: string;
  113036. /**
  113037. * The scene the component belongs to.
  113038. */
  113039. scene: Scene;
  113040. /**
  113041. * Creates a new instance of the component for the given scene
  113042. * @param scene Defines the scene to register the component in
  113043. */
  113044. constructor(scene: Scene);
  113045. /**
  113046. * Registers the component in a given scene
  113047. */
  113048. register(): void;
  113049. /**
  113050. * Rebuilds the elements related to this component in case of
  113051. * context lost for instance.
  113052. */
  113053. rebuild(): void;
  113054. /**
  113055. * Disposes the component and the associated ressources
  113056. */
  113057. dispose(): void;
  113058. private _gatherRenderTargets;
  113059. }
  113060. }
  113061. declare module BABYLON {
  113062. /** @hidden */
  113063. export var motionBlurPixelShader: {
  113064. name: string;
  113065. shader: string;
  113066. };
  113067. }
  113068. declare module BABYLON {
  113069. /**
  113070. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113071. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113072. * As an example, all you have to do is to create the post-process:
  113073. * var mb = new BABYLON.MotionBlurPostProcess(
  113074. * 'mb', // The name of the effect.
  113075. * scene, // The scene containing the objects to blur according to their velocity.
  113076. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113077. * camera // The camera to apply the render pass to.
  113078. * );
  113079. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113080. */
  113081. export class MotionBlurPostProcess extends PostProcess {
  113082. /**
  113083. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113084. */
  113085. motionStrength: number;
  113086. /**
  113087. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113088. */
  113089. /**
  113090. * Sets the number of iterations to be used for motion blur quality
  113091. */
  113092. motionBlurSamples: number;
  113093. private _motionBlurSamples;
  113094. private _geometryBufferRenderer;
  113095. /**
  113096. * Creates a new instance MotionBlurPostProcess
  113097. * @param name The name of the effect.
  113098. * @param scene The scene containing the objects to blur according to their velocity.
  113099. * @param options The required width/height ratio to downsize to before computing the render pass.
  113100. * @param camera The camera to apply the render pass to.
  113101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113102. * @param engine The engine which the post process will be applied. (default: current engine)
  113103. * @param reusable If the post process can be reused on the same frame. (default: false)
  113104. * @param textureType Type of textures used when performing the post process. (default: 0)
  113105. * @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)
  113106. */
  113107. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113108. /**
  113109. * Disposes the post process.
  113110. * @param camera The camera to dispose the post process on.
  113111. */
  113112. dispose(camera?: Camera): void;
  113113. }
  113114. }
  113115. declare module BABYLON {
  113116. /** @hidden */
  113117. export var refractionPixelShader: {
  113118. name: string;
  113119. shader: string;
  113120. };
  113121. }
  113122. declare module BABYLON {
  113123. /**
  113124. * Post process which applies a refractin texture
  113125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113126. */
  113127. export class RefractionPostProcess extends PostProcess {
  113128. /** the base color of the refraction (used to taint the rendering) */
  113129. color: Color3;
  113130. /** simulated refraction depth */
  113131. depth: number;
  113132. /** the coefficient of the base color (0 to remove base color tainting) */
  113133. colorLevel: number;
  113134. private _refTexture;
  113135. private _ownRefractionTexture;
  113136. /**
  113137. * Gets or sets the refraction texture
  113138. * Please note that you are responsible for disposing the texture if you set it manually
  113139. */
  113140. refractionTexture: Texture;
  113141. /**
  113142. * Initializes the RefractionPostProcess
  113143. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113144. * @param name The name of the effect.
  113145. * @param refractionTextureUrl Url of the refraction texture to use
  113146. * @param color the base color of the refraction (used to taint the rendering)
  113147. * @param depth simulated refraction depth
  113148. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113149. * @param camera The camera to apply the render pass to.
  113150. * @param options The required width/height ratio to downsize to before computing the render pass.
  113151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113152. * @param engine The engine which the post process will be applied. (default: current engine)
  113153. * @param reusable If the post process can be reused on the same frame. (default: false)
  113154. */
  113155. constructor(name: string, refractionTextureUrl: string,
  113156. /** the base color of the refraction (used to taint the rendering) */
  113157. color: Color3,
  113158. /** simulated refraction depth */
  113159. depth: number,
  113160. /** the coefficient of the base color (0 to remove base color tainting) */
  113161. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113162. /**
  113163. * Disposes of the post process
  113164. * @param camera Camera to dispose post process on
  113165. */
  113166. dispose(camera: Camera): void;
  113167. }
  113168. }
  113169. declare module BABYLON {
  113170. /** @hidden */
  113171. export var sharpenPixelShader: {
  113172. name: string;
  113173. shader: string;
  113174. };
  113175. }
  113176. declare module BABYLON {
  113177. /**
  113178. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113179. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113180. */
  113181. export class SharpenPostProcess extends PostProcess {
  113182. /**
  113183. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113184. */
  113185. colorAmount: number;
  113186. /**
  113187. * How much sharpness should be applied (default: 0.3)
  113188. */
  113189. edgeAmount: number;
  113190. /**
  113191. * Creates a new instance ConvolutionPostProcess
  113192. * @param name The name of the effect.
  113193. * @param options The required width/height ratio to downsize to before computing the render pass.
  113194. * @param camera The camera to apply the render pass to.
  113195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113196. * @param engine The engine which the post process will be applied. (default: current engine)
  113197. * @param reusable If the post process can be reused on the same frame. (default: false)
  113198. * @param textureType Type of textures used when performing the post process. (default: 0)
  113199. * @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)
  113200. */
  113201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113202. }
  113203. }
  113204. declare module BABYLON {
  113205. /**
  113206. * PostProcessRenderPipeline
  113207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113208. */
  113209. export class PostProcessRenderPipeline {
  113210. private engine;
  113211. private _renderEffects;
  113212. private _renderEffectsForIsolatedPass;
  113213. /**
  113214. * List of inspectable custom properties (used by the Inspector)
  113215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113216. */
  113217. inspectableCustomProperties: IInspectable[];
  113218. /**
  113219. * @hidden
  113220. */
  113221. protected _cameras: Camera[];
  113222. /** @hidden */
  113223. _name: string;
  113224. /**
  113225. * Gets pipeline name
  113226. */
  113227. readonly name: string;
  113228. /**
  113229. * Initializes a PostProcessRenderPipeline
  113230. * @param engine engine to add the pipeline to
  113231. * @param name name of the pipeline
  113232. */
  113233. constructor(engine: Engine, name: string);
  113234. /**
  113235. * Gets the class name
  113236. * @returns "PostProcessRenderPipeline"
  113237. */
  113238. getClassName(): string;
  113239. /**
  113240. * If all the render effects in the pipeline are supported
  113241. */
  113242. readonly isSupported: boolean;
  113243. /**
  113244. * Adds an effect to the pipeline
  113245. * @param renderEffect the effect to add
  113246. */
  113247. addEffect(renderEffect: PostProcessRenderEffect): void;
  113248. /** @hidden */
  113249. _rebuild(): void;
  113250. /** @hidden */
  113251. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113252. /** @hidden */
  113253. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113254. /** @hidden */
  113255. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113256. /** @hidden */
  113257. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113258. /** @hidden */
  113259. _attachCameras(cameras: Camera, unique: boolean): void;
  113260. /** @hidden */
  113261. _attachCameras(cameras: Camera[], unique: boolean): void;
  113262. /** @hidden */
  113263. _detachCameras(cameras: Camera): void;
  113264. /** @hidden */
  113265. _detachCameras(cameras: Nullable<Camera[]>): void;
  113266. /** @hidden */
  113267. _update(): void;
  113268. /** @hidden */
  113269. _reset(): void;
  113270. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113271. /**
  113272. * Disposes of the pipeline
  113273. */
  113274. dispose(): void;
  113275. }
  113276. }
  113277. declare module BABYLON {
  113278. /**
  113279. * PostProcessRenderPipelineManager class
  113280. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113281. */
  113282. export class PostProcessRenderPipelineManager {
  113283. private _renderPipelines;
  113284. /**
  113285. * Initializes a PostProcessRenderPipelineManager
  113286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113287. */
  113288. constructor();
  113289. /**
  113290. * Gets the list of supported render pipelines
  113291. */
  113292. readonly supportedPipelines: PostProcessRenderPipeline[];
  113293. /**
  113294. * Adds a pipeline to the manager
  113295. * @param renderPipeline The pipeline to add
  113296. */
  113297. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113298. /**
  113299. * Attaches a camera to the pipeline
  113300. * @param renderPipelineName The name of the pipeline to attach to
  113301. * @param cameras the camera to attach
  113302. * @param unique if the camera can be attached multiple times to the pipeline
  113303. */
  113304. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113305. /**
  113306. * Detaches a camera from the pipeline
  113307. * @param renderPipelineName The name of the pipeline to detach from
  113308. * @param cameras the camera to detach
  113309. */
  113310. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113311. /**
  113312. * Enables an effect by name on a pipeline
  113313. * @param renderPipelineName the name of the pipeline to enable the effect in
  113314. * @param renderEffectName the name of the effect to enable
  113315. * @param cameras the cameras that the effect should be enabled on
  113316. */
  113317. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113318. /**
  113319. * Disables an effect by name on a pipeline
  113320. * @param renderPipelineName the name of the pipeline to disable the effect in
  113321. * @param renderEffectName the name of the effect to disable
  113322. * @param cameras the cameras that the effect should be disabled on
  113323. */
  113324. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113325. /**
  113326. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113327. */
  113328. update(): void;
  113329. /** @hidden */
  113330. _rebuild(): void;
  113331. /**
  113332. * Disposes of the manager and pipelines
  113333. */
  113334. dispose(): void;
  113335. }
  113336. }
  113337. declare module BABYLON {
  113338. interface Scene {
  113339. /** @hidden (Backing field) */
  113340. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113341. /**
  113342. * Gets the postprocess render pipeline manager
  113343. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113344. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113345. */
  113346. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113347. }
  113348. /**
  113349. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113350. */
  113351. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113352. /**
  113353. * The component name helpfull to identify the component in the list of scene components.
  113354. */
  113355. readonly name: string;
  113356. /**
  113357. * The scene the component belongs to.
  113358. */
  113359. scene: Scene;
  113360. /**
  113361. * Creates a new instance of the component for the given scene
  113362. * @param scene Defines the scene to register the component in
  113363. */
  113364. constructor(scene: Scene);
  113365. /**
  113366. * Registers the component in a given scene
  113367. */
  113368. register(): void;
  113369. /**
  113370. * Rebuilds the elements related to this component in case of
  113371. * context lost for instance.
  113372. */
  113373. rebuild(): void;
  113374. /**
  113375. * Disposes the component and the associated ressources
  113376. */
  113377. dispose(): void;
  113378. private _gatherRenderTargets;
  113379. }
  113380. }
  113381. declare module BABYLON {
  113382. /**
  113383. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113384. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113385. */
  113386. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113387. private _scene;
  113388. private _camerasToBeAttached;
  113389. /**
  113390. * ID of the sharpen post process,
  113391. */
  113392. private readonly SharpenPostProcessId;
  113393. /**
  113394. * @ignore
  113395. * ID of the image processing post process;
  113396. */
  113397. readonly ImageProcessingPostProcessId: string;
  113398. /**
  113399. * @ignore
  113400. * ID of the Fast Approximate Anti-Aliasing post process;
  113401. */
  113402. readonly FxaaPostProcessId: string;
  113403. /**
  113404. * ID of the chromatic aberration post process,
  113405. */
  113406. private readonly ChromaticAberrationPostProcessId;
  113407. /**
  113408. * ID of the grain post process
  113409. */
  113410. private readonly GrainPostProcessId;
  113411. /**
  113412. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113413. */
  113414. sharpen: SharpenPostProcess;
  113415. private _sharpenEffect;
  113416. private bloom;
  113417. /**
  113418. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113419. */
  113420. depthOfField: DepthOfFieldEffect;
  113421. /**
  113422. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113423. */
  113424. fxaa: FxaaPostProcess;
  113425. /**
  113426. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113427. */
  113428. imageProcessing: ImageProcessingPostProcess;
  113429. /**
  113430. * Chromatic aberration post process which will shift rgb colors in the image
  113431. */
  113432. chromaticAberration: ChromaticAberrationPostProcess;
  113433. private _chromaticAberrationEffect;
  113434. /**
  113435. * Grain post process which add noise to the image
  113436. */
  113437. grain: GrainPostProcess;
  113438. private _grainEffect;
  113439. /**
  113440. * Glow post process which adds a glow to emissive areas of the image
  113441. */
  113442. private _glowLayer;
  113443. /**
  113444. * Animations which can be used to tweak settings over a period of time
  113445. */
  113446. animations: Animation[];
  113447. private _imageProcessingConfigurationObserver;
  113448. private _sharpenEnabled;
  113449. private _bloomEnabled;
  113450. private _depthOfFieldEnabled;
  113451. private _depthOfFieldBlurLevel;
  113452. private _fxaaEnabled;
  113453. private _imageProcessingEnabled;
  113454. private _defaultPipelineTextureType;
  113455. private _bloomScale;
  113456. private _chromaticAberrationEnabled;
  113457. private _grainEnabled;
  113458. private _buildAllowed;
  113459. /**
  113460. * Gets active scene
  113461. */
  113462. readonly scene: Scene;
  113463. /**
  113464. * Enable or disable the sharpen process from the pipeline
  113465. */
  113466. sharpenEnabled: boolean;
  113467. private _resizeObserver;
  113468. private _hardwareScaleLevel;
  113469. private _bloomKernel;
  113470. /**
  113471. * Specifies the size of the bloom blur kernel, relative to the final output size
  113472. */
  113473. bloomKernel: number;
  113474. /**
  113475. * Specifies the weight of the bloom in the final rendering
  113476. */
  113477. private _bloomWeight;
  113478. /**
  113479. * Specifies the luma threshold for the area that will be blurred by the bloom
  113480. */
  113481. private _bloomThreshold;
  113482. private _hdr;
  113483. /**
  113484. * The strength of the bloom.
  113485. */
  113486. bloomWeight: number;
  113487. /**
  113488. * The strength of the bloom.
  113489. */
  113490. bloomThreshold: number;
  113491. /**
  113492. * The scale of the bloom, lower value will provide better performance.
  113493. */
  113494. bloomScale: number;
  113495. /**
  113496. * Enable or disable the bloom from the pipeline
  113497. */
  113498. bloomEnabled: boolean;
  113499. private _rebuildBloom;
  113500. /**
  113501. * If the depth of field is enabled.
  113502. */
  113503. depthOfFieldEnabled: boolean;
  113504. /**
  113505. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113506. */
  113507. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113508. /**
  113509. * If the anti aliasing is enabled.
  113510. */
  113511. fxaaEnabled: boolean;
  113512. private _samples;
  113513. /**
  113514. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113515. */
  113516. samples: number;
  113517. /**
  113518. * If image processing is enabled.
  113519. */
  113520. imageProcessingEnabled: boolean;
  113521. /**
  113522. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113523. */
  113524. glowLayerEnabled: boolean;
  113525. /**
  113526. * Enable or disable the chromaticAberration process from the pipeline
  113527. */
  113528. chromaticAberrationEnabled: boolean;
  113529. /**
  113530. * Enable or disable the grain process from the pipeline
  113531. */
  113532. grainEnabled: boolean;
  113533. /**
  113534. * @constructor
  113535. * @param name - The rendering pipeline name (default: "")
  113536. * @param hdr - If high dynamic range textures should be used (default: true)
  113537. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113538. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113539. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113540. */
  113541. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113542. /**
  113543. * Get the class name
  113544. * @returns "DefaultRenderingPipeline"
  113545. */
  113546. getClassName(): string;
  113547. /**
  113548. * Force the compilation of the entire pipeline.
  113549. */
  113550. prepare(): void;
  113551. private _hasCleared;
  113552. private _prevPostProcess;
  113553. private _prevPrevPostProcess;
  113554. private _setAutoClearAndTextureSharing;
  113555. private _depthOfFieldSceneObserver;
  113556. private _buildPipeline;
  113557. private _disposePostProcesses;
  113558. /**
  113559. * Adds a camera to the pipeline
  113560. * @param camera the camera to be added
  113561. */
  113562. addCamera(camera: Camera): void;
  113563. /**
  113564. * Removes a camera from the pipeline
  113565. * @param camera the camera to remove
  113566. */
  113567. removeCamera(camera: Camera): void;
  113568. /**
  113569. * Dispose of the pipeline and stop all post processes
  113570. */
  113571. dispose(): void;
  113572. /**
  113573. * Serialize the rendering pipeline (Used when exporting)
  113574. * @returns the serialized object
  113575. */
  113576. serialize(): any;
  113577. /**
  113578. * Parse the serialized pipeline
  113579. * @param source Source pipeline.
  113580. * @param scene The scene to load the pipeline to.
  113581. * @param rootUrl The URL of the serialized pipeline.
  113582. * @returns An instantiated pipeline from the serialized object.
  113583. */
  113584. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113585. }
  113586. }
  113587. declare module BABYLON {
  113588. /** @hidden */
  113589. export var lensHighlightsPixelShader: {
  113590. name: string;
  113591. shader: string;
  113592. };
  113593. }
  113594. declare module BABYLON {
  113595. /** @hidden */
  113596. export var depthOfFieldPixelShader: {
  113597. name: string;
  113598. shader: string;
  113599. };
  113600. }
  113601. declare module BABYLON {
  113602. /**
  113603. * BABYLON.JS Chromatic Aberration GLSL Shader
  113604. * Author: Olivier Guyot
  113605. * Separates very slightly R, G and B colors on the edges of the screen
  113606. * Inspired by Francois Tarlier & Martins Upitis
  113607. */
  113608. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113609. /**
  113610. * @ignore
  113611. * The chromatic aberration PostProcess id in the pipeline
  113612. */
  113613. LensChromaticAberrationEffect: string;
  113614. /**
  113615. * @ignore
  113616. * The highlights enhancing PostProcess id in the pipeline
  113617. */
  113618. HighlightsEnhancingEffect: string;
  113619. /**
  113620. * @ignore
  113621. * The depth-of-field PostProcess id in the pipeline
  113622. */
  113623. LensDepthOfFieldEffect: string;
  113624. private _scene;
  113625. private _depthTexture;
  113626. private _grainTexture;
  113627. private _chromaticAberrationPostProcess;
  113628. private _highlightsPostProcess;
  113629. private _depthOfFieldPostProcess;
  113630. private _edgeBlur;
  113631. private _grainAmount;
  113632. private _chromaticAberration;
  113633. private _distortion;
  113634. private _highlightsGain;
  113635. private _highlightsThreshold;
  113636. private _dofDistance;
  113637. private _dofAperture;
  113638. private _dofDarken;
  113639. private _dofPentagon;
  113640. private _blurNoise;
  113641. /**
  113642. * @constructor
  113643. *
  113644. * Effect parameters are as follow:
  113645. * {
  113646. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113647. * edge_blur: number; // from 0 to x (1 for realism)
  113648. * distortion: number; // from 0 to x (1 for realism)
  113649. * grain_amount: number; // from 0 to 1
  113650. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113651. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113652. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113653. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113654. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113655. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113656. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113657. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113658. * }
  113659. * Note: if an effect parameter is unset, effect is disabled
  113660. *
  113661. * @param name The rendering pipeline name
  113662. * @param parameters - An object containing all parameters (see above)
  113663. * @param scene The scene linked to this pipeline
  113664. * @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)
  113665. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113666. */
  113667. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113668. /**
  113669. * Get the class name
  113670. * @returns "LensRenderingPipeline"
  113671. */
  113672. getClassName(): string;
  113673. /**
  113674. * Gets associated scene
  113675. */
  113676. readonly scene: Scene;
  113677. /**
  113678. * Gets or sets the edge blur
  113679. */
  113680. edgeBlur: number;
  113681. /**
  113682. * Gets or sets the grain amount
  113683. */
  113684. grainAmount: number;
  113685. /**
  113686. * Gets or sets the chromatic aberration amount
  113687. */
  113688. chromaticAberration: number;
  113689. /**
  113690. * Gets or sets the depth of field aperture
  113691. */
  113692. dofAperture: number;
  113693. /**
  113694. * Gets or sets the edge distortion
  113695. */
  113696. edgeDistortion: number;
  113697. /**
  113698. * Gets or sets the depth of field distortion
  113699. */
  113700. dofDistortion: number;
  113701. /**
  113702. * Gets or sets the darken out of focus amount
  113703. */
  113704. darkenOutOfFocus: number;
  113705. /**
  113706. * Gets or sets a boolean indicating if blur noise is enabled
  113707. */
  113708. blurNoise: boolean;
  113709. /**
  113710. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113711. */
  113712. pentagonBokeh: boolean;
  113713. /**
  113714. * Gets or sets the highlight grain amount
  113715. */
  113716. highlightsGain: number;
  113717. /**
  113718. * Gets or sets the highlight threshold
  113719. */
  113720. highlightsThreshold: number;
  113721. /**
  113722. * Sets the amount of blur at the edges
  113723. * @param amount blur amount
  113724. */
  113725. setEdgeBlur(amount: number): void;
  113726. /**
  113727. * Sets edge blur to 0
  113728. */
  113729. disableEdgeBlur(): void;
  113730. /**
  113731. * Sets the amout of grain
  113732. * @param amount Amount of grain
  113733. */
  113734. setGrainAmount(amount: number): void;
  113735. /**
  113736. * Set grain amount to 0
  113737. */
  113738. disableGrain(): void;
  113739. /**
  113740. * Sets the chromatic aberration amount
  113741. * @param amount amount of chromatic aberration
  113742. */
  113743. setChromaticAberration(amount: number): void;
  113744. /**
  113745. * Sets chromatic aberration amount to 0
  113746. */
  113747. disableChromaticAberration(): void;
  113748. /**
  113749. * Sets the EdgeDistortion amount
  113750. * @param amount amount of EdgeDistortion
  113751. */
  113752. setEdgeDistortion(amount: number): void;
  113753. /**
  113754. * Sets edge distortion to 0
  113755. */
  113756. disableEdgeDistortion(): void;
  113757. /**
  113758. * Sets the FocusDistance amount
  113759. * @param amount amount of FocusDistance
  113760. */
  113761. setFocusDistance(amount: number): void;
  113762. /**
  113763. * Disables depth of field
  113764. */
  113765. disableDepthOfField(): void;
  113766. /**
  113767. * Sets the Aperture amount
  113768. * @param amount amount of Aperture
  113769. */
  113770. setAperture(amount: number): void;
  113771. /**
  113772. * Sets the DarkenOutOfFocus amount
  113773. * @param amount amount of DarkenOutOfFocus
  113774. */
  113775. setDarkenOutOfFocus(amount: number): void;
  113776. private _pentagonBokehIsEnabled;
  113777. /**
  113778. * Creates a pentagon bokeh effect
  113779. */
  113780. enablePentagonBokeh(): void;
  113781. /**
  113782. * Disables the pentagon bokeh effect
  113783. */
  113784. disablePentagonBokeh(): void;
  113785. /**
  113786. * Enables noise blur
  113787. */
  113788. enableNoiseBlur(): void;
  113789. /**
  113790. * Disables noise blur
  113791. */
  113792. disableNoiseBlur(): void;
  113793. /**
  113794. * Sets the HighlightsGain amount
  113795. * @param amount amount of HighlightsGain
  113796. */
  113797. setHighlightsGain(amount: number): void;
  113798. /**
  113799. * Sets the HighlightsThreshold amount
  113800. * @param amount amount of HighlightsThreshold
  113801. */
  113802. setHighlightsThreshold(amount: number): void;
  113803. /**
  113804. * Disables highlights
  113805. */
  113806. disableHighlights(): void;
  113807. /**
  113808. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113809. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113810. */
  113811. dispose(disableDepthRender?: boolean): void;
  113812. private _createChromaticAberrationPostProcess;
  113813. private _createHighlightsPostProcess;
  113814. private _createDepthOfFieldPostProcess;
  113815. private _createGrainTexture;
  113816. }
  113817. }
  113818. declare module BABYLON {
  113819. /** @hidden */
  113820. export var ssao2PixelShader: {
  113821. name: string;
  113822. shader: string;
  113823. };
  113824. }
  113825. declare module BABYLON {
  113826. /** @hidden */
  113827. export var ssaoCombinePixelShader: {
  113828. name: string;
  113829. shader: string;
  113830. };
  113831. }
  113832. declare module BABYLON {
  113833. /**
  113834. * Render pipeline to produce ssao effect
  113835. */
  113836. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113837. /**
  113838. * @ignore
  113839. * The PassPostProcess id in the pipeline that contains the original scene color
  113840. */
  113841. SSAOOriginalSceneColorEffect: string;
  113842. /**
  113843. * @ignore
  113844. * The SSAO PostProcess id in the pipeline
  113845. */
  113846. SSAORenderEffect: string;
  113847. /**
  113848. * @ignore
  113849. * The horizontal blur PostProcess id in the pipeline
  113850. */
  113851. SSAOBlurHRenderEffect: string;
  113852. /**
  113853. * @ignore
  113854. * The vertical blur PostProcess id in the pipeline
  113855. */
  113856. SSAOBlurVRenderEffect: string;
  113857. /**
  113858. * @ignore
  113859. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113860. */
  113861. SSAOCombineRenderEffect: string;
  113862. /**
  113863. * The output strength of the SSAO post-process. Default value is 1.0.
  113864. */
  113865. totalStrength: number;
  113866. /**
  113867. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113868. */
  113869. maxZ: number;
  113870. /**
  113871. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113872. */
  113873. minZAspect: number;
  113874. private _samples;
  113875. /**
  113876. * Number of samples used for the SSAO calculations. Default value is 8
  113877. */
  113878. samples: number;
  113879. private _textureSamples;
  113880. /**
  113881. * Number of samples to use for antialiasing
  113882. */
  113883. textureSamples: number;
  113884. /**
  113885. * Ratio object used for SSAO ratio and blur ratio
  113886. */
  113887. private _ratio;
  113888. /**
  113889. * Dynamically generated sphere sampler.
  113890. */
  113891. private _sampleSphere;
  113892. /**
  113893. * Blur filter offsets
  113894. */
  113895. private _samplerOffsets;
  113896. private _expensiveBlur;
  113897. /**
  113898. * If bilateral blur should be used
  113899. */
  113900. expensiveBlur: boolean;
  113901. /**
  113902. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113903. */
  113904. radius: number;
  113905. /**
  113906. * The base color of the SSAO post-process
  113907. * The final result is "base + ssao" between [0, 1]
  113908. */
  113909. base: number;
  113910. /**
  113911. * Support test.
  113912. */
  113913. static readonly IsSupported: boolean;
  113914. private _scene;
  113915. private _depthTexture;
  113916. private _normalTexture;
  113917. private _randomTexture;
  113918. private _originalColorPostProcess;
  113919. private _ssaoPostProcess;
  113920. private _blurHPostProcess;
  113921. private _blurVPostProcess;
  113922. private _ssaoCombinePostProcess;
  113923. private _firstUpdate;
  113924. /**
  113925. * Gets active scene
  113926. */
  113927. readonly scene: Scene;
  113928. /**
  113929. * @constructor
  113930. * @param name The rendering pipeline name
  113931. * @param scene The scene linked to this pipeline
  113932. * @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 }
  113933. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113934. */
  113935. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113936. /**
  113937. * Get the class name
  113938. * @returns "SSAO2RenderingPipeline"
  113939. */
  113940. getClassName(): string;
  113941. /**
  113942. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113943. */
  113944. dispose(disableGeometryBufferRenderer?: boolean): void;
  113945. private _createBlurPostProcess;
  113946. /** @hidden */
  113947. _rebuild(): void;
  113948. private _bits;
  113949. private _radicalInverse_VdC;
  113950. private _hammersley;
  113951. private _hemisphereSample_uniform;
  113952. private _generateHemisphere;
  113953. private _createSSAOPostProcess;
  113954. private _createSSAOCombinePostProcess;
  113955. private _createRandomTexture;
  113956. /**
  113957. * Serialize the rendering pipeline (Used when exporting)
  113958. * @returns the serialized object
  113959. */
  113960. serialize(): any;
  113961. /**
  113962. * Parse the serialized pipeline
  113963. * @param source Source pipeline.
  113964. * @param scene The scene to load the pipeline to.
  113965. * @param rootUrl The URL of the serialized pipeline.
  113966. * @returns An instantiated pipeline from the serialized object.
  113967. */
  113968. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113969. }
  113970. }
  113971. declare module BABYLON {
  113972. /** @hidden */
  113973. export var ssaoPixelShader: {
  113974. name: string;
  113975. shader: string;
  113976. };
  113977. }
  113978. declare module BABYLON {
  113979. /**
  113980. * Render pipeline to produce ssao effect
  113981. */
  113982. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113983. /**
  113984. * @ignore
  113985. * The PassPostProcess id in the pipeline that contains the original scene color
  113986. */
  113987. SSAOOriginalSceneColorEffect: string;
  113988. /**
  113989. * @ignore
  113990. * The SSAO PostProcess id in the pipeline
  113991. */
  113992. SSAORenderEffect: string;
  113993. /**
  113994. * @ignore
  113995. * The horizontal blur PostProcess id in the pipeline
  113996. */
  113997. SSAOBlurHRenderEffect: string;
  113998. /**
  113999. * @ignore
  114000. * The vertical blur PostProcess id in the pipeline
  114001. */
  114002. SSAOBlurVRenderEffect: string;
  114003. /**
  114004. * @ignore
  114005. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114006. */
  114007. SSAOCombineRenderEffect: string;
  114008. /**
  114009. * The output strength of the SSAO post-process. Default value is 1.0.
  114010. */
  114011. totalStrength: number;
  114012. /**
  114013. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114014. */
  114015. radius: number;
  114016. /**
  114017. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114018. * Must not be equal to fallOff and superior to fallOff.
  114019. * Default value is 0.0075
  114020. */
  114021. area: number;
  114022. /**
  114023. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114024. * Must not be equal to area and inferior to area.
  114025. * Default value is 0.000001
  114026. */
  114027. fallOff: number;
  114028. /**
  114029. * The base color of the SSAO post-process
  114030. * The final result is "base + ssao" between [0, 1]
  114031. */
  114032. base: number;
  114033. private _scene;
  114034. private _depthTexture;
  114035. private _randomTexture;
  114036. private _originalColorPostProcess;
  114037. private _ssaoPostProcess;
  114038. private _blurHPostProcess;
  114039. private _blurVPostProcess;
  114040. private _ssaoCombinePostProcess;
  114041. private _firstUpdate;
  114042. /**
  114043. * Gets active scene
  114044. */
  114045. readonly scene: Scene;
  114046. /**
  114047. * @constructor
  114048. * @param name - The rendering pipeline name
  114049. * @param scene - The scene linked to this pipeline
  114050. * @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 }
  114051. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114052. */
  114053. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114054. /**
  114055. * Get the class name
  114056. * @returns "SSAORenderingPipeline"
  114057. */
  114058. getClassName(): string;
  114059. /**
  114060. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114061. */
  114062. dispose(disableDepthRender?: boolean): void;
  114063. private _createBlurPostProcess;
  114064. /** @hidden */
  114065. _rebuild(): void;
  114066. private _createSSAOPostProcess;
  114067. private _createSSAOCombinePostProcess;
  114068. private _createRandomTexture;
  114069. }
  114070. }
  114071. declare module BABYLON {
  114072. /** @hidden */
  114073. export var standardPixelShader: {
  114074. name: string;
  114075. shader: string;
  114076. };
  114077. }
  114078. declare module BABYLON {
  114079. /**
  114080. * Standard rendering pipeline
  114081. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114082. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114083. */
  114084. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114085. /**
  114086. * Public members
  114087. */
  114088. /**
  114089. * Post-process which contains the original scene color before the pipeline applies all the effects
  114090. */
  114091. originalPostProcess: Nullable<PostProcess>;
  114092. /**
  114093. * Post-process used to down scale an image x4
  114094. */
  114095. downSampleX4PostProcess: Nullable<PostProcess>;
  114096. /**
  114097. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114098. */
  114099. brightPassPostProcess: Nullable<PostProcess>;
  114100. /**
  114101. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114102. */
  114103. blurHPostProcesses: PostProcess[];
  114104. /**
  114105. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114106. */
  114107. blurVPostProcesses: PostProcess[];
  114108. /**
  114109. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114110. */
  114111. textureAdderPostProcess: Nullable<PostProcess>;
  114112. /**
  114113. * Post-process used to create volumetric lighting effect
  114114. */
  114115. volumetricLightPostProcess: Nullable<PostProcess>;
  114116. /**
  114117. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114118. */
  114119. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114120. /**
  114121. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114122. */
  114123. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114124. /**
  114125. * Post-process used to merge the volumetric light effect and the real scene color
  114126. */
  114127. volumetricLightMergePostProces: Nullable<PostProcess>;
  114128. /**
  114129. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114130. */
  114131. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114132. /**
  114133. * Base post-process used to calculate the average luminance of the final image for HDR
  114134. */
  114135. luminancePostProcess: Nullable<PostProcess>;
  114136. /**
  114137. * Post-processes used to create down sample post-processes in order to get
  114138. * the average luminance of the final image for HDR
  114139. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114140. */
  114141. luminanceDownSamplePostProcesses: PostProcess[];
  114142. /**
  114143. * Post-process used to create a HDR effect (light adaptation)
  114144. */
  114145. hdrPostProcess: Nullable<PostProcess>;
  114146. /**
  114147. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114148. */
  114149. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114150. /**
  114151. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114152. */
  114153. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114154. /**
  114155. * Post-process used to merge the final HDR post-process and the real scene color
  114156. */
  114157. hdrFinalPostProcess: Nullable<PostProcess>;
  114158. /**
  114159. * Post-process used to create a lens flare effect
  114160. */
  114161. lensFlarePostProcess: Nullable<PostProcess>;
  114162. /**
  114163. * Post-process that merges the result of the lens flare post-process and the real scene color
  114164. */
  114165. lensFlareComposePostProcess: Nullable<PostProcess>;
  114166. /**
  114167. * Post-process used to create a motion blur effect
  114168. */
  114169. motionBlurPostProcess: Nullable<PostProcess>;
  114170. /**
  114171. * Post-process used to create a depth of field effect
  114172. */
  114173. depthOfFieldPostProcess: Nullable<PostProcess>;
  114174. /**
  114175. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114176. */
  114177. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114178. /**
  114179. * Represents the brightness threshold in order to configure the illuminated surfaces
  114180. */
  114181. brightThreshold: number;
  114182. /**
  114183. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114184. */
  114185. blurWidth: number;
  114186. /**
  114187. * Sets if the blur for highlighted surfaces must be only horizontal
  114188. */
  114189. horizontalBlur: boolean;
  114190. /**
  114191. * Gets the overall exposure used by the pipeline
  114192. */
  114193. /**
  114194. * Sets the overall exposure used by the pipeline
  114195. */
  114196. exposure: number;
  114197. /**
  114198. * Texture used typically to simulate "dirty" on camera lens
  114199. */
  114200. lensTexture: Nullable<Texture>;
  114201. /**
  114202. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114203. */
  114204. volumetricLightCoefficient: number;
  114205. /**
  114206. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114207. */
  114208. volumetricLightPower: number;
  114209. /**
  114210. * Used the set the blur intensity to smooth the volumetric lights
  114211. */
  114212. volumetricLightBlurScale: number;
  114213. /**
  114214. * Light (spot or directional) used to generate the volumetric lights rays
  114215. * The source light must have a shadow generate so the pipeline can get its
  114216. * depth map
  114217. */
  114218. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114219. /**
  114220. * For eye adaptation, represents the minimum luminance the eye can see
  114221. */
  114222. hdrMinimumLuminance: number;
  114223. /**
  114224. * For eye adaptation, represents the decrease luminance speed
  114225. */
  114226. hdrDecreaseRate: number;
  114227. /**
  114228. * For eye adaptation, represents the increase luminance speed
  114229. */
  114230. hdrIncreaseRate: number;
  114231. /**
  114232. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114233. */
  114234. /**
  114235. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114236. */
  114237. hdrAutoExposure: boolean;
  114238. /**
  114239. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114240. */
  114241. lensColorTexture: Nullable<Texture>;
  114242. /**
  114243. * The overall strengh for the lens flare effect
  114244. */
  114245. lensFlareStrength: number;
  114246. /**
  114247. * Dispersion coefficient for lens flare ghosts
  114248. */
  114249. lensFlareGhostDispersal: number;
  114250. /**
  114251. * Main lens flare halo width
  114252. */
  114253. lensFlareHaloWidth: number;
  114254. /**
  114255. * Based on the lens distortion effect, defines how much the lens flare result
  114256. * is distorted
  114257. */
  114258. lensFlareDistortionStrength: number;
  114259. /**
  114260. * Lens star texture must be used to simulate rays on the flares and is available
  114261. * in the documentation
  114262. */
  114263. lensStarTexture: Nullable<Texture>;
  114264. /**
  114265. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114266. * flare effect by taking account of the dirt texture
  114267. */
  114268. lensFlareDirtTexture: Nullable<Texture>;
  114269. /**
  114270. * Represents the focal length for the depth of field effect
  114271. */
  114272. depthOfFieldDistance: number;
  114273. /**
  114274. * Represents the blur intensity for the blurred part of the depth of field effect
  114275. */
  114276. depthOfFieldBlurWidth: number;
  114277. /**
  114278. * For motion blur, defines how much the image is blurred by the movement
  114279. */
  114280. motionStrength: number;
  114281. /**
  114282. * List of animations for the pipeline (IAnimatable implementation)
  114283. */
  114284. animations: Animation[];
  114285. /**
  114286. * Private members
  114287. */
  114288. private _scene;
  114289. private _currentDepthOfFieldSource;
  114290. private _basePostProcess;
  114291. private _fixedExposure;
  114292. private _currentExposure;
  114293. private _hdrAutoExposure;
  114294. private _hdrCurrentLuminance;
  114295. private _floatTextureType;
  114296. private _ratio;
  114297. private _bloomEnabled;
  114298. private _depthOfFieldEnabled;
  114299. private _vlsEnabled;
  114300. private _lensFlareEnabled;
  114301. private _hdrEnabled;
  114302. private _motionBlurEnabled;
  114303. private _fxaaEnabled;
  114304. private _motionBlurSamples;
  114305. private _volumetricLightStepsCount;
  114306. private _samples;
  114307. /**
  114308. * @ignore
  114309. * Specifies if the bloom pipeline is enabled
  114310. */
  114311. BloomEnabled: boolean;
  114312. /**
  114313. * @ignore
  114314. * Specifies if the depth of field pipeline is enabed
  114315. */
  114316. DepthOfFieldEnabled: boolean;
  114317. /**
  114318. * @ignore
  114319. * Specifies if the lens flare pipeline is enabed
  114320. */
  114321. LensFlareEnabled: boolean;
  114322. /**
  114323. * @ignore
  114324. * Specifies if the HDR pipeline is enabled
  114325. */
  114326. HDREnabled: boolean;
  114327. /**
  114328. * @ignore
  114329. * Specifies if the volumetric lights scattering effect is enabled
  114330. */
  114331. VLSEnabled: boolean;
  114332. /**
  114333. * @ignore
  114334. * Specifies if the motion blur effect is enabled
  114335. */
  114336. MotionBlurEnabled: boolean;
  114337. /**
  114338. * Specifies if anti-aliasing is enabled
  114339. */
  114340. fxaaEnabled: boolean;
  114341. /**
  114342. * Specifies the number of steps used to calculate the volumetric lights
  114343. * Typically in interval [50, 200]
  114344. */
  114345. volumetricLightStepsCount: number;
  114346. /**
  114347. * Specifies the number of samples used for the motion blur effect
  114348. * Typically in interval [16, 64]
  114349. */
  114350. motionBlurSamples: number;
  114351. /**
  114352. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114353. */
  114354. samples: number;
  114355. /**
  114356. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114357. * @constructor
  114358. * @param name The rendering pipeline name
  114359. * @param scene The scene linked to this pipeline
  114360. * @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)
  114361. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114362. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114363. */
  114364. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114365. private _buildPipeline;
  114366. private _createDownSampleX4PostProcess;
  114367. private _createBrightPassPostProcess;
  114368. private _createBlurPostProcesses;
  114369. private _createTextureAdderPostProcess;
  114370. private _createVolumetricLightPostProcess;
  114371. private _createLuminancePostProcesses;
  114372. private _createHdrPostProcess;
  114373. private _createLensFlarePostProcess;
  114374. private _createDepthOfFieldPostProcess;
  114375. private _createMotionBlurPostProcess;
  114376. private _getDepthTexture;
  114377. private _disposePostProcesses;
  114378. /**
  114379. * Dispose of the pipeline and stop all post processes
  114380. */
  114381. dispose(): void;
  114382. /**
  114383. * Serialize the rendering pipeline (Used when exporting)
  114384. * @returns the serialized object
  114385. */
  114386. serialize(): any;
  114387. /**
  114388. * Parse the serialized pipeline
  114389. * @param source Source pipeline.
  114390. * @param scene The scene to load the pipeline to.
  114391. * @param rootUrl The URL of the serialized pipeline.
  114392. * @returns An instantiated pipeline from the serialized object.
  114393. */
  114394. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114395. /**
  114396. * Luminance steps
  114397. */
  114398. static LuminanceSteps: number;
  114399. }
  114400. }
  114401. declare module BABYLON {
  114402. /** @hidden */
  114403. export var tonemapPixelShader: {
  114404. name: string;
  114405. shader: string;
  114406. };
  114407. }
  114408. declare module BABYLON {
  114409. /** Defines operator used for tonemapping */
  114410. export enum TonemappingOperator {
  114411. /** Hable */
  114412. Hable = 0,
  114413. /** Reinhard */
  114414. Reinhard = 1,
  114415. /** HejiDawson */
  114416. HejiDawson = 2,
  114417. /** Photographic */
  114418. Photographic = 3
  114419. }
  114420. /**
  114421. * Defines a post process to apply tone mapping
  114422. */
  114423. export class TonemapPostProcess extends PostProcess {
  114424. private _operator;
  114425. /** Defines the required exposure adjustement */
  114426. exposureAdjustment: number;
  114427. /**
  114428. * Creates a new TonemapPostProcess
  114429. * @param name defines the name of the postprocess
  114430. * @param _operator defines the operator to use
  114431. * @param exposureAdjustment defines the required exposure adjustement
  114432. * @param camera defines the camera to use (can be null)
  114433. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114434. * @param engine defines the hosting engine (can be ignore if camera is set)
  114435. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114436. */
  114437. constructor(name: string, _operator: TonemappingOperator,
  114438. /** Defines the required exposure adjustement */
  114439. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114440. }
  114441. }
  114442. declare module BABYLON {
  114443. /** @hidden */
  114444. export var depthVertexShader: {
  114445. name: string;
  114446. shader: string;
  114447. };
  114448. }
  114449. declare module BABYLON {
  114450. /** @hidden */
  114451. export var volumetricLightScatteringPixelShader: {
  114452. name: string;
  114453. shader: string;
  114454. };
  114455. }
  114456. declare module BABYLON {
  114457. /** @hidden */
  114458. export var volumetricLightScatteringPassPixelShader: {
  114459. name: string;
  114460. shader: string;
  114461. };
  114462. }
  114463. declare module BABYLON {
  114464. /**
  114465. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114466. */
  114467. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114468. private _volumetricLightScatteringPass;
  114469. private _volumetricLightScatteringRTT;
  114470. private _viewPort;
  114471. private _screenCoordinates;
  114472. private _cachedDefines;
  114473. /**
  114474. * If not undefined, the mesh position is computed from the attached node position
  114475. */
  114476. attachedNode: {
  114477. position: Vector3;
  114478. };
  114479. /**
  114480. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114481. */
  114482. customMeshPosition: Vector3;
  114483. /**
  114484. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114485. */
  114486. useCustomMeshPosition: boolean;
  114487. /**
  114488. * If the post-process should inverse the light scattering direction
  114489. */
  114490. invert: boolean;
  114491. /**
  114492. * The internal mesh used by the post-process
  114493. */
  114494. mesh: Mesh;
  114495. /**
  114496. * @hidden
  114497. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114498. */
  114499. useDiffuseColor: boolean;
  114500. /**
  114501. * Array containing the excluded meshes not rendered in the internal pass
  114502. */
  114503. excludedMeshes: AbstractMesh[];
  114504. /**
  114505. * Controls the overall intensity of the post-process
  114506. */
  114507. exposure: number;
  114508. /**
  114509. * Dissipates each sample's contribution in range [0, 1]
  114510. */
  114511. decay: number;
  114512. /**
  114513. * Controls the overall intensity of each sample
  114514. */
  114515. weight: number;
  114516. /**
  114517. * Controls the density of each sample
  114518. */
  114519. density: number;
  114520. /**
  114521. * @constructor
  114522. * @param name The post-process name
  114523. * @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)
  114524. * @param camera The camera that the post-process will be attached to
  114525. * @param mesh The mesh used to create the light scattering
  114526. * @param samples The post-process quality, default 100
  114527. * @param samplingModeThe post-process filtering mode
  114528. * @param engine The babylon engine
  114529. * @param reusable If the post-process is reusable
  114530. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114531. */
  114532. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114533. /**
  114534. * Returns the string "VolumetricLightScatteringPostProcess"
  114535. * @returns "VolumetricLightScatteringPostProcess"
  114536. */
  114537. getClassName(): string;
  114538. private _isReady;
  114539. /**
  114540. * Sets the new light position for light scattering effect
  114541. * @param position The new custom light position
  114542. */
  114543. setCustomMeshPosition(position: Vector3): void;
  114544. /**
  114545. * Returns the light position for light scattering effect
  114546. * @return Vector3 The custom light position
  114547. */
  114548. getCustomMeshPosition(): Vector3;
  114549. /**
  114550. * Disposes the internal assets and detaches the post-process from the camera
  114551. */
  114552. dispose(camera: Camera): void;
  114553. /**
  114554. * Returns the render target texture used by the post-process
  114555. * @return the render target texture used by the post-process
  114556. */
  114557. getPass(): RenderTargetTexture;
  114558. private _meshExcluded;
  114559. private _createPass;
  114560. private _updateMeshScreenCoordinates;
  114561. /**
  114562. * Creates a default mesh for the Volumeric Light Scattering post-process
  114563. * @param name The mesh name
  114564. * @param scene The scene where to create the mesh
  114565. * @return the default mesh
  114566. */
  114567. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114568. }
  114569. }
  114570. declare module BABYLON {
  114571. interface Scene {
  114572. /** @hidden (Backing field) */
  114573. _boundingBoxRenderer: BoundingBoxRenderer;
  114574. /** @hidden (Backing field) */
  114575. _forceShowBoundingBoxes: boolean;
  114576. /**
  114577. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114578. */
  114579. forceShowBoundingBoxes: boolean;
  114580. /**
  114581. * Gets the bounding box renderer associated with the scene
  114582. * @returns a BoundingBoxRenderer
  114583. */
  114584. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114585. }
  114586. interface AbstractMesh {
  114587. /** @hidden (Backing field) */
  114588. _showBoundingBox: boolean;
  114589. /**
  114590. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114591. */
  114592. showBoundingBox: boolean;
  114593. }
  114594. /**
  114595. * Component responsible of rendering the bounding box of the meshes in a scene.
  114596. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114597. */
  114598. export class BoundingBoxRenderer implements ISceneComponent {
  114599. /**
  114600. * The component name helpfull to identify the component in the list of scene components.
  114601. */
  114602. readonly name: string;
  114603. /**
  114604. * The scene the component belongs to.
  114605. */
  114606. scene: Scene;
  114607. /**
  114608. * Color of the bounding box lines placed in front of an object
  114609. */
  114610. frontColor: Color3;
  114611. /**
  114612. * Color of the bounding box lines placed behind an object
  114613. */
  114614. backColor: Color3;
  114615. /**
  114616. * Defines if the renderer should show the back lines or not
  114617. */
  114618. showBackLines: boolean;
  114619. /**
  114620. * @hidden
  114621. */
  114622. renderList: SmartArray<BoundingBox>;
  114623. private _colorShader;
  114624. private _vertexBuffers;
  114625. private _indexBuffer;
  114626. /**
  114627. * Instantiates a new bounding box renderer in a scene.
  114628. * @param scene the scene the renderer renders in
  114629. */
  114630. constructor(scene: Scene);
  114631. /**
  114632. * Registers the component in a given scene
  114633. */
  114634. register(): void;
  114635. private _evaluateSubMesh;
  114636. private _activeMesh;
  114637. private _prepareRessources;
  114638. private _createIndexBuffer;
  114639. /**
  114640. * Rebuilds the elements related to this component in case of
  114641. * context lost for instance.
  114642. */
  114643. rebuild(): void;
  114644. /**
  114645. * @hidden
  114646. */
  114647. reset(): void;
  114648. /**
  114649. * Render the bounding boxes of a specific rendering group
  114650. * @param renderingGroupId defines the rendering group to render
  114651. */
  114652. render(renderingGroupId: number): void;
  114653. /**
  114654. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114655. * @param mesh Define the mesh to render the occlusion bounding box for
  114656. */
  114657. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114658. /**
  114659. * Dispose and release the resources attached to this renderer.
  114660. */
  114661. dispose(): void;
  114662. }
  114663. }
  114664. declare module BABYLON {
  114665. /** @hidden */
  114666. export var depthPixelShader: {
  114667. name: string;
  114668. shader: string;
  114669. };
  114670. }
  114671. declare module BABYLON {
  114672. /**
  114673. * This represents a depth renderer in Babylon.
  114674. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114675. */
  114676. export class DepthRenderer {
  114677. private _scene;
  114678. private _depthMap;
  114679. private _effect;
  114680. private _cachedDefines;
  114681. private _camera;
  114682. /**
  114683. * Specifiess that the depth renderer will only be used within
  114684. * the camera it is created for.
  114685. * This can help forcing its rendering during the camera processing.
  114686. */
  114687. useOnlyInActiveCamera: boolean;
  114688. /** @hidden */
  114689. static _SceneComponentInitialization: (scene: Scene) => void;
  114690. /**
  114691. * Instantiates a depth renderer
  114692. * @param scene The scene the renderer belongs to
  114693. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114694. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114695. */
  114696. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114697. /**
  114698. * Creates the depth rendering effect and checks if the effect is ready.
  114699. * @param subMesh The submesh to be used to render the depth map of
  114700. * @param useInstances If multiple world instances should be used
  114701. * @returns if the depth renderer is ready to render the depth map
  114702. */
  114703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114704. /**
  114705. * Gets the texture which the depth map will be written to.
  114706. * @returns The depth map texture
  114707. */
  114708. getDepthMap(): RenderTargetTexture;
  114709. /**
  114710. * Disposes of the depth renderer.
  114711. */
  114712. dispose(): void;
  114713. }
  114714. }
  114715. declare module BABYLON {
  114716. interface Scene {
  114717. /** @hidden (Backing field) */
  114718. _depthRenderer: {
  114719. [id: string]: DepthRenderer;
  114720. };
  114721. /**
  114722. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114723. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114724. * @returns the created depth renderer
  114725. */
  114726. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114727. /**
  114728. * Disables a depth renderer for a given camera
  114729. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114730. */
  114731. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114732. }
  114733. /**
  114734. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114735. * in several rendering techniques.
  114736. */
  114737. export class DepthRendererSceneComponent implements ISceneComponent {
  114738. /**
  114739. * The component name helpfull to identify the component in the list of scene components.
  114740. */
  114741. readonly name: string;
  114742. /**
  114743. * The scene the component belongs to.
  114744. */
  114745. scene: Scene;
  114746. /**
  114747. * Creates a new instance of the component for the given scene
  114748. * @param scene Defines the scene to register the component in
  114749. */
  114750. constructor(scene: Scene);
  114751. /**
  114752. * Registers the component in a given scene
  114753. */
  114754. register(): void;
  114755. /**
  114756. * Rebuilds the elements related to this component in case of
  114757. * context lost for instance.
  114758. */
  114759. rebuild(): void;
  114760. /**
  114761. * Disposes the component and the associated ressources
  114762. */
  114763. dispose(): void;
  114764. private _gatherRenderTargets;
  114765. private _gatherActiveCameraRenderTargets;
  114766. }
  114767. }
  114768. declare module BABYLON {
  114769. /** @hidden */
  114770. export var outlinePixelShader: {
  114771. name: string;
  114772. shader: string;
  114773. };
  114774. }
  114775. declare module BABYLON {
  114776. /** @hidden */
  114777. export var outlineVertexShader: {
  114778. name: string;
  114779. shader: string;
  114780. };
  114781. }
  114782. declare module BABYLON {
  114783. interface Scene {
  114784. /** @hidden */
  114785. _outlineRenderer: OutlineRenderer;
  114786. /**
  114787. * Gets the outline renderer associated with the scene
  114788. * @returns a OutlineRenderer
  114789. */
  114790. getOutlineRenderer(): OutlineRenderer;
  114791. }
  114792. interface AbstractMesh {
  114793. /** @hidden (Backing field) */
  114794. _renderOutline: boolean;
  114795. /**
  114796. * Gets or sets a boolean indicating if the outline must be rendered as well
  114797. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114798. */
  114799. renderOutline: boolean;
  114800. /** @hidden (Backing field) */
  114801. _renderOverlay: boolean;
  114802. /**
  114803. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114804. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114805. */
  114806. renderOverlay: boolean;
  114807. }
  114808. /**
  114809. * This class is responsible to draw bothe outline/overlay of meshes.
  114810. * It should not be used directly but through the available method on mesh.
  114811. */
  114812. export class OutlineRenderer implements ISceneComponent {
  114813. /**
  114814. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114815. */
  114816. private static _StencilReference;
  114817. /**
  114818. * The name of the component. Each component must have a unique name.
  114819. */
  114820. name: string;
  114821. /**
  114822. * The scene the component belongs to.
  114823. */
  114824. scene: Scene;
  114825. /**
  114826. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114827. */
  114828. zOffset: number;
  114829. private _engine;
  114830. private _effect;
  114831. private _cachedDefines;
  114832. private _savedDepthWrite;
  114833. /**
  114834. * Instantiates a new outline renderer. (There could be only one per scene).
  114835. * @param scene Defines the scene it belongs to
  114836. */
  114837. constructor(scene: Scene);
  114838. /**
  114839. * Register the component to one instance of a scene.
  114840. */
  114841. register(): void;
  114842. /**
  114843. * Rebuilds the elements related to this component in case of
  114844. * context lost for instance.
  114845. */
  114846. rebuild(): void;
  114847. /**
  114848. * Disposes the component and the associated ressources.
  114849. */
  114850. dispose(): void;
  114851. /**
  114852. * Renders the outline in the canvas.
  114853. * @param subMesh Defines the sumesh to render
  114854. * @param batch Defines the batch of meshes in case of instances
  114855. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114856. */
  114857. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114858. /**
  114859. * Returns whether or not the outline renderer is ready for a given submesh.
  114860. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114861. * @param subMesh Defines the submesh to check readyness for
  114862. * @param useInstances Defines wheter wee are trying to render instances or not
  114863. * @returns true if ready otherwise false
  114864. */
  114865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114866. private _beforeRenderingMesh;
  114867. private _afterRenderingMesh;
  114868. }
  114869. }
  114870. declare module BABYLON {
  114871. /**
  114872. * Defines the list of states available for a task inside a AssetsManager
  114873. */
  114874. export enum AssetTaskState {
  114875. /**
  114876. * Initialization
  114877. */
  114878. INIT = 0,
  114879. /**
  114880. * Running
  114881. */
  114882. RUNNING = 1,
  114883. /**
  114884. * Done
  114885. */
  114886. DONE = 2,
  114887. /**
  114888. * Error
  114889. */
  114890. ERROR = 3
  114891. }
  114892. /**
  114893. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114894. */
  114895. export abstract class AbstractAssetTask {
  114896. /**
  114897. * Task name
  114898. */ name: string;
  114899. /**
  114900. * Callback called when the task is successful
  114901. */
  114902. onSuccess: (task: any) => void;
  114903. /**
  114904. * Callback called when the task is not successful
  114905. */
  114906. onError: (task: any, message?: string, exception?: any) => void;
  114907. /**
  114908. * Creates a new AssetsManager
  114909. * @param name defines the name of the task
  114910. */
  114911. constructor(
  114912. /**
  114913. * Task name
  114914. */ name: string);
  114915. private _isCompleted;
  114916. private _taskState;
  114917. private _errorObject;
  114918. /**
  114919. * Get if the task is completed
  114920. */
  114921. readonly isCompleted: boolean;
  114922. /**
  114923. * Gets the current state of the task
  114924. */
  114925. readonly taskState: AssetTaskState;
  114926. /**
  114927. * Gets the current error object (if task is in error)
  114928. */
  114929. readonly errorObject: {
  114930. message?: string;
  114931. exception?: any;
  114932. };
  114933. /**
  114934. * Internal only
  114935. * @hidden
  114936. */
  114937. _setErrorObject(message?: string, exception?: any): void;
  114938. /**
  114939. * Execute the current task
  114940. * @param scene defines the scene where you want your assets to be loaded
  114941. * @param onSuccess is a callback called when the task is successfully executed
  114942. * @param onError is a callback called if an error occurs
  114943. */
  114944. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114945. /**
  114946. * Execute the current task
  114947. * @param scene defines the scene where you want your assets to be loaded
  114948. * @param onSuccess is a callback called when the task is successfully executed
  114949. * @param onError is a callback called if an error occurs
  114950. */
  114951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114952. /**
  114953. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114954. * This can be used with failed tasks that have the reason for failure fixed.
  114955. */
  114956. reset(): void;
  114957. private onErrorCallback;
  114958. private onDoneCallback;
  114959. }
  114960. /**
  114961. * Define the interface used by progress events raised during assets loading
  114962. */
  114963. export interface IAssetsProgressEvent {
  114964. /**
  114965. * Defines the number of remaining tasks to process
  114966. */
  114967. remainingCount: number;
  114968. /**
  114969. * Defines the total number of tasks
  114970. */
  114971. totalCount: number;
  114972. /**
  114973. * Defines the task that was just processed
  114974. */
  114975. task: AbstractAssetTask;
  114976. }
  114977. /**
  114978. * Class used to share progress information about assets loading
  114979. */
  114980. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114981. /**
  114982. * Defines the number of remaining tasks to process
  114983. */
  114984. remainingCount: number;
  114985. /**
  114986. * Defines the total number of tasks
  114987. */
  114988. totalCount: number;
  114989. /**
  114990. * Defines the task that was just processed
  114991. */
  114992. task: AbstractAssetTask;
  114993. /**
  114994. * Creates a AssetsProgressEvent
  114995. * @param remainingCount defines the number of remaining tasks to process
  114996. * @param totalCount defines the total number of tasks
  114997. * @param task defines the task that was just processed
  114998. */
  114999. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115000. }
  115001. /**
  115002. * Define a task used by AssetsManager to load meshes
  115003. */
  115004. export class MeshAssetTask extends AbstractAssetTask {
  115005. /**
  115006. * Defines the name of the task
  115007. */
  115008. name: string;
  115009. /**
  115010. * Defines the list of mesh's names you want to load
  115011. */
  115012. meshesNames: any;
  115013. /**
  115014. * Defines the root url to use as a base to load your meshes and associated resources
  115015. */
  115016. rootUrl: string;
  115017. /**
  115018. * Defines the filename of the scene to load from
  115019. */
  115020. sceneFilename: string;
  115021. /**
  115022. * Gets the list of loaded meshes
  115023. */
  115024. loadedMeshes: Array<AbstractMesh>;
  115025. /**
  115026. * Gets the list of loaded particle systems
  115027. */
  115028. loadedParticleSystems: Array<IParticleSystem>;
  115029. /**
  115030. * Gets the list of loaded skeletons
  115031. */
  115032. loadedSkeletons: Array<Skeleton>;
  115033. /**
  115034. * Gets the list of loaded animation groups
  115035. */
  115036. loadedAnimationGroups: Array<AnimationGroup>;
  115037. /**
  115038. * Callback called when the task is successful
  115039. */
  115040. onSuccess: (task: MeshAssetTask) => void;
  115041. /**
  115042. * Callback called when the task is successful
  115043. */
  115044. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115045. /**
  115046. * Creates a new MeshAssetTask
  115047. * @param name defines the name of the task
  115048. * @param meshesNames defines the list of mesh's names you want to load
  115049. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115050. * @param sceneFilename defines the filename of the scene to load from
  115051. */
  115052. constructor(
  115053. /**
  115054. * Defines the name of the task
  115055. */
  115056. name: string,
  115057. /**
  115058. * Defines the list of mesh's names you want to load
  115059. */
  115060. meshesNames: any,
  115061. /**
  115062. * Defines the root url to use as a base to load your meshes and associated resources
  115063. */
  115064. rootUrl: string,
  115065. /**
  115066. * Defines the filename of the scene to load from
  115067. */
  115068. sceneFilename: string);
  115069. /**
  115070. * Execute the current task
  115071. * @param scene defines the scene where you want your assets to be loaded
  115072. * @param onSuccess is a callback called when the task is successfully executed
  115073. * @param onError is a callback called if an error occurs
  115074. */
  115075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115076. }
  115077. /**
  115078. * Define a task used by AssetsManager to load text content
  115079. */
  115080. export class TextFileAssetTask extends AbstractAssetTask {
  115081. /**
  115082. * Defines the name of the task
  115083. */
  115084. name: string;
  115085. /**
  115086. * Defines the location of the file to load
  115087. */
  115088. url: string;
  115089. /**
  115090. * Gets the loaded text string
  115091. */
  115092. text: string;
  115093. /**
  115094. * Callback called when the task is successful
  115095. */
  115096. onSuccess: (task: TextFileAssetTask) => void;
  115097. /**
  115098. * Callback called when the task is successful
  115099. */
  115100. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115101. /**
  115102. * Creates a new TextFileAssetTask object
  115103. * @param name defines the name of the task
  115104. * @param url defines the location of the file to load
  115105. */
  115106. constructor(
  115107. /**
  115108. * Defines the name of the task
  115109. */
  115110. name: string,
  115111. /**
  115112. * Defines the location of the file to load
  115113. */
  115114. url: string);
  115115. /**
  115116. * Execute the current task
  115117. * @param scene defines the scene where you want your assets to be loaded
  115118. * @param onSuccess is a callback called when the task is successfully executed
  115119. * @param onError is a callback called if an error occurs
  115120. */
  115121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115122. }
  115123. /**
  115124. * Define a task used by AssetsManager to load binary data
  115125. */
  115126. export class BinaryFileAssetTask extends AbstractAssetTask {
  115127. /**
  115128. * Defines the name of the task
  115129. */
  115130. name: string;
  115131. /**
  115132. * Defines the location of the file to load
  115133. */
  115134. url: string;
  115135. /**
  115136. * Gets the lodaded data (as an array buffer)
  115137. */
  115138. data: ArrayBuffer;
  115139. /**
  115140. * Callback called when the task is successful
  115141. */
  115142. onSuccess: (task: BinaryFileAssetTask) => void;
  115143. /**
  115144. * Callback called when the task is successful
  115145. */
  115146. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115147. /**
  115148. * Creates a new BinaryFileAssetTask object
  115149. * @param name defines the name of the new task
  115150. * @param url defines the location of the file to load
  115151. */
  115152. constructor(
  115153. /**
  115154. * Defines the name of the task
  115155. */
  115156. name: string,
  115157. /**
  115158. * Defines the location of the file to load
  115159. */
  115160. url: string);
  115161. /**
  115162. * Execute the current task
  115163. * @param scene defines the scene where you want your assets to be loaded
  115164. * @param onSuccess is a callback called when the task is successfully executed
  115165. * @param onError is a callback called if an error occurs
  115166. */
  115167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115168. }
  115169. /**
  115170. * Define a task used by AssetsManager to load images
  115171. */
  115172. export class ImageAssetTask extends AbstractAssetTask {
  115173. /**
  115174. * Defines the name of the task
  115175. */
  115176. name: string;
  115177. /**
  115178. * Defines the location of the image to load
  115179. */
  115180. url: string;
  115181. /**
  115182. * Gets the loaded images
  115183. */
  115184. image: HTMLImageElement;
  115185. /**
  115186. * Callback called when the task is successful
  115187. */
  115188. onSuccess: (task: ImageAssetTask) => void;
  115189. /**
  115190. * Callback called when the task is successful
  115191. */
  115192. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115193. /**
  115194. * Creates a new ImageAssetTask
  115195. * @param name defines the name of the task
  115196. * @param url defines the location of the image to load
  115197. */
  115198. constructor(
  115199. /**
  115200. * Defines the name of the task
  115201. */
  115202. name: string,
  115203. /**
  115204. * Defines the location of the image to load
  115205. */
  115206. url: string);
  115207. /**
  115208. * Execute the current task
  115209. * @param scene defines the scene where you want your assets to be loaded
  115210. * @param onSuccess is a callback called when the task is successfully executed
  115211. * @param onError is a callback called if an error occurs
  115212. */
  115213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115214. }
  115215. /**
  115216. * Defines the interface used by texture loading tasks
  115217. */
  115218. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115219. /**
  115220. * Gets the loaded texture
  115221. */
  115222. texture: TEX;
  115223. }
  115224. /**
  115225. * Define a task used by AssetsManager to load 2D textures
  115226. */
  115227. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115228. /**
  115229. * Defines the name of the task
  115230. */
  115231. name: string;
  115232. /**
  115233. * Defines the location of the file to load
  115234. */
  115235. url: string;
  115236. /**
  115237. * Defines if mipmap should not be generated (default is false)
  115238. */
  115239. noMipmap?: boolean | undefined;
  115240. /**
  115241. * Defines if texture must be inverted on Y axis (default is false)
  115242. */
  115243. invertY?: boolean | undefined;
  115244. /**
  115245. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115246. */
  115247. samplingMode: number;
  115248. /**
  115249. * Gets the loaded texture
  115250. */
  115251. texture: Texture;
  115252. /**
  115253. * Callback called when the task is successful
  115254. */
  115255. onSuccess: (task: TextureAssetTask) => void;
  115256. /**
  115257. * Callback called when the task is successful
  115258. */
  115259. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115260. /**
  115261. * Creates a new TextureAssetTask object
  115262. * @param name defines the name of the task
  115263. * @param url defines the location of the file to load
  115264. * @param noMipmap defines if mipmap should not be generated (default is false)
  115265. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115266. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115267. */
  115268. constructor(
  115269. /**
  115270. * Defines the name of the task
  115271. */
  115272. name: string,
  115273. /**
  115274. * Defines the location of the file to load
  115275. */
  115276. url: string,
  115277. /**
  115278. * Defines if mipmap should not be generated (default is false)
  115279. */
  115280. noMipmap?: boolean | undefined,
  115281. /**
  115282. * Defines if texture must be inverted on Y axis (default is false)
  115283. */
  115284. invertY?: boolean | undefined,
  115285. /**
  115286. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115287. */
  115288. samplingMode?: number);
  115289. /**
  115290. * Execute the current task
  115291. * @param scene defines the scene where you want your assets to be loaded
  115292. * @param onSuccess is a callback called when the task is successfully executed
  115293. * @param onError is a callback called if an error occurs
  115294. */
  115295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115296. }
  115297. /**
  115298. * Define a task used by AssetsManager to load cube textures
  115299. */
  115300. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115301. /**
  115302. * Defines the name of the task
  115303. */
  115304. name: string;
  115305. /**
  115306. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115307. */
  115308. url: string;
  115309. /**
  115310. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115311. */
  115312. extensions?: string[] | undefined;
  115313. /**
  115314. * Defines if mipmaps should not be generated (default is false)
  115315. */
  115316. noMipmap?: boolean | undefined;
  115317. /**
  115318. * Defines the explicit list of files (undefined by default)
  115319. */
  115320. files?: string[] | undefined;
  115321. /**
  115322. * Gets the loaded texture
  115323. */
  115324. texture: CubeTexture;
  115325. /**
  115326. * Callback called when the task is successful
  115327. */
  115328. onSuccess: (task: CubeTextureAssetTask) => void;
  115329. /**
  115330. * Callback called when the task is successful
  115331. */
  115332. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115333. /**
  115334. * Creates a new CubeTextureAssetTask
  115335. * @param name defines the name of the task
  115336. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115337. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115338. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115339. * @param files defines the explicit list of files (undefined by default)
  115340. */
  115341. constructor(
  115342. /**
  115343. * Defines the name of the task
  115344. */
  115345. name: string,
  115346. /**
  115347. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115348. */
  115349. url: string,
  115350. /**
  115351. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115352. */
  115353. extensions?: string[] | undefined,
  115354. /**
  115355. * Defines if mipmaps should not be generated (default is false)
  115356. */
  115357. noMipmap?: boolean | undefined,
  115358. /**
  115359. * Defines the explicit list of files (undefined by default)
  115360. */
  115361. files?: string[] | undefined);
  115362. /**
  115363. * Execute the current task
  115364. * @param scene defines the scene where you want your assets to be loaded
  115365. * @param onSuccess is a callback called when the task is successfully executed
  115366. * @param onError is a callback called if an error occurs
  115367. */
  115368. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115369. }
  115370. /**
  115371. * Define a task used by AssetsManager to load HDR cube textures
  115372. */
  115373. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115374. /**
  115375. * Defines the name of the task
  115376. */
  115377. name: string;
  115378. /**
  115379. * Defines the location of the file to load
  115380. */
  115381. url: string;
  115382. /**
  115383. * Defines the desired size (the more it increases the longer the generation will be)
  115384. */
  115385. size: number;
  115386. /**
  115387. * Defines if mipmaps should not be generated (default is false)
  115388. */
  115389. noMipmap: boolean;
  115390. /**
  115391. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115392. */
  115393. generateHarmonics: boolean;
  115394. /**
  115395. * 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)
  115396. */
  115397. gammaSpace: boolean;
  115398. /**
  115399. * Internal Use Only
  115400. */
  115401. reserved: boolean;
  115402. /**
  115403. * Gets the loaded texture
  115404. */
  115405. texture: HDRCubeTexture;
  115406. /**
  115407. * Callback called when the task is successful
  115408. */
  115409. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115410. /**
  115411. * Callback called when the task is successful
  115412. */
  115413. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115414. /**
  115415. * Creates a new HDRCubeTextureAssetTask object
  115416. * @param name defines the name of the task
  115417. * @param url defines the location of the file to load
  115418. * @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.
  115419. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115420. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115421. * @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)
  115422. * @param reserved Internal use only
  115423. */
  115424. constructor(
  115425. /**
  115426. * Defines the name of the task
  115427. */
  115428. name: string,
  115429. /**
  115430. * Defines the location of the file to load
  115431. */
  115432. url: string,
  115433. /**
  115434. * Defines the desired size (the more it increases the longer the generation will be)
  115435. */
  115436. size: number,
  115437. /**
  115438. * Defines if mipmaps should not be generated (default is false)
  115439. */
  115440. noMipmap?: boolean,
  115441. /**
  115442. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115443. */
  115444. generateHarmonics?: boolean,
  115445. /**
  115446. * 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)
  115447. */
  115448. gammaSpace?: boolean,
  115449. /**
  115450. * Internal Use Only
  115451. */
  115452. reserved?: boolean);
  115453. /**
  115454. * Execute the current task
  115455. * @param scene defines the scene where you want your assets to be loaded
  115456. * @param onSuccess is a callback called when the task is successfully executed
  115457. * @param onError is a callback called if an error occurs
  115458. */
  115459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115460. }
  115461. /**
  115462. * Define a task used by AssetsManager to load Equirectangular cube textures
  115463. */
  115464. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115465. /**
  115466. * Defines the name of the task
  115467. */
  115468. name: string;
  115469. /**
  115470. * Defines the location of the file to load
  115471. */
  115472. url: string;
  115473. /**
  115474. * Defines the desired size (the more it increases the longer the generation will be)
  115475. */
  115476. size: number;
  115477. /**
  115478. * Defines if mipmaps should not be generated (default is false)
  115479. */
  115480. noMipmap: boolean;
  115481. /**
  115482. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115483. * but the standard material would require them in Gamma space) (default is true)
  115484. */
  115485. gammaSpace: boolean;
  115486. /**
  115487. * Gets the loaded texture
  115488. */
  115489. texture: EquiRectangularCubeTexture;
  115490. /**
  115491. * Callback called when the task is successful
  115492. */
  115493. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115494. /**
  115495. * Callback called when the task is successful
  115496. */
  115497. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115498. /**
  115499. * Creates a new EquiRectangularCubeTextureAssetTask object
  115500. * @param name defines the name of the task
  115501. * @param url defines the location of the file to load
  115502. * @param size defines the desired size (the more it increases the longer the generation will be)
  115503. * If the size is omitted this implies you are using a preprocessed cubemap.
  115504. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115505. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115506. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115507. * (default is true)
  115508. */
  115509. constructor(
  115510. /**
  115511. * Defines the name of the task
  115512. */
  115513. name: string,
  115514. /**
  115515. * Defines the location of the file to load
  115516. */
  115517. url: string,
  115518. /**
  115519. * Defines the desired size (the more it increases the longer the generation will be)
  115520. */
  115521. size: number,
  115522. /**
  115523. * Defines if mipmaps should not be generated (default is false)
  115524. */
  115525. noMipmap?: boolean,
  115526. /**
  115527. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115528. * but the standard material would require them in Gamma space) (default is true)
  115529. */
  115530. gammaSpace?: boolean);
  115531. /**
  115532. * Execute the current task
  115533. * @param scene defines the scene where you want your assets to be loaded
  115534. * @param onSuccess is a callback called when the task is successfully executed
  115535. * @param onError is a callback called if an error occurs
  115536. */
  115537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115538. }
  115539. /**
  115540. * This class can be used to easily import assets into a scene
  115541. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115542. */
  115543. export class AssetsManager {
  115544. private _scene;
  115545. private _isLoading;
  115546. protected _tasks: AbstractAssetTask[];
  115547. protected _waitingTasksCount: number;
  115548. protected _totalTasksCount: number;
  115549. /**
  115550. * Callback called when all tasks are processed
  115551. */
  115552. onFinish: (tasks: AbstractAssetTask[]) => void;
  115553. /**
  115554. * Callback called when a task is successful
  115555. */
  115556. onTaskSuccess: (task: AbstractAssetTask) => void;
  115557. /**
  115558. * Callback called when a task had an error
  115559. */
  115560. onTaskError: (task: AbstractAssetTask) => void;
  115561. /**
  115562. * Callback called when a task is done (whatever the result is)
  115563. */
  115564. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115565. /**
  115566. * Observable called when all tasks are processed
  115567. */
  115568. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115569. /**
  115570. * Observable called when a task had an error
  115571. */
  115572. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115573. /**
  115574. * Observable called when all tasks were executed
  115575. */
  115576. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115577. /**
  115578. * Observable called when a task is done (whatever the result is)
  115579. */
  115580. onProgressObservable: Observable<IAssetsProgressEvent>;
  115581. /**
  115582. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115584. */
  115585. useDefaultLoadingScreen: boolean;
  115586. /**
  115587. * Creates a new AssetsManager
  115588. * @param scene defines the scene to work on
  115589. */
  115590. constructor(scene: Scene);
  115591. /**
  115592. * Add a MeshAssetTask to the list of active tasks
  115593. * @param taskName defines the name of the new task
  115594. * @param meshesNames defines the name of meshes to load
  115595. * @param rootUrl defines the root url to use to locate files
  115596. * @param sceneFilename defines the filename of the scene file
  115597. * @returns a new MeshAssetTask object
  115598. */
  115599. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115600. /**
  115601. * Add a TextFileAssetTask to the list of active tasks
  115602. * @param taskName defines the name of the new task
  115603. * @param url defines the url of the file to load
  115604. * @returns a new TextFileAssetTask object
  115605. */
  115606. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115607. /**
  115608. * Add a BinaryFileAssetTask to the list of active tasks
  115609. * @param taskName defines the name of the new task
  115610. * @param url defines the url of the file to load
  115611. * @returns a new BinaryFileAssetTask object
  115612. */
  115613. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115614. /**
  115615. * Add a ImageAssetTask to the list of active tasks
  115616. * @param taskName defines the name of the new task
  115617. * @param url defines the url of the file to load
  115618. * @returns a new ImageAssetTask object
  115619. */
  115620. addImageTask(taskName: string, url: string): ImageAssetTask;
  115621. /**
  115622. * Add a TextureAssetTask to the list of active tasks
  115623. * @param taskName defines the name of the new task
  115624. * @param url defines the url of the file to load
  115625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115626. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115627. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115628. * @returns a new TextureAssetTask object
  115629. */
  115630. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115631. /**
  115632. * Add a CubeTextureAssetTask to the list of active tasks
  115633. * @param taskName defines the name of the new task
  115634. * @param url defines the url of the file to load
  115635. * @param extensions defines the extension to use to load the cube map (can be null)
  115636. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115637. * @param files defines the list of files to load (can be null)
  115638. * @returns a new CubeTextureAssetTask object
  115639. */
  115640. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115641. /**
  115642. *
  115643. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115644. * @param taskName defines the name of the new task
  115645. * @param url defines the url of the file to load
  115646. * @param size defines the size you want for the cubemap (can be null)
  115647. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115648. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115649. * @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)
  115650. * @param reserved Internal use only
  115651. * @returns a new HDRCubeTextureAssetTask object
  115652. */
  115653. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115654. /**
  115655. *
  115656. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115657. * @param taskName defines the name of the new task
  115658. * @param url defines the url of the file to load
  115659. * @param size defines the size you want for the cubemap (can be null)
  115660. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115661. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115662. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115663. * @returns a new EquiRectangularCubeTextureAssetTask object
  115664. */
  115665. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115666. /**
  115667. * Remove a task from the assets manager.
  115668. * @param task the task to remove
  115669. */
  115670. removeTask(task: AbstractAssetTask): void;
  115671. private _decreaseWaitingTasksCount;
  115672. private _runTask;
  115673. /**
  115674. * Reset the AssetsManager and remove all tasks
  115675. * @return the current instance of the AssetsManager
  115676. */
  115677. reset(): AssetsManager;
  115678. /**
  115679. * Start the loading process
  115680. * @return the current instance of the AssetsManager
  115681. */
  115682. load(): AssetsManager;
  115683. /**
  115684. * Start the loading process as an async operation
  115685. * @return a promise returning the list of failed tasks
  115686. */
  115687. loadAsync(): Promise<void>;
  115688. }
  115689. }
  115690. declare module BABYLON {
  115691. /**
  115692. * Wrapper class for promise with external resolve and reject.
  115693. */
  115694. export class Deferred<T> {
  115695. /**
  115696. * The promise associated with this deferred object.
  115697. */
  115698. readonly promise: Promise<T>;
  115699. private _resolve;
  115700. private _reject;
  115701. /**
  115702. * The resolve method of the promise associated with this deferred object.
  115703. */
  115704. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115705. /**
  115706. * The reject method of the promise associated with this deferred object.
  115707. */
  115708. readonly reject: (reason?: any) => void;
  115709. /**
  115710. * Constructor for this deferred object.
  115711. */
  115712. constructor();
  115713. }
  115714. }
  115715. declare module BABYLON {
  115716. /**
  115717. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115718. */
  115719. export class MeshExploder {
  115720. private _centerMesh;
  115721. private _meshes;
  115722. private _meshesOrigins;
  115723. private _toCenterVectors;
  115724. private _scaledDirection;
  115725. private _newPosition;
  115726. private _centerPosition;
  115727. /**
  115728. * Explodes meshes from a center mesh.
  115729. * @param meshes The meshes to explode.
  115730. * @param centerMesh The mesh to be center of explosion.
  115731. */
  115732. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115733. private _setCenterMesh;
  115734. /**
  115735. * Get class name
  115736. * @returns "MeshExploder"
  115737. */
  115738. getClassName(): string;
  115739. /**
  115740. * "Exploded meshes"
  115741. * @returns Array of meshes with the centerMesh at index 0.
  115742. */
  115743. getMeshes(): Array<Mesh>;
  115744. /**
  115745. * Explodes meshes giving a specific direction
  115746. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115747. */
  115748. explode(direction?: number): void;
  115749. }
  115750. }
  115751. declare module BABYLON {
  115752. /**
  115753. * Class used to help managing file picking and drag'n'drop
  115754. */
  115755. export class FilesInput {
  115756. /**
  115757. * List of files ready to be loaded
  115758. */
  115759. static readonly FilesToLoad: {
  115760. [key: string]: File;
  115761. };
  115762. /**
  115763. * Callback called when a file is processed
  115764. */
  115765. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115766. private _engine;
  115767. private _currentScene;
  115768. private _sceneLoadedCallback;
  115769. private _progressCallback;
  115770. private _additionalRenderLoopLogicCallback;
  115771. private _textureLoadingCallback;
  115772. private _startingProcessingFilesCallback;
  115773. private _onReloadCallback;
  115774. private _errorCallback;
  115775. private _elementToMonitor;
  115776. private _sceneFileToLoad;
  115777. private _filesToLoad;
  115778. /**
  115779. * Creates a new FilesInput
  115780. * @param engine defines the rendering engine
  115781. * @param scene defines the hosting scene
  115782. * @param sceneLoadedCallback callback called when scene is loaded
  115783. * @param progressCallback callback called to track progress
  115784. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115785. * @param textureLoadingCallback callback called when a texture is loading
  115786. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115787. * @param onReloadCallback callback called when a reload is requested
  115788. * @param errorCallback callback call if an error occurs
  115789. */
  115790. 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);
  115791. private _dragEnterHandler;
  115792. private _dragOverHandler;
  115793. private _dropHandler;
  115794. /**
  115795. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115796. * @param elementToMonitor defines the DOM element to track
  115797. */
  115798. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115799. /**
  115800. * Release all associated resources
  115801. */
  115802. dispose(): void;
  115803. private renderFunction;
  115804. private drag;
  115805. private drop;
  115806. private _traverseFolder;
  115807. private _processFiles;
  115808. /**
  115809. * Load files from a drop event
  115810. * @param event defines the drop event to use as source
  115811. */
  115812. loadFiles(event: any): void;
  115813. private _processReload;
  115814. /**
  115815. * Reload the current scene from the loaded files
  115816. */
  115817. reload(): void;
  115818. }
  115819. }
  115820. declare module BABYLON {
  115821. /**
  115822. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115824. */
  115825. export class SceneOptimization {
  115826. /**
  115827. * Defines the priority of this optimization (0 by default which means first in the list)
  115828. */
  115829. priority: number;
  115830. /**
  115831. * Gets a string describing the action executed by the current optimization
  115832. * @returns description string
  115833. */
  115834. getDescription(): string;
  115835. /**
  115836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115837. * @param scene defines the current scene where to apply this optimization
  115838. * @param optimizer defines the current optimizer
  115839. * @returns true if everything that can be done was applied
  115840. */
  115841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115842. /**
  115843. * Creates the SceneOptimization object
  115844. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115845. * @param desc defines the description associated with the optimization
  115846. */
  115847. constructor(
  115848. /**
  115849. * Defines the priority of this optimization (0 by default which means first in the list)
  115850. */
  115851. priority?: number);
  115852. }
  115853. /**
  115854. * Defines an optimization used to reduce the size of render target textures
  115855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115856. */
  115857. export class TextureOptimization extends SceneOptimization {
  115858. /**
  115859. * Defines the priority of this optimization (0 by default which means first in the list)
  115860. */
  115861. priority: number;
  115862. /**
  115863. * 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
  115864. */
  115865. maximumSize: number;
  115866. /**
  115867. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115868. */
  115869. step: number;
  115870. /**
  115871. * Gets a string describing the action executed by the current optimization
  115872. * @returns description string
  115873. */
  115874. getDescription(): string;
  115875. /**
  115876. * Creates the TextureOptimization object
  115877. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115878. * @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
  115879. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115880. */
  115881. constructor(
  115882. /**
  115883. * Defines the priority of this optimization (0 by default which means first in the list)
  115884. */
  115885. priority?: number,
  115886. /**
  115887. * 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
  115888. */
  115889. maximumSize?: number,
  115890. /**
  115891. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115892. */
  115893. step?: number);
  115894. /**
  115895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115896. * @param scene defines the current scene where to apply this optimization
  115897. * @param optimizer defines the current optimizer
  115898. * @returns true if everything that can be done was applied
  115899. */
  115900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115901. }
  115902. /**
  115903. * Defines an optimization used to increase or decrease the rendering resolution
  115904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115905. */
  115906. export class HardwareScalingOptimization extends SceneOptimization {
  115907. /**
  115908. * Defines the priority of this optimization (0 by default which means first in the list)
  115909. */
  115910. priority: number;
  115911. /**
  115912. * Defines the maximum scale to use (2 by default)
  115913. */
  115914. maximumScale: number;
  115915. /**
  115916. * Defines the step to use between two passes (0.5 by default)
  115917. */
  115918. step: number;
  115919. private _currentScale;
  115920. private _directionOffset;
  115921. /**
  115922. * Gets a string describing the action executed by the current optimization
  115923. * @return description string
  115924. */
  115925. getDescription(): string;
  115926. /**
  115927. * Creates the HardwareScalingOptimization object
  115928. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115929. * @param maximumScale defines the maximum scale to use (2 by default)
  115930. * @param step defines the step to use between two passes (0.5 by default)
  115931. */
  115932. constructor(
  115933. /**
  115934. * Defines the priority of this optimization (0 by default which means first in the list)
  115935. */
  115936. priority?: number,
  115937. /**
  115938. * Defines the maximum scale to use (2 by default)
  115939. */
  115940. maximumScale?: number,
  115941. /**
  115942. * Defines the step to use between two passes (0.5 by default)
  115943. */
  115944. step?: number);
  115945. /**
  115946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115947. * @param scene defines the current scene where to apply this optimization
  115948. * @param optimizer defines the current optimizer
  115949. * @returns true if everything that can be done was applied
  115950. */
  115951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115952. }
  115953. /**
  115954. * Defines an optimization used to remove shadows
  115955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115956. */
  115957. export class ShadowsOptimization extends SceneOptimization {
  115958. /**
  115959. * Gets a string describing the action executed by the current optimization
  115960. * @return description string
  115961. */
  115962. getDescription(): string;
  115963. /**
  115964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115965. * @param scene defines the current scene where to apply this optimization
  115966. * @param optimizer defines the current optimizer
  115967. * @returns true if everything that can be done was applied
  115968. */
  115969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115970. }
  115971. /**
  115972. * Defines an optimization used to turn post-processes off
  115973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115974. */
  115975. export class PostProcessesOptimization extends SceneOptimization {
  115976. /**
  115977. * Gets a string describing the action executed by the current optimization
  115978. * @return description string
  115979. */
  115980. getDescription(): string;
  115981. /**
  115982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115983. * @param scene defines the current scene where to apply this optimization
  115984. * @param optimizer defines the current optimizer
  115985. * @returns true if everything that can be done was applied
  115986. */
  115987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115988. }
  115989. /**
  115990. * Defines an optimization used to turn lens flares off
  115991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115992. */
  115993. export class LensFlaresOptimization extends SceneOptimization {
  115994. /**
  115995. * Gets a string describing the action executed by the current optimization
  115996. * @return description string
  115997. */
  115998. getDescription(): string;
  115999. /**
  116000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116001. * @param scene defines the current scene where to apply this optimization
  116002. * @param optimizer defines the current optimizer
  116003. * @returns true if everything that can be done was applied
  116004. */
  116005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116006. }
  116007. /**
  116008. * Defines an optimization based on user defined callback.
  116009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116010. */
  116011. export class CustomOptimization extends SceneOptimization {
  116012. /**
  116013. * Callback called to apply the custom optimization.
  116014. */
  116015. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116016. /**
  116017. * Callback called to get custom description
  116018. */
  116019. onGetDescription: () => string;
  116020. /**
  116021. * Gets a string describing the action executed by the current optimization
  116022. * @returns description string
  116023. */
  116024. getDescription(): string;
  116025. /**
  116026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116027. * @param scene defines the current scene where to apply this optimization
  116028. * @param optimizer defines the current optimizer
  116029. * @returns true if everything that can be done was applied
  116030. */
  116031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116032. }
  116033. /**
  116034. * Defines an optimization used to turn particles off
  116035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116036. */
  116037. export class ParticlesOptimization extends SceneOptimization {
  116038. /**
  116039. * Gets a string describing the action executed by the current optimization
  116040. * @return description string
  116041. */
  116042. getDescription(): string;
  116043. /**
  116044. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116045. * @param scene defines the current scene where to apply this optimization
  116046. * @param optimizer defines the current optimizer
  116047. * @returns true if everything that can be done was applied
  116048. */
  116049. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116050. }
  116051. /**
  116052. * Defines an optimization used to turn render targets off
  116053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116054. */
  116055. export class RenderTargetsOptimization extends SceneOptimization {
  116056. /**
  116057. * Gets a string describing the action executed by the current optimization
  116058. * @return description string
  116059. */
  116060. getDescription(): string;
  116061. /**
  116062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116063. * @param scene defines the current scene where to apply this optimization
  116064. * @param optimizer defines the current optimizer
  116065. * @returns true if everything that can be done was applied
  116066. */
  116067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116068. }
  116069. /**
  116070. * Defines an optimization used to merge meshes with compatible materials
  116071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116072. */
  116073. export class MergeMeshesOptimization extends SceneOptimization {
  116074. private static _UpdateSelectionTree;
  116075. /**
  116076. * Gets or sets a boolean which defines if optimization octree has to be updated
  116077. */
  116078. /**
  116079. * Gets or sets a boolean which defines if optimization octree has to be updated
  116080. */
  116081. static UpdateSelectionTree: boolean;
  116082. /**
  116083. * Gets a string describing the action executed by the current optimization
  116084. * @return description string
  116085. */
  116086. getDescription(): string;
  116087. private _canBeMerged;
  116088. /**
  116089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116090. * @param scene defines the current scene where to apply this optimization
  116091. * @param optimizer defines the current optimizer
  116092. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116093. * @returns true if everything that can be done was applied
  116094. */
  116095. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116096. }
  116097. /**
  116098. * Defines a list of options used by SceneOptimizer
  116099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116100. */
  116101. export class SceneOptimizerOptions {
  116102. /**
  116103. * Defines the target frame rate to reach (60 by default)
  116104. */
  116105. targetFrameRate: number;
  116106. /**
  116107. * Defines the interval between two checkes (2000ms by default)
  116108. */
  116109. trackerDuration: number;
  116110. /**
  116111. * Gets the list of optimizations to apply
  116112. */
  116113. optimizations: SceneOptimization[];
  116114. /**
  116115. * Creates a new list of options used by SceneOptimizer
  116116. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116117. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116118. */
  116119. constructor(
  116120. /**
  116121. * Defines the target frame rate to reach (60 by default)
  116122. */
  116123. targetFrameRate?: number,
  116124. /**
  116125. * Defines the interval between two checkes (2000ms by default)
  116126. */
  116127. trackerDuration?: number);
  116128. /**
  116129. * Add a new optimization
  116130. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116131. * @returns the current SceneOptimizerOptions
  116132. */
  116133. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116134. /**
  116135. * Add a new custom optimization
  116136. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116137. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116139. * @returns the current SceneOptimizerOptions
  116140. */
  116141. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116142. /**
  116143. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116144. * @param targetFrameRate defines the target frame rate (60 by default)
  116145. * @returns a SceneOptimizerOptions object
  116146. */
  116147. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116148. /**
  116149. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116150. * @param targetFrameRate defines the target frame rate (60 by default)
  116151. * @returns a SceneOptimizerOptions object
  116152. */
  116153. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116154. /**
  116155. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116156. * @param targetFrameRate defines the target frame rate (60 by default)
  116157. * @returns a SceneOptimizerOptions object
  116158. */
  116159. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116160. }
  116161. /**
  116162. * Class used to run optimizations in order to reach a target frame rate
  116163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116164. */
  116165. export class SceneOptimizer implements IDisposable {
  116166. private _isRunning;
  116167. private _options;
  116168. private _scene;
  116169. private _currentPriorityLevel;
  116170. private _targetFrameRate;
  116171. private _trackerDuration;
  116172. private _currentFrameRate;
  116173. private _sceneDisposeObserver;
  116174. private _improvementMode;
  116175. /**
  116176. * Defines an observable called when the optimizer reaches the target frame rate
  116177. */
  116178. onSuccessObservable: Observable<SceneOptimizer>;
  116179. /**
  116180. * Defines an observable called when the optimizer enables an optimization
  116181. */
  116182. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116183. /**
  116184. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116185. */
  116186. onFailureObservable: Observable<SceneOptimizer>;
  116187. /**
  116188. * Gets a boolean indicating if the optimizer is in improvement mode
  116189. */
  116190. readonly isInImprovementMode: boolean;
  116191. /**
  116192. * Gets the current priority level (0 at start)
  116193. */
  116194. readonly currentPriorityLevel: number;
  116195. /**
  116196. * Gets the current frame rate checked by the SceneOptimizer
  116197. */
  116198. readonly currentFrameRate: number;
  116199. /**
  116200. * Gets or sets the current target frame rate (60 by default)
  116201. */
  116202. /**
  116203. * Gets or sets the current target frame rate (60 by default)
  116204. */
  116205. targetFrameRate: number;
  116206. /**
  116207. * Gets or sets the current interval between two checks (every 2000ms by default)
  116208. */
  116209. /**
  116210. * Gets or sets the current interval between two checks (every 2000ms by default)
  116211. */
  116212. trackerDuration: number;
  116213. /**
  116214. * Gets the list of active optimizations
  116215. */
  116216. readonly optimizations: SceneOptimization[];
  116217. /**
  116218. * Creates a new SceneOptimizer
  116219. * @param scene defines the scene to work on
  116220. * @param options defines the options to use with the SceneOptimizer
  116221. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116222. * @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)
  116223. */
  116224. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116225. /**
  116226. * Stops the current optimizer
  116227. */
  116228. stop(): void;
  116229. /**
  116230. * Reset the optimizer to initial step (current priority level = 0)
  116231. */
  116232. reset(): void;
  116233. /**
  116234. * Start the optimizer. By default it will try to reach a specific framerate
  116235. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116236. */
  116237. start(): void;
  116238. private _checkCurrentState;
  116239. /**
  116240. * Release all resources
  116241. */
  116242. dispose(): void;
  116243. /**
  116244. * Helper function to create a SceneOptimizer with one single line of code
  116245. * @param scene defines the scene to work on
  116246. * @param options defines the options to use with the SceneOptimizer
  116247. * @param onSuccess defines a callback to call on success
  116248. * @param onFailure defines a callback to call on failure
  116249. * @returns the new SceneOptimizer object
  116250. */
  116251. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116252. }
  116253. }
  116254. declare module BABYLON {
  116255. /**
  116256. * Class used to serialize a scene into a string
  116257. */
  116258. export class SceneSerializer {
  116259. /**
  116260. * Clear cache used by a previous serialization
  116261. */
  116262. static ClearCache(): void;
  116263. /**
  116264. * Serialize a scene into a JSON compatible object
  116265. * @param scene defines the scene to serialize
  116266. * @returns a JSON compatible object
  116267. */
  116268. static Serialize(scene: Scene): any;
  116269. /**
  116270. * Serialize a mesh into a JSON compatible object
  116271. * @param toSerialize defines the mesh to serialize
  116272. * @param withParents defines if parents must be serialized as well
  116273. * @param withChildren defines if children must be serialized as well
  116274. * @returns a JSON compatible object
  116275. */
  116276. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116277. }
  116278. }
  116279. declare module BABYLON {
  116280. /**
  116281. * Class used to host texture specific utilities
  116282. */
  116283. export class TextureTools {
  116284. /**
  116285. * Uses the GPU to create a copy texture rescaled at a given size
  116286. * @param texture Texture to copy from
  116287. * @param width defines the desired width
  116288. * @param height defines the desired height
  116289. * @param useBilinearMode defines if bilinear mode has to be used
  116290. * @return the generated texture
  116291. */
  116292. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116293. }
  116294. }
  116295. declare module BABYLON {
  116296. /**
  116297. * This represents the different options avilable for the video capture.
  116298. */
  116299. export interface VideoRecorderOptions {
  116300. /** Defines the mime type of the video */
  116301. mimeType: string;
  116302. /** Defines the video the video should be recorded at */
  116303. fps: number;
  116304. /** Defines the chunk size for the recording data */
  116305. recordChunckSize: number;
  116306. /** The audio tracks to attach to the record */
  116307. audioTracks?: MediaStreamTrack[];
  116308. }
  116309. /**
  116310. * This can helps recording videos from BabylonJS.
  116311. * This is based on the available WebRTC functionalities of the browser.
  116312. *
  116313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116314. */
  116315. export class VideoRecorder {
  116316. private static readonly _defaultOptions;
  116317. /**
  116318. * Returns wehther or not the VideoRecorder is available in your browser.
  116319. * @param engine Defines the Babylon Engine to check the support for
  116320. * @returns true if supported otherwise false
  116321. */
  116322. static IsSupported(engine: Engine): boolean;
  116323. private readonly _options;
  116324. private _canvas;
  116325. private _mediaRecorder;
  116326. private _recordedChunks;
  116327. private _fileName;
  116328. private _resolve;
  116329. private _reject;
  116330. /**
  116331. * True wether a recording is already in progress.
  116332. */
  116333. readonly isRecording: boolean;
  116334. /**
  116335. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116336. * a video file.
  116337. * @param engine Defines the BabylonJS Engine you wish to record
  116338. * @param options Defines options that can be used to customized the capture
  116339. */
  116340. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116341. /**
  116342. * Stops the current recording before the default capture timeout passed in the startRecording
  116343. * functions.
  116344. */
  116345. stopRecording(): void;
  116346. /**
  116347. * Starts recording the canvas for a max duration specified in parameters.
  116348. * @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.
  116349. * @param maxDuration Defines the maximum recording time in seconds.
  116350. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116351. * @return a promise callback at the end of the recording with the video data in Blob.
  116352. */
  116353. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116354. /**
  116355. * Releases internal resources used during the recording.
  116356. */
  116357. dispose(): void;
  116358. private _handleDataAvailable;
  116359. private _handleError;
  116360. private _handleStop;
  116361. }
  116362. }
  116363. declare module BABYLON {
  116364. /**
  116365. * Class containing a set of static utilities functions for screenshots
  116366. */
  116367. export class ScreenshotTools {
  116368. /**
  116369. * Captures a screenshot of the current rendering
  116370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116371. * @param engine defines the rendering engine
  116372. * @param camera defines the source camera
  116373. * @param size This parameter can be set to a single number or to an object with the
  116374. * following (optional) properties: precision, width, height. If a single number is passed,
  116375. * it will be used for both width and height. If an object is passed, the screenshot size
  116376. * will be derived from the parameters. The precision property is a multiplier allowing
  116377. * rendering at a higher or lower resolution
  116378. * @param successCallback defines the callback receives a single parameter which contains the
  116379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116380. * src parameter of an <img> to display it
  116381. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116382. * Check your browser for supported MIME types
  116383. */
  116384. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116385. /**
  116386. * Generates an image screenshot from the specified camera.
  116387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116388. * @param engine The engine to use for rendering
  116389. * @param camera The camera to use for rendering
  116390. * @param size This parameter can be set to a single number or to an object with the
  116391. * following (optional) properties: precision, width, height. If a single number is passed,
  116392. * it will be used for both width and height. If an object is passed, the screenshot size
  116393. * will be derived from the parameters. The precision property is a multiplier allowing
  116394. * rendering at a higher or lower resolution
  116395. * @param successCallback The callback receives a single parameter which contains the
  116396. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116397. * src parameter of an <img> to display it
  116398. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116399. * Check your browser for supported MIME types
  116400. * @param samples Texture samples (default: 1)
  116401. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116402. * @param fileName A name for for the downloaded file.
  116403. */
  116404. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116405. }
  116406. }
  116407. declare module BABYLON {
  116408. /**
  116409. * A cursor which tracks a point on a path
  116410. */
  116411. export class PathCursor {
  116412. private path;
  116413. /**
  116414. * Stores path cursor callbacks for when an onchange event is triggered
  116415. */
  116416. private _onchange;
  116417. /**
  116418. * The value of the path cursor
  116419. */
  116420. value: number;
  116421. /**
  116422. * The animation array of the path cursor
  116423. */
  116424. animations: Animation[];
  116425. /**
  116426. * Initializes the path cursor
  116427. * @param path The path to track
  116428. */
  116429. constructor(path: Path2);
  116430. /**
  116431. * Gets the cursor point on the path
  116432. * @returns A point on the path cursor at the cursor location
  116433. */
  116434. getPoint(): Vector3;
  116435. /**
  116436. * Moves the cursor ahead by the step amount
  116437. * @param step The amount to move the cursor forward
  116438. * @returns This path cursor
  116439. */
  116440. moveAhead(step?: number): PathCursor;
  116441. /**
  116442. * Moves the cursor behind by the step amount
  116443. * @param step The amount to move the cursor back
  116444. * @returns This path cursor
  116445. */
  116446. moveBack(step?: number): PathCursor;
  116447. /**
  116448. * Moves the cursor by the step amount
  116449. * If the step amount is greater than one, an exception is thrown
  116450. * @param step The amount to move the cursor
  116451. * @returns This path cursor
  116452. */
  116453. move(step: number): PathCursor;
  116454. /**
  116455. * Ensures that the value is limited between zero and one
  116456. * @returns This path cursor
  116457. */
  116458. private ensureLimits;
  116459. /**
  116460. * Runs onchange callbacks on change (used by the animation engine)
  116461. * @returns This path cursor
  116462. */
  116463. private raiseOnChange;
  116464. /**
  116465. * Executes a function on change
  116466. * @param f A path cursor onchange callback
  116467. * @returns This path cursor
  116468. */
  116469. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116470. }
  116471. }
  116472. declare module BABYLON {
  116473. /** @hidden */
  116474. export var blurPixelShader: {
  116475. name: string;
  116476. shader: string;
  116477. };
  116478. }
  116479. declare module BABYLON {
  116480. /** @hidden */
  116481. export var bones300Declaration: {
  116482. name: string;
  116483. shader: string;
  116484. };
  116485. }
  116486. declare module BABYLON {
  116487. /** @hidden */
  116488. export var instances300Declaration: {
  116489. name: string;
  116490. shader: string;
  116491. };
  116492. }
  116493. declare module BABYLON {
  116494. /** @hidden */
  116495. export var pointCloudVertexDeclaration: {
  116496. name: string;
  116497. shader: string;
  116498. };
  116499. }
  116500. // Mixins
  116501. interface Window {
  116502. mozIndexedDB: IDBFactory;
  116503. webkitIndexedDB: IDBFactory;
  116504. msIndexedDB: IDBFactory;
  116505. webkitURL: typeof URL;
  116506. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116507. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116508. WebGLRenderingContext: WebGLRenderingContext;
  116509. MSGesture: MSGesture;
  116510. CANNON: any;
  116511. AudioContext: AudioContext;
  116512. webkitAudioContext: AudioContext;
  116513. PointerEvent: any;
  116514. Math: Math;
  116515. Uint8Array: Uint8ArrayConstructor;
  116516. Float32Array: Float32ArrayConstructor;
  116517. mozURL: typeof URL;
  116518. msURL: typeof URL;
  116519. VRFrameData: any; // WebVR, from specs 1.1
  116520. DracoDecoderModule: any;
  116521. setImmediate(handler: (...args: any[]) => void): number;
  116522. }
  116523. interface HTMLCanvasElement {
  116524. requestPointerLock(): void;
  116525. msRequestPointerLock?(): void;
  116526. mozRequestPointerLock?(): void;
  116527. webkitRequestPointerLock?(): void;
  116528. /** Track wether a record is in progress */
  116529. isRecording: boolean;
  116530. /** Capture Stream method defined by some browsers */
  116531. captureStream(fps?: number): MediaStream;
  116532. }
  116533. interface CanvasRenderingContext2D {
  116534. msImageSmoothingEnabled: boolean;
  116535. }
  116536. interface MouseEvent {
  116537. mozMovementX: number;
  116538. mozMovementY: number;
  116539. webkitMovementX: number;
  116540. webkitMovementY: number;
  116541. msMovementX: number;
  116542. msMovementY: number;
  116543. }
  116544. interface Navigator {
  116545. mozGetVRDevices: (any: any) => any;
  116546. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116547. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116548. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116549. webkitGetGamepads(): Gamepad[];
  116550. msGetGamepads(): Gamepad[];
  116551. webkitGamepads(): Gamepad[];
  116552. }
  116553. interface HTMLVideoElement {
  116554. mozSrcObject: any;
  116555. }
  116556. interface Math {
  116557. fround(x: number): number;
  116558. imul(a: number, b: number): number;
  116559. }
  116560. interface WebGLRenderingContext {
  116561. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116562. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116563. vertexAttribDivisor(index: number, divisor: number): void;
  116564. createVertexArray(): any;
  116565. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116566. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116567. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116568. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116569. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116570. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116571. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116572. // Queries
  116573. createQuery(): WebGLQuery;
  116574. deleteQuery(query: WebGLQuery): void;
  116575. beginQuery(target: number, query: WebGLQuery): void;
  116576. endQuery(target: number): void;
  116577. getQueryParameter(query: WebGLQuery, pname: number): any;
  116578. getQuery(target: number, pname: number): any;
  116579. MAX_SAMPLES: number;
  116580. RGBA8: number;
  116581. READ_FRAMEBUFFER: number;
  116582. DRAW_FRAMEBUFFER: number;
  116583. UNIFORM_BUFFER: number;
  116584. HALF_FLOAT_OES: number;
  116585. RGBA16F: number;
  116586. RGBA32F: number;
  116587. R32F: number;
  116588. RG32F: number;
  116589. RGB32F: number;
  116590. R16F: number;
  116591. RG16F: number;
  116592. RGB16F: number;
  116593. RED: number;
  116594. RG: number;
  116595. R8: number;
  116596. RG8: number;
  116597. UNSIGNED_INT_24_8: number;
  116598. DEPTH24_STENCIL8: number;
  116599. /* Multiple Render Targets */
  116600. drawBuffers(buffers: number[]): void;
  116601. readBuffer(src: number): void;
  116602. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116603. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116604. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116605. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116606. // Occlusion Query
  116607. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116608. ANY_SAMPLES_PASSED: number;
  116609. QUERY_RESULT_AVAILABLE: number;
  116610. QUERY_RESULT: number;
  116611. }
  116612. interface WebGLProgram {
  116613. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116614. }
  116615. interface EXT_disjoint_timer_query {
  116616. QUERY_COUNTER_BITS_EXT: number;
  116617. TIME_ELAPSED_EXT: number;
  116618. TIMESTAMP_EXT: number;
  116619. GPU_DISJOINT_EXT: number;
  116620. QUERY_RESULT_EXT: number;
  116621. QUERY_RESULT_AVAILABLE_EXT: number;
  116622. queryCounterEXT(query: WebGLQuery, target: number): void;
  116623. createQueryEXT(): WebGLQuery;
  116624. beginQueryEXT(target: number, query: WebGLQuery): void;
  116625. endQueryEXT(target: number): void;
  116626. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116627. deleteQueryEXT(query: WebGLQuery): void;
  116628. }
  116629. interface WebGLUniformLocation {
  116630. _currentState: any;
  116631. }
  116632. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116633. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116634. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116635. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116636. interface WebGLRenderingContext {
  116637. readonly RASTERIZER_DISCARD: number;
  116638. readonly DEPTH_COMPONENT24: number;
  116639. readonly TEXTURE_3D: number;
  116640. readonly TEXTURE_2D_ARRAY: number;
  116641. readonly TEXTURE_COMPARE_FUNC: number;
  116642. readonly TEXTURE_COMPARE_MODE: number;
  116643. readonly COMPARE_REF_TO_TEXTURE: number;
  116644. readonly TEXTURE_WRAP_R: number;
  116645. readonly HALF_FLOAT: number;
  116646. readonly RGB8: number;
  116647. readonly RED_INTEGER: number;
  116648. readonly RG_INTEGER: number;
  116649. readonly RGB_INTEGER: number;
  116650. readonly RGBA_INTEGER: number;
  116651. readonly R8_SNORM: number;
  116652. readonly RG8_SNORM: number;
  116653. readonly RGB8_SNORM: number;
  116654. readonly RGBA8_SNORM: number;
  116655. readonly R8I: number;
  116656. readonly RG8I: number;
  116657. readonly RGB8I: number;
  116658. readonly RGBA8I: number;
  116659. readonly R8UI: number;
  116660. readonly RG8UI: number;
  116661. readonly RGB8UI: number;
  116662. readonly RGBA8UI: number;
  116663. readonly R16I: number;
  116664. readonly RG16I: number;
  116665. readonly RGB16I: number;
  116666. readonly RGBA16I: number;
  116667. readonly R16UI: number;
  116668. readonly RG16UI: number;
  116669. readonly RGB16UI: number;
  116670. readonly RGBA16UI: number;
  116671. readonly R32I: number;
  116672. readonly RG32I: number;
  116673. readonly RGB32I: number;
  116674. readonly RGBA32I: number;
  116675. readonly R32UI: number;
  116676. readonly RG32UI: number;
  116677. readonly RGB32UI: number;
  116678. readonly RGBA32UI: number;
  116679. readonly RGB10_A2UI: number;
  116680. readonly R11F_G11F_B10F: number;
  116681. readonly RGB9_E5: number;
  116682. readonly RGB10_A2: number;
  116683. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116684. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116685. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116686. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116687. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116688. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116689. 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;
  116690. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116691. readonly TRANSFORM_FEEDBACK: number;
  116692. readonly INTERLEAVED_ATTRIBS: number;
  116693. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116694. createTransformFeedback(): WebGLTransformFeedback;
  116695. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116696. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116697. beginTransformFeedback(primitiveMode: number): void;
  116698. endTransformFeedback(): void;
  116699. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116700. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116701. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116702. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116703. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116704. }
  116705. interface ImageBitmap {
  116706. readonly width: number;
  116707. readonly height: number;
  116708. close(): void;
  116709. }
  116710. interface WebGLQuery extends WebGLObject {
  116711. }
  116712. declare var WebGLQuery: {
  116713. prototype: WebGLQuery;
  116714. new(): WebGLQuery;
  116715. };
  116716. interface WebGLSampler extends WebGLObject {
  116717. }
  116718. declare var WebGLSampler: {
  116719. prototype: WebGLSampler;
  116720. new(): WebGLSampler;
  116721. };
  116722. interface WebGLSync extends WebGLObject {
  116723. }
  116724. declare var WebGLSync: {
  116725. prototype: WebGLSync;
  116726. new(): WebGLSync;
  116727. };
  116728. interface WebGLTransformFeedback extends WebGLObject {
  116729. }
  116730. declare var WebGLTransformFeedback: {
  116731. prototype: WebGLTransformFeedback;
  116732. new(): WebGLTransformFeedback;
  116733. };
  116734. interface WebGLVertexArrayObject extends WebGLObject {
  116735. }
  116736. declare var WebGLVertexArrayObject: {
  116737. prototype: WebGLVertexArrayObject;
  116738. new(): WebGLVertexArrayObject;
  116739. };
  116740. // Type definitions for WebVR API
  116741. // Project: https://w3c.github.io/webvr/
  116742. // Definitions by: six a <https://github.com/lostfictions>
  116743. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116744. interface VRDisplay extends EventTarget {
  116745. /**
  116746. * Dictionary of capabilities describing the VRDisplay.
  116747. */
  116748. readonly capabilities: VRDisplayCapabilities;
  116749. /**
  116750. * z-depth defining the far plane of the eye view frustum
  116751. * enables mapping of values in the render target depth
  116752. * attachment to scene coordinates. Initially set to 10000.0.
  116753. */
  116754. depthFar: number;
  116755. /**
  116756. * z-depth defining the near plane of the eye view frustum
  116757. * enables mapping of values in the render target depth
  116758. * attachment to scene coordinates. Initially set to 0.01.
  116759. */
  116760. depthNear: number;
  116761. /**
  116762. * An identifier for this distinct VRDisplay. Used as an
  116763. * association point in the Gamepad API.
  116764. */
  116765. readonly displayId: number;
  116766. /**
  116767. * A display name, a user-readable name identifying it.
  116768. */
  116769. readonly displayName: string;
  116770. readonly isConnected: boolean;
  116771. readonly isPresenting: boolean;
  116772. /**
  116773. * If this VRDisplay supports room-scale experiences, the optional
  116774. * stage attribute contains details on the room-scale parameters.
  116775. */
  116776. readonly stageParameters: VRStageParameters | null;
  116777. /**
  116778. * Passing the value returned by `requestAnimationFrame` to
  116779. * `cancelAnimationFrame` will unregister the callback.
  116780. * @param handle Define the hanle of the request to cancel
  116781. */
  116782. cancelAnimationFrame(handle: number): void;
  116783. /**
  116784. * Stops presenting to the VRDisplay.
  116785. * @returns a promise to know when it stopped
  116786. */
  116787. exitPresent(): Promise<void>;
  116788. /**
  116789. * Return the current VREyeParameters for the given eye.
  116790. * @param whichEye Define the eye we want the parameter for
  116791. * @returns the eye parameters
  116792. */
  116793. getEyeParameters(whichEye: string): VREyeParameters;
  116794. /**
  116795. * Populates the passed VRFrameData with the information required to render
  116796. * the current frame.
  116797. * @param frameData Define the data structure to populate
  116798. * @returns true if ok otherwise false
  116799. */
  116800. getFrameData(frameData: VRFrameData): boolean;
  116801. /**
  116802. * Get the layers currently being presented.
  116803. * @returns the list of VR layers
  116804. */
  116805. getLayers(): VRLayer[];
  116806. /**
  116807. * Return a VRPose containing the future predicted pose of the VRDisplay
  116808. * when the current frame will be presented. The value returned will not
  116809. * change until JavaScript has returned control to the browser.
  116810. *
  116811. * The VRPose will contain the position, orientation, velocity,
  116812. * and acceleration of each of these properties.
  116813. * @returns the pose object
  116814. */
  116815. getPose(): VRPose;
  116816. /**
  116817. * Return the current instantaneous pose of the VRDisplay, with no
  116818. * prediction applied.
  116819. * @returns the current instantaneous pose
  116820. */
  116821. getImmediatePose(): VRPose;
  116822. /**
  116823. * The callback passed to `requestAnimationFrame` will be called
  116824. * any time a new frame should be rendered. When the VRDisplay is
  116825. * presenting the callback will be called at the native refresh
  116826. * rate of the HMD. When not presenting this function acts
  116827. * identically to how window.requestAnimationFrame acts. Content should
  116828. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116829. * asynchronously from other displays and at differing refresh rates.
  116830. * @param callback Define the eaction to run next frame
  116831. * @returns the request handle it
  116832. */
  116833. requestAnimationFrame(callback: FrameRequestCallback): number;
  116834. /**
  116835. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116836. * Repeat calls while already presenting will update the VRLayers being displayed.
  116837. * @param layers Define the list of layer to present
  116838. * @returns a promise to know when the request has been fulfilled
  116839. */
  116840. requestPresent(layers: VRLayer[]): Promise<void>;
  116841. /**
  116842. * Reset the pose for this display, treating its current position and
  116843. * orientation as the "origin/zero" values. VRPose.position,
  116844. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116845. * updated when calling resetPose(). This should be called in only
  116846. * sitting-space experiences.
  116847. */
  116848. resetPose(): void;
  116849. /**
  116850. * The VRLayer provided to the VRDisplay will be captured and presented
  116851. * in the HMD. Calling this function has the same effect on the source
  116852. * canvas as any other operation that uses its source image, and canvases
  116853. * created without preserveDrawingBuffer set to true will be cleared.
  116854. * @param pose Define the pose to submit
  116855. */
  116856. submitFrame(pose?: VRPose): void;
  116857. }
  116858. declare var VRDisplay: {
  116859. prototype: VRDisplay;
  116860. new(): VRDisplay;
  116861. };
  116862. interface VRLayer {
  116863. leftBounds?: number[] | Float32Array | null;
  116864. rightBounds?: number[] | Float32Array | null;
  116865. source?: HTMLCanvasElement | null;
  116866. }
  116867. interface VRDisplayCapabilities {
  116868. readonly canPresent: boolean;
  116869. readonly hasExternalDisplay: boolean;
  116870. readonly hasOrientation: boolean;
  116871. readonly hasPosition: boolean;
  116872. readonly maxLayers: number;
  116873. }
  116874. interface VREyeParameters {
  116875. /** @deprecated */
  116876. readonly fieldOfView: VRFieldOfView;
  116877. readonly offset: Float32Array;
  116878. readonly renderHeight: number;
  116879. readonly renderWidth: number;
  116880. }
  116881. interface VRFieldOfView {
  116882. readonly downDegrees: number;
  116883. readonly leftDegrees: number;
  116884. readonly rightDegrees: number;
  116885. readonly upDegrees: number;
  116886. }
  116887. interface VRFrameData {
  116888. readonly leftProjectionMatrix: Float32Array;
  116889. readonly leftViewMatrix: Float32Array;
  116890. readonly pose: VRPose;
  116891. readonly rightProjectionMatrix: Float32Array;
  116892. readonly rightViewMatrix: Float32Array;
  116893. readonly timestamp: number;
  116894. }
  116895. interface VRPose {
  116896. readonly angularAcceleration: Float32Array | null;
  116897. readonly angularVelocity: Float32Array | null;
  116898. readonly linearAcceleration: Float32Array | null;
  116899. readonly linearVelocity: Float32Array | null;
  116900. readonly orientation: Float32Array | null;
  116901. readonly position: Float32Array | null;
  116902. readonly timestamp: number;
  116903. }
  116904. interface VRStageParameters {
  116905. sittingToStandingTransform?: Float32Array;
  116906. sizeX?: number;
  116907. sizeY?: number;
  116908. }
  116909. interface Navigator {
  116910. getVRDisplays(): Promise<VRDisplay[]>;
  116911. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116912. }
  116913. interface Window {
  116914. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116915. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116916. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116917. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116918. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116919. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116920. }
  116921. interface Gamepad {
  116922. readonly displayId: number;
  116923. }
  116924. interface XRDevice {
  116925. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116926. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116927. }
  116928. interface XRSession {
  116929. getInputSources(): Array<any>;
  116930. baseLayer: XRWebGLLayer;
  116931. requestFrameOfReference(type: string): Promise<void>;
  116932. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116933. end(): Promise<void>;
  116934. requestAnimationFrame: Function;
  116935. addEventListener: Function;
  116936. }
  116937. interface XRSessionCreationOptions {
  116938. outputContext?: WebGLRenderingContext | null;
  116939. immersive?: boolean;
  116940. environmentIntegration?: boolean;
  116941. }
  116942. interface XRLayer {
  116943. getViewport: Function;
  116944. framebufferWidth: number;
  116945. framebufferHeight: number;
  116946. }
  116947. interface XRView {
  116948. projectionMatrix: Float32Array;
  116949. }
  116950. interface XRFrame {
  116951. getDevicePose: Function;
  116952. getInputPose: Function;
  116953. views: Array<XRView>;
  116954. baseLayer: XRLayer;
  116955. }
  116956. interface XRFrameOfReference {
  116957. }
  116958. interface XRWebGLLayer extends XRLayer {
  116959. framebuffer: WebGLFramebuffer;
  116960. }
  116961. declare var XRWebGLLayer: {
  116962. prototype: XRWebGLLayer;
  116963. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116964. };